Using filtered data in beta diversity analysis

Hello -

I’ve run into a seemingly not-uncommon error when attempting to run the beta-group-significance command:

qiime diversity beta-group-significance
–i-distance-matrix Iceland-2018-1003-core-metrics/Iceland-2018-1003-unweighted-unifrac-distance-matrix.qza
–m-metadata-file Iceland-2018-1003-no-mock.tsv
–m-metadata-column group
–o-visualization no-mock-unweighted-unifrac-sector-significance.qzv

Plugin error from diversity:

All values in the grouping vector are unique. This method cannot operate on a grouping vector with only unique values (e.g., there are no ‘within’ distances because each group of objects contains only a single object).

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

After researching, it appears that my problem is that I have two samples in my data set that each belong to one group. Here are my samples and their groups:

sample-id . barcode-sequence . group
categorical. categorical. categorical
Solo-spot2 . TAGATGCCGTCC . two
Solo-spot3 . CGCTCCTTCCTT . two
Solo-spot4 . CGAGCGCCGTCC . two
Solo-spot5 . TCGAGAGTCCGG . three
Solo-spot6 . GCTCGGCCGGCC . three
Solo-spot8 . AGCTCAGTCCGG . three
Solo-spot9 . ACTGCCGCGTCC . three
Solo-spot10 . TTACTTCTCCGG . three
Solo-spot12 . TGACGCGCGGCC . four
Solo-spot16 . AATGATCTCCGG . one
Solo-spot17 . TTATCAGTCCTT . one
Solo-spot18 . AAGCGTACGTCC . one
Mock1 . TAAGAGAAGTCC . mock1

As you can see, the Mock belongs to its own group (mock1), and Spot12 belongs to its own group (four). All well and good. I have run the following command to remove them from my data:

qiime feature-table filter-samples
–i-table Iceland-2018-1003-table-dada2.qza
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–p-where “[group]=‘three’ AND [group]=‘four’ AND [group]=’one’”
–o-filtered-table Iceland-2018-1003-filtered-table.qza

My question now is, how do I incorporate that into beta diversity? As far as I can tell, beta diversity analysis doesn’t use the table.qza as input, and still needs the metadata file, which was causing the error in the first place.

I am running Qiime2 2020.2 on a cluster installed with conda.

Thanks much!

Hello @16sIceland, apologies for the delay in response. If I understand correctly, your question is concerning how to execute your beta-group-significance command without those problematic bits of data?

If that is the case, I suggest you try the following.

  1. Open up your metadata and delete the two problematic samples.

  2. Filter your distance matrix using that modified metadata (reference).

  3. Attempt running beta-group-significance again with the modified metadata and the filtered matrix.

Thanks for the reply. Based on what I could dig up, I went back in the workflow to before alpha-diversity analysis to incorporate the new filtered-table-dada2. This means my alpha-diversity analysis will be missing the two samples (the mock and Spot12). However, it did run beta-diversity analysis with no errors. I’ll paste my code below.

Am I wrong with going this far back in the workflow to incorporate the filtered data? If there is a way to directly put the filtered data into beta analysis, I don’t see it.

Filter the data to remove Mock1 and Spot12 from the analysis, since they are in their own groups and the beta-diversity analysis doesn’t like that

qiime feature-table filter-samples
–i-table Iceland-2018-1003-table-dada2.qza
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–p-where “[group] IN (‘one’, ‘two’, ‘three’)”
–o-filtered-table Iceland-2018-1003-filtered-table-dada2.qza \

qiime feature-table summarize
–i-table Iceland-2018-1003-filtered-table-dada2.qza
–o-visualization Iceland-2018-1003-filtered-table-dada2.qzv
–m-sample-metadata-file 2018-1003-Solo-Metadata.tsv

Alpha Diversity Metrics

make sure to change p-smalping-depth and p-max depth to match current data set

qiime diversity core-metrics-phylogenetic
–i-phylogeny Iceland-2018-1003-rooted-tree.qza
–i-table Iceland-2018-1003-filtered-table-dada2.qza
–p-sampling-depth 4138
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–output-dir Iceland-2018-1003-core-metrics

qiime diversity alpha-rarefaction
–i-table Iceland-2018-1003-filtered-table-dada2.qza
–i-phylogeny Iceland-2018-1003-rooted-tree.qza
–p-max-depth 16273
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–o-visualization Iceland-2018-1003-filtered-alpha-rarefaction.qzv

qiime diversity alpha-group-significance
–i-alpha-diversity Iceland-2018-1003-core-metrics/faith_pd_vector.qza
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–o-visualization Iceland-2018-1003-core-metrics/Iceland-2018-1003-filtered-faith-pd-group-significance.qzv

qiime diversity alpha-group-significance
–i-alpha-diversity Iceland-2018-1003-core-metrics/evenness_vector.qza
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–o-visualization Iceland-2018-1003-core-metrics/Iceland-2018-1003-filtered-evenness-group-significance.qzv

Beta Diversity Metrics

qiime diversity beta-group-significance
–i-distance-matrix Iceland-2018-1003-core-metrics/unweighted_unifrac_distance_matrix.qza
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–m-metadata-column year-of-last-ice
–o-visualization Iceland-2018-1003-core-metrics/unweighted-unifrac-sector-significance.qzv

qiime emperor plot
–i-pcoa Iceland-2018-1003-core-metrics/unweighted_unifrac_pcoa_results.qza
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–p-custom-axes year-of-last-ice
–o-visualization Iceland-2018-1003-core-metrics/unweighted-unifrac-emperor-sector.qzv

qiime emperor plot
–i-pcoa Iceland-2018-1003-core-metrics/bray_curtis_pcoa_results.qza
–m-metadata-file 2018-1003-Solo-Metadata.tsv
–p-custom-axes year-of-last-ice
–o-visualization Iceland-2018-1003-core-metrics/bray-curtis-emperor-sector.qzv

My apologies @16sIceland, that link I sent in my original response didn’t quite take you where I intended. This is where I was trying to point you.

I believe you can filter the distance matrices immediately before their use in beta-diversity-analysis using the filter-distance-matrix method described at the above link.

EDIT: Additionally, it is possible to generate distance matrices independently of alpha-diversity calculations using qiime diversity beta and qiime diversity beta-phylogenetic

Thanks, that makes more sense. I will look into these options.

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