Step 7.1: Testing for statistical correlations between metadata categories and diversity data - shenjean/diversity GitHub Wiki

Alpha diversity - Discrete (categorical) metadata category

  • QIIME2 diversity core-metrics outputs Shannon Diversity, Faith Phylogenetic Diversity (a measure of community richness), observed features (OTUs), and evenness metrics.
  • We can test for statistical associations between discrete (categorical) metadata categories and specific alpha diversity metric(s)
  • These commands perform an overall (all groups) and pairwise Kruskal-Wallis test between metadata categories and the specified alpha diversity metric
qiime diversity alpha-group-significance --i-alpha-diversity core-diversity-10000/shannon_vector.qza  --m-metadata-file metadata.txt --o-visualization core-diversity-10000/shannon-group-significance.qzv
qiime diversity alpha-group-significance --i-alpha-diversity core-diversity-10000/observed_features_vector.qza --m-metadata-file metadata.txt --o-visualization core-diversity-10000/observedfeatures-group-significance.qzv
qiime diversity alpha-group-significance --i-alpha-diversity core-diversity-10000/faith_pd_vector.qza --m-metadata-file metadata.txt --o-visualization core-diversity-10000/faith_pd-group-significance.qzv
qiime diversity alpha-group-significance --i-alpha-diversity core-diversity-10000/evenness_vector.qza --m-metadata-file metadata.txt --o-visualization core-diversity-10000/evenness-group-significance.qzv
  • Output files can be exported using the export function or visualized in qiime2view.
  • Example visualization here.

Alpha diversity - Continuous (numerical) metadata category

The qiime diversity alpha-correlation command can be used: https://docs.qiime2.org/2024.10/plugins/available/diversity/alpha-correlation/

qiime diversity alpha-correlation --i-alpha-diversity core-diversity-10000/shannon_vector.qza --m-metadata-file metadata.txt --p-method spearman --o-visualization core-diversity-10000/shannon_correlation.qzv

Beta diversity - Discrete (categorical) data

  • We can also test for associations between discrete (categorical) data and a pre-calculated beta diversity metric using the qiime diversity beta-group-significance command.
  • For each command, you will have to specify a single column in your metadata file (--m-metadata-column) and a specific beta diversity metric (**--i-distance-matrix) to compare.
  • The --p-pairwise option tells the command to also perform pairwise comparisons between samples.
qiime diversity beta-group-significance --i-distance-matrix core-diversity-10000/weighted_unifrac_distance_matrix.qza --m-metadata-file metadata.txt --m-metadata-column Tissue --o-visualization core-diversity-10000/weighted-unifrac-tissue-significance.qzv --p-pairwise
qiime diversity beta-group-significance --i-distance-matrix core-diversity-10000/unweighted_unifrac_distance_matrix.qza --m-metadata-file metadata.txt --m-metadata-column Tissue --o-visualization core-diversity-10000/unweighted-unifrac-tissue-significance.qzv --p-pairwise
qiime diversity beta-group-significance --i-distance-matrix core-diversity-10000/bray_curtis_distance_matrix.qza --m-metadata-file metadata.txt --m-metadata-column Tissue --o-visualization core-diversity-10000/bray-tissue-significance.qzv --p-pairwise
qiime diversity beta-group-significance --i-distance-matrix core-diversity-10000/jaccard_distance_matrix.qza --m-metadata-file metadata.txt --m-metadata-column Tissue --o-visualization core-diversity-10000/jaccard-tissue-significance.qzv --p-pairwise
  • Output files can be exported using the export function or visualized in qiime2view.
  • Example visualization here.

Beta diversity - Continuous (numerical) metadata

For these tests, you can use the qiime diversity beta-correlation and qiime diversity bioenv commands: