After grouping samples, i can't analyse beta/alpha diversity

Hi everybody,

I am using 2020.2 version and I am trying something new for me:
I grouped samples with a shared feature (in my case, seasons). I merged the dada2 table and it worked:

qiime feature-table group --i-table table-dada2.qza --p-axis sample --m-metadata-file metadata.tsv --m-metadata-column season --p-mode sum --o-grouped-table table-dada2-seasons2.qza

Now, i want to run beta and alpha diversity analyses:

qiime diversity core-metrics-phylogenetic \
  --i-phylogeny rooted-tree.qza \
  --i-table table-dada2-seasons2.qza \
  --p-sampling-depth 100 \
  --m-metadata-file metadata_merged.tsv \
  --output-dir core-metrics-results

and I got this:

Plugin error from diversity:

None of the sample identifiers match between the metadata and the coordinates. Verify that you are using metadata and coordinates corresponding to the same dataset.

Debug info has been saved to /tmp/qiime2-q2cli-err-_kiexhsv.log

And the debug file:

/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/sklearn/metrics/pairwise.py:1735: DataConversionWarning: Data was converted to boolean for metric jaccard
warnings.warn(msg, DataConversionWarning)
Traceback (most recent call last):
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2cli/commands.py”, line 328, in call
results = action(**arguments)
File “</home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/decorator.py:decorator-gen-386>”, line 2, in core_metrics_phylogenetic
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 484, in callable_executor
outputs = self._callable(scope.ctx, **view_args)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2_diversity/_core_metrics.py”, line 53, in core_metrics_phylogenetic
metadata=metadata, n_jobs=n_jobs)
File “</home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/decorator.py:decorator-gen-483>”, line 2, in core_metrics
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 484, in callable_executor
outputs = self._callable(scope.ctx, **view_args)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2_diversity/_core_metrics.py”, line 39, in core_metrics
results += emperor_plot(pcoa=pcoa, metadata=metadata)
File “</home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/decorator.py:decorator-gen-489>”, line 2, in plot
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 245, in bound_callable
output_types, provenance)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/qiime2/sdk/action.py”, line 452, in callable_executor
ret_val = self._callable(output_dir=temp_dir, **view_args)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2_emperor/_plot.py”, line 65, in plot
custom_axes=custom_axes, plot_name=‘plot’)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/q2_emperor/_plot.py”, line 41, in generic_plot
procrustes=procrustes, remote=’.’)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/emperor/core.py”, line 247, in init
ignore_missing_samples)
File “/home/qiime2/miniconda/envs/qiime2-2020.2/lib/python3.6/site-packages/emperor/core.py”, line 325, in _validate_metadata
’ to the same dataset.’ % kind)
ValueError: None of the sample identifiers match between the metadata and the coordinates. Verify that you are using metadata and coordinates corresponding to the same dataset.

I also edited the metadata to fit to the new table but it doesn’t work and I am not sure where I mistook in editing the metadata table. Is there a way to visualize dada2 qza so I can figure out how the metadata should look like.

Thank you very much!

Hi!
To run diversity metrics and other plugins, now you need to create a knew metadata file, in which instead of Sample-IDs you will have a names of the groups. Just copy them from your “season” column. Also you need to “collapse” your metadata - since samples were grouped by season columns, you should have the same number of grouped samples as you have unique values in season column.

Also you need to build a knew tree with your grouped tables.

Thank you for your answer.

I think I did something wrong. I meant to group samples with shared feature, I wanted to keep the other features but just group seasons samples that have same features such as a sampling station and filter size. I need to re-think, is it still possible?

I am also attaching my metadata.

metadata.csv (449 Bytes)

Thank you!

Maybe, it all just depends on the parameters of your study.

For example, I might have metadata like this:

sample-id replicate study-group
s1 1 case
s2-1 1 control
s2-2 2 control

In this study, I have one sample from the “case” study-group, and two samples from the “control” study-group. The two control samples are replicates, that I want to “group” together:

sample-id study-group
s1 case
s2 control

One way to get there is to add a new column to the original metadata file, and then “group” your feature table:

sample-id replicate new-sample-id study-group
s1 1 s1 case
s2-1 1 s2 control
s2-2 2 s2 control
qiime feature-table group \
  --i-table table-dada2.qza \
  --p-axis sample \
  --p-mode sum \
  --m-metadata-file original-metadata.tsv \
  --m-metadata-column new-sample-id \
  --o-grouped-table table-dada2-new-sample-ids.qza

Then, I can take my new sample ID file (that I wrote myself, QIIME 2 can’t make this for you):

sample-id study-group
s1 case
s2 control

and use that in the next step:

qiime diversity core-metrics-phylogenetic \
  --i-phylogeny rooted-tree.qza \
  --i-table table-dada2-new-sample-ids.qza \
  --p-sampling-depth 100 \
  --m-metadata-file new_sample_metadata.tsv \
  --output-dir core-metrics-results

Hope that helps.

You could add another column that describes that relationship:

sample-id barcode station season filter grouper
6144-1-MS AAAACAAA A winter 12 winter-A-12
6144-2-MS AAAACAAT A winter 0.4 winter-A-0.4
6144-3-MS AAAACACA A summer 12 summer-A-12
6144-4-MS AAAACACC B winter 12 winter-B-12
6144-5-MS AAAACACG B winter 0.4 winter-B-0.4
6144-6-MS 6144-7-MS-mnifh B summer 12 summer-B-12
6144-7-MS AAAACAGA B summer 0.4 summer-B-0.4
6144-8-MS AAAACAGC C winter 12 winter-C-12
6144-9-MS AAAACAGG C winter 0.4 winter-C-0.4
6144-10-MS AAAACAAG C summer 12 summer-C-12
6144-11-MS AAAACAAG C summer 0.4 summer-C-0.4

Then, hopefully it becomes pretty clear, there are no groups here, so while you could do this, your study samples don’t support it. If you wanted, you could drop the “filter” from the grouper, and wind up with grouped samples by station and season, but you would have to completely drop the filter column - there is no way to track that kind of info once grouped, make sense?

PS - 100 is a pretty low rarefaction depth…

1 Like

It worked. Thank you for you help.

Regarding the sample depth, this is my mistake. I missed 0.

1 Like

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