# Pairwise differences according to taxonomy with imported feature table

**URL:** https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-with-imported-feature-table/21253
**Category:** Technical Support
**Created:** [November 4, 2021, 2:41pm UTC](https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-with-imported-feature-table/21253 "2021-11-04T14:41:24Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![fjdisofj0ew](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fjdisofj0ew](https://forum.qiime2.org/u/fjdisofj0ew)
#### Post date: [November 4, 2021, 2:41pm UTC](https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-with-imported-feature-table/21253/1 "2021-11-04T14:41:25Z")

</div>

I am having an issue doing a longitudinal pairwise differences test between two time points and two groups using an imported feature table. When I try to select the taxon (Streptococcus\_thermophilus) I would like to compare frequencies between, I get an error. I tried putting the taxon name in quotes and transposing the feature table (although this yields an error because sample IDs are in the first column instead of the first row, and QIIME2 cannot match it with the metadata file). What else can I try, or is there something wrong with my command?

qiime longitudinal pairwise-differences   
--m-metadata-file metadata.tsv   
--i-table species-filtered-table.qza   
--p-metric Streptococcus\_thermophilus   
--p-state-column months-relative-onset   
--p-state-1 -12   
--p-state-2 0   
--p-individual-id-column sample-id   
--p-group-column case-control   
--p-replicate-handling random   
--p-no-parametric   
--o-visualization pairwise-differences.qzv

> Traceback (most recent call last):  
> File ".../qiime2-2021.8/lib/python3.8/site-packages/q2cli/commands.py", line 329, in **call**  
> results = action(\*\*arguments)  
> File "", line 2, in pairwise\_differences  
> File ".../.conda/envs/qiime2-2021.8/lib/python3.8/site-packages/qiime2/sdk/action.py", line 245, in bound\_callable  
> outputs = self._callable\_executor_(scope, callable\_args,  
> File .../.conda/envs/qiime2-2021.8/lib/python3.8/site-packages/qiime2/sdk/action.py", line 453, in _callable\_executor_  
> ret\_val = self.\_callable(output\_dir=temp\_dir, \*\*view\_args)  
> File ".../.conda/envs/qiime2-2021.8/lib/python3.8/site-packages/q2\_longitudinal/\_longitudinal.py", line 47, in pairwise\_differences  
> metadata = \_add\_metric\_to\_metadata(table, \_load\_metadata(metadata), metric)  
> File ".../.conda/envs/qiime2-2021.8/lib/python3.8/site-packages/q2\_longitudinal/\_utilities.py", line 448, in \_add\_metric\_to\_metadata  
> raise ValueError(  
> ValueError: metric must be a valid metadata or feature table column.
> 
> Plugin error from longitudinal:
> 
> metric must be a valid metadata or feature table column.
> 
> See above for debug info.

I think it is looking at the metadata file for the --p-metric, but I assumed from the longitudinal analysis tutorial and this thread [Pairwise differences according to taxonomy qiime2 - #3 by Tina\_Khone](https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-qiime2/19747/3) that it was possible to provide a taxon ID.

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [November 5, 2021, 11:36pm UTC](https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-with-imported-feature-table/21253/2 "2021-11-05T23:36:18Z")

</div>



---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [November 5, 2021, 11:39pm UTC](https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-with-imported-feature-table/21253/3 "2021-11-05T23:39:23Z")

</div>

Hi there @fjdisofj0ew!

> [@fjdisofj0ew](#):
>
> is there something wrong with my command?

I think there might be! If you want to use one of your filtered table's column as the metric, you must provide the table _as metadata_:

```bash
qiime longitudinal pairwise-differences \
  --m-metadata-file metadata.tsv \
  --m-metadata-file species-filtered-table.qza \
  --i-table species-filtered-table.qza \
  --p-metric Streptococcus_thermophilus \
  --p-state-column months-relative-onset \
  --p-state-1 -12 \
  --p-state-2 0 \
  --p-individual-id-column sample-id \
  --p-group-column case-control \
  --p-replicate-handling random \
  --p-no-parametric \
  --o-visualization pairwise-differences.qzv \

```

Depending on the orientation of the table, you might have to [transpose](https://docs.qiime2.org/2021.8/plugins/available/feature-table/transpose/) it first, prior to providing it to the `metadata` parameter of this command.

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [November 5, 2021, 11:39pm UTC](https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-with-imported-feature-table/21253/4 "2021-11-05T23:39:29Z")

</div>



---

<div class="post-metadata">

### Author: ![fjdisofj0ew](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fjdisofj0ew](https://forum.qiime2.org/u/fjdisofj0ew)
#### Post date: [November 8, 2021, 6:33pm UTC](https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-with-imported-feature-table/21253/5 "2021-11-08T18:33:33Z")

</div>

Thanks so much. This was precisely the issue.

---

<div class="post-metadata">

### Author: ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)
#### Post date: [December 10, 2021, 12:33am UTC](https://forum.qiime2.org/t/pairwise-differences-according-to-taxonomy-with-imported-feature-table/21253/6 "2021-12-10T00:33:53Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
