Alpha and beta diversity

The commands I describe show how these steps were generally carried out for the 16S rRNA and 18S rRNA datasets.

Alpha rarefaction was done as follows:

# 16S rRNA dataset
qiime diversity alpha-rarefaction \
--i-table feature_table_samples.qza \
--i-phylogeny phylogenetic_tree/rooted_tree.qza \
--p-max-depth 21383 \
--m-metadata-file metadata_for_rarefaction.txt \
--o-visualization alpha_rarefaction/rarefaction_21383.qzv

# 18S rRNA dataset
qiime diversity alpha-rarefaction \
--i-table feature_table_samples_filtered.qza \
--i-phylogeny phylogenetic_tree/rooted_tree.qza \
--p-max-depth 2319 \
--m-metadata-file metadata_for_rarefaction.txt \
--o-visualization alpha_rarefaction/rarefaction_2319.qzv

The core metrics pipeline produces results of standard alpha and beta diversity metrics:

qiime diversity core-metrics-phylogenetic \
--i-phylogeny phylogenetic_tree/rooted_tree.qza \
--i-table feature_table_samples.qza \
--p-sampling-depth 21383 \
--m-metadata-file metadata_for_qiime2.txt \
--output-dir core_metrics \
--p-n-jobs 16 \
--verbose \
&> core_metrics_samples.log

I used the alpha group significance plugin to test for differences in alpha diversity:

# Run plugin for each alpha diversity result
for result in *vector.qza; \
do \
outname=${result/_vector.qza/_group_significance.qzv}; \
qiime diversity alpha-group-significance \
--i-alpha-diversity $result \
--m-metadata-file ../metadata_for_qiime2.txt \
--o-visualization $outname; \
done

Beta rarefaction plots were made to view the effect of multiple rarefactions on the data:

qiime diversity beta-rarefaction \
--i-table feature_table_samples.qza \
--p-metric weighted_unifrac \
--p-clustering-method nj \
--m-metadata-file metadata_for_qiime2.txt \
--p-sampling-depth 21383 \
--i-phylogeny phylogenetic_tree/rooted_tree.qza \
--o-visualization beta_rarefaction/weighted_unifrac.qzv

Beta diversity plots came from the core metrics plugin.

Any time I needed to add metadata to a beta diversity plot, I used the same PCoA matrix each time (rather than rarefying again) and just recreated the Emperor plot with the new metadata, for example:

qiime emperor plot \
--i-pcoa jaccard_pcoa_results.qza \
--m-metadata-file ../metadata_for_qiime2_with_blasto_ANCOM_families.txt \
--o-visualization jaccard_emperor_with_blasto_ANCOM_families.qzv