Pairwise differences according to taxonomy with imported feature table

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 that it was possible to provide a taxon ID.

Hi there @fjdisofj0ew!

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:

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 it first, prior to providing it to the metadata parameter of this command.

Thanks so much. This was precisely the issue.

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