Alpha Diversity¶
Alpha diversity describes the diversity within individual samples. Specifially alpha diversity is measuring your richness (or presence and absence of organisms), the evenness (the abundance of the organisms) and we can also add in the phylogeny to "weight" our alpha/within sample diversity based on shared evolutionary history.
Thus, alpha diversity uses the metadata, feature table, and a phylogenetic tree, which describes the evolutionary relationship between your organisms, to determine the within sample diversity.
Running the Diversity Pipeline (Core Metrics) to Generate Alpha and Beta Diversity (no controls)¶
The core-metrics-phylogenetic command calculates a standard suite of alpha and beta diversity metrics in a single step, rarefying the table to the specified depth:
First we need to load the workshop node (only use this line once, or there wont be enough allocated resources for everyone)¶
sinteractive --reservation=microbiome --time=04:00:00 --partition=amilan --nodes=1 --ntasks=6 --qos=normal
Note: This command will only work during this workshop. we have reserved these resources for this week only, with all future use of Alpine, you will need to use ainteractive --time=04:00:00 --ntasks=6
Activate the QIIME2 Module¶
First we need to move back into the decomp_tutorial directory
Then we will remove the controls from the table, since we checked that they are not contaminated:
qiime feature-table filter-samples \
--i-table dada2/table_nomitochloro.qza \
--m-metadata-file metadata/metadata.txt \
--p-where "[sample_type] != 'control'" \
--o-filtered-table dada2/table_nomitochloro_nocontrol.qza
alpha_rarefaction_curves.qzv from the Rarefaction step. The sampling depth should be the point where diversity curves plateau, deep enough to capture diversity, shallow enough to retain as many samples as possible. The workshop confirmed this depth as 1,500 reads.
--p-sampling-depth, Rarefaction depth (integer). All samples are subsampled to exactly this many reads. Samples with fewer reads than this value are excluded from all downstream diversity analyses.
This creates the core_metrics/ directory containing alpha diversity vectors, distance matrices, and PCoA results.
Alpha Diversity Files¶
Which core-diversity-metric files are alpha diversity and what do they mean? (ordered here from simplest to more complex):
1. Observed features: this is an alpha diversity metric that counts the number of present features in your community.
core_metrics/observed_features_vector.qza
2. Pielou's evenness: an alpha diversity metric that measures relative evenness (a comparison of organism abundance) of species richness
core_metrics/evenness_vector.qza
3. Faith's Phylogenetic Diversity (pd): this is an alpha diversity metric that uses phylogenetic information plus richness (presence/absence of an organism) to determine alpha diversity.
core_metrics/faith_pd_vector.qza
4. Shannon's Diversity: this is an alpha diversity metric that uses richness (presence/absence of an organism) and evenness (organism relative abundance), but does not use phylogeny.
core_metrics/shannon_vector.qza
Alpha Group Significance¶
For categorical data, we use the alpha-group-significance visualizer. Each sample gets one alpha diversity metric because, unlike beta diversity, the math is independent of other samples- more on that later! For now, just remember that alpha diversity is within-sample diversity. So, we don't have to input the group of interest here, the only decision we need to make is which diversity metric we're interested in.
First we’ll look for general patterns in alpha diversity across samples by comparing different categorical groupings of samples to see if there is some relationship to richness. This uses a Kruskal-Wallis H test which is a rank-based nonparametric test that can be used to determine if there are statistically significant differences between two or more groups.
Observed Features¶
- You should still be in the decomp_tutorial directory use
pwdto check.
Number of unique ASVs per sample:
qiime diversity alpha-group-significance \
--i-alpha-diversity core_metrics/observed_features_vector.qza \
--m-metadata-file metadata/metadata.txt \
--o-visualization core_metrics/observed_features_statistics.qzv
Shannon Diversity¶
Diversity metric accounting for both richness and evenness:
qiime diversity alpha-group-significance \
--i-alpha-diversity core_metrics/shannon_vector.qza \
--m-metadata-file metadata/metadata.txt \
--o-visualization core_metrics/shannon_statistics.qzv
Pielou's Evenness¶
How evenly reads are distributed across ASVs (0 = completely uneven, 1 = perfectly even):
qiime diversity alpha-group-significance \
--i-alpha-diversity core_metrics/evenness_vector.qza \
--m-metadata-file metadata/metadata.txt \
--o-visualization core_metrics/evenness_statistics.qzv
Faith's Phylogenetic Diversity¶
Sum of branch lengths in the phylogenetic tree spanned by a sample's ASVs:
qiime diversity alpha-group-significance \
--i-alpha-diversity core_metrics/faith_pd_vector.qza \
--m-metadata-file metadata/metadata.txt \
--o-visualization core_metrics/faiths_pd_statistics.qzv
Continuous covariates¶
For continuous covariates that we think could be associated with alpha diversity, we can use the alpha-correlation visualizer. In this study, a couple of variables we could look at include add_0c and days since placement.
qiime diversity alpha-correlation \
--i-alpha-diversity core_metrics/faith_pd_vector.qza \
--m-metadata-file metadata/metadata.txt \
--o-visualization core_metrics/faith_pd_correlation_statistics.qzv
Since most of our experiments are slightly more complex than just comparing across one categorical or continuous variable, there is the QIIME2 longitudinal plugin. We will explore longitudinal analysis of alpha diversity metrics more in-depth during the longitudinal tutorial.
Soil-Only Analysis¶
Filter to soil samples and re-run core metrics:
qiime feature-table filter-samples \
--i-table dada2/table_nomitochloro.qza \
--m-metadata-file metadata/metadata.txt \
--p-where "[sample_type]='soil'" \
--o-filtered-table dada2/table_nomitochloro_soil.qza
qiime diversity core-metrics-phylogenetic \
--i-table dada2/table_nomitochloro_soil.qza \
--i-phylogeny tree/tree_gg2.qza \
--m-metadata-file metadata/metadata.txt \
--p-sampling-depth 5000 \
--output-dir core_metrics_soil
Re-run observed features visualization for soil only:
qiime diversity alpha-group-significance \
--i-alpha-diversity core_metrics_soil/observed_features_vector.qza \
--m-metadata-file metadata/metadata.txt \
--o-visualization core_metrics_soil/observed_features_statistics.qzv
Outputs¶
| File | Type | Description |
|---|---|---|
core_metrics/observed_features_vector.qza |
Artifact | Observed features per sample |
core_metrics/shannon_vector.qza |
Artifact | Shannon entropy per sample |
core_metrics/evenness_vector.qza |
Artifact | Pielou's evenness per sample |
core_metrics/faith_pd_vector.qza |
Artifact | Faith's PD per sample |
core_metrics/observed_features_statistics.qzv |
Visualization | Group significance for observed features |
core_metrics/shannon_statistics.qzv |
Visualization | Group significance for Shannon |
core_metrics/evenness_statistics.qzv |
Visualization | Group significance for evenness |
core_metrics/faith_pd_statistics.qzv |
Visualization | Group significance for Faith's PD |
table_nomitochloro_soil.qza |
Artifact | Feature table filtered to soil samples |
core_metrics_soil/ |
Directory | Core metrics for soil samples only |
Next: Beta Diversity