Diversity analysis summarizes the whole microbial community: alpha diversity (within-sample richness and evenness) and beta diversity (between-sample dissimilarity) of an amplicon ASV/OTU table, with QIIME2 core-metrics-phylogenetic, phyloseq/vegan, and scikit-bio. The central discipline is that a diversity number is the output of three choices made before the number appears - the rarefaction depth, the tree, and the metric - so the agent declares all three and shows the conclusion survives a second reasonable choice rather than reading a single p-value.
The two decisions that dominate everything: the sampling depth in core-metrics silently deletes every sample below it (biased toward low-biomass samples), and the tree behind UniFrac/Faith PD is a modeling choice (de novo from short reads loses to SEPP fragment-insertion and Greengenes2 placement). Per-taxon testing belongs to differential-abundance; shotgun profiler tables belong to metagenomics/metagenome-visualization; the shared compositional and rarefaction-debate theory lives in metagenomics/abundance-estimation, and the Hill-number and PERMANOVA-dispersion theory in metagenomics/metagenome-visualization.
BiocManager::install(c('phyloseq', 'picante'))
install.packages(c('vegan', 'GUniFrac'))
# QIIME2 installs as its own conda env (the release tag defines the plugin API and .qza format)
conda env create -n qiime2-amplicon-2024.2 --file https://data.qiime2.org/distro/amplicon/qiime2-amplicon-2024.2-py39-linux-conda.yml
# scikit-bio (Python engine under q2-diversity)
pip install scikit-bio
Conceptual prerequisites:
- An ASV/OTU feature table of integer counts (DADA2/Deblur or a QIIME2 FeatureTable[Frequency]), plus representative sequences if a tree is needed.
- A phylogenetic tree is REQUIRED for UniFrac and Faith PD; prefer a SEPP-into-reference or Greengenes2 tree over a de novo build from short reads.
- Sample metadata with the grouping/covariate columns.
- Reference packages for SEPP (e.g. Greengenes 13_8 or SILVA) are large downloads; the QIIME2 release tag is recorded with the artifacts.
- The table should already have host mitochondria/chloroplast features removed (taxonomy-assignment) and, for low-biomass samples, reagent contaminants removed with decontam (amplicon-processing) - both distort every diversity metric.
Tell your AI agent what you want to do: - "Pick a rarefaction sampling depth from my feature table and tell me which samples it drops" - "Run core-metrics-phylogenetic and report alpha and beta diversity" - "Calculate Shannon and Faith PD per sample and compare my groups" - "Compute weighted and unweighted UniFrac and test the group difference with PERMANOVA and betadisper" - "Build a SEPP fragment-insertion tree instead of a de novo tree for UniFrac"
"I have a QIIME2 feature table. Summarize the per-sample frequencies, show me an alpha-rarefaction curve, recommend a sampling depth on the plateau, and tell me how many and which samples that depth would drop."
"Rarefy my ASV table to the depth I chose, calculate observed features, Shannon, and inverse Simpson, report effective species, and test whether diversity differs between control and treatment with a non-parametric test."
"My reads are V4 16S. Build a SEPP fragment-insertion tree against a full-length reference instead of a de novo MAFFT+FastTree tree, filter out the ASVs that failed to insert, and explain why this matters for UniFrac."
"Compute weighted and unweighted UniFrac plus generalized UniFrac at alpha 0.5, make PCoA plots, run PERMANOVA on each, and pair every PERMANOVA with betadisper so I know whether a significant result is a location shift or a dispersion difference."
"Run a robust Aitchison PCA (RPCA) on my ASV table and tell me which ASVs load on the first axis."
min(sample_sums) - one tiny library drags every sample down to under-saturated noise. Pick a depth from the rarefaction plateau instead.exp(H') (effective species) to compare across the two ecosystems.