Differential abundance analysis (DAA)
Overview of Day 4
12-14
Association testing (alpha & beta diversity)
14-16
Differential abundance analysis
What to say. “Before the break we looked at community-level association testing; now we look at individual taxa.” Heads-up for the teacher: the slide title and table say “Day 4”, but the Oulu course has three days; say “today” and skip the number.
Idea of the slide. A two-row schedule table that shows where this lecture sits in the day: from 12 to 14 association testing (alpha and beta diversity), from 14 to 16 differential abundance analysis. Its only purpose is to orient the students.
Teaching cues. About 1 min. Do not discuss the table. Transition: “Let us recall the three questions we ask of microbiome data.”
Differential abundance
Alpha diversity: how diverse the community is?
Beta diversity: how similar the microbial communities are?
Differential abundance: how individual taxa differ between conditions?
What to say.
Alpha = within one sample, beta = between samples, differential abundance = which specific taxa differ between groups.
Differential abundance gives a taxon-level answer, whereas alpha and beta diversity give community-level summaries.
Idea of the slide. A recap of the three basic questions of community analysis, as three bullets. Alpha diversity: how diverse is the community within a sample? Beta diversity: how similar are the microbial communities between samples? Differential abundance: how do individual taxa differ between conditions? The third is the topic of today and is shown in bold.
Teaching cues. About 2 min. Ask the audience which method they would use for the third question. Most will say a t-test or Wilcoxon test, which sets up the next slides where we show why that is not so simple. Transition: “Let us look at one taxon.”
Differential abundance analysis (DAA)
Goal: identify features (e.g., species) whose abundance varies with external factors: groups, gradients
What to say.
Counts are heavily skewed, with a few large values and many small ones, so boxplots look squashed near zero.
Library size varies a lot between samples, and counts of any taxon tend to grow with it, which means raw counts are not directly comparable between samples. This is why normalisation or modelling of the library size is needed.
Idea of the slide. It defines the goal of DAA: identify features (for example species) whose abundance varies with external factors, either groups or gradients. The R code (shown and run) loads mia and dplyr, loads the built-in Tengeler2020 data set of mia (ADHD patients vs controls) as a TreeSummarizedExperiment tse, computes the library size (total counts per sample, colSums of the counts assay) and stores it in tse$librarysize. It selects one feature, the genus Escherichia-Shigella (Escherichia-Shigella), and extracts its counts across samples as y. It then draws two base-R panels side by side. Left: a boxplot of the counts by patient group (ADHD vs control). Right: a scatter plot with library size on the x axis and the counts of the species on the y axis.
Teaching cues. About 3 min. Ask: “Does Escherichia-Shigella look different between the groups?” Pitfall: a visible difference in raw counts may partly reflect sequencing depth. Transition: “Which approaches exist?”
Differential abundance analysis (DAA)
Approaches:
Classical statistical tests
Microbiome-specific methods
Challenges: compositionality, sparsity, multiple testing
What to say.
DAA is central in microbiome studies but needs caution because of the unusual properties of sequencing data.
Compositionality: the data are relative (the total is fixed by sequencing depth), so when one taxon increases, the others look decreased.
Sparsity: many zeros, because most taxa are absent in most samples.
Multiple testing: hundreds of taxa are tested at once, so some will be significant by chance unless the p-values are corrected.
Idea of the slide. An overview of approaches and challenges. Two kinds of approach: classical statistical tests (t-test, Wilcoxon, linear models) and microbiome-specific methods (tools designed for count and compositional data). Three challenges: compositionality, sparsity, multiple testing.
Teaching cues. About 2 min. Likely question: “What does compositional mean in practice?” If E. coli blooms, every other taxon’s relative abundance falls even if its absolute amount did not change. Transition: “A simple example shows the issues.”
Simple example
Significance (p-value) for the selected feature:
Note: data has 151 OTUs -> multiple testing
What to say.
On the original scale the distribution is dominated by a few huge values; on the log scale the groups are easier to compare.
The Wilcoxon p-value is the answer for this one taxon.
The dataset has hundreds of taxa, so testing each of them without correction gives many false positives.
Idea of the slide. A worked mini-example on the same species. The code reads the data again and draws two boxplots of Escherichia-Shigella abundance by patient group: left on the original count scale (“Original counts”), right on the log10 scale (“Log10 counts”). The commented lines about peerj13075 are an alternative dataset and are not used. Below, wilcox.test(...)$p.value prints the p-value from a Wilcoxon rank-sum test comparing the two groups for this single taxon. The last line, computed inline, states the number of OTUs (features) in the data.
Teaching cues. About 3 min. Likely question: “Why not just correct for multiple testing and move on?” Correction is necessary but not sufficient, because compositionality, zeros and overdispersion remain. Pitfall: log10 of a zero count is minus infinity, and such samples are dropped from the log plot (a warning may appear). Transition: “Why are standard tests potentially problematic?”
Assumptions about the data
Taxonomic profiling data:
Sparse
Non-Gaussian
Zero-inflated
Overdispersed
etc.
-> Usual statistical tests (Wilcoxon, t-test) are potentially problematic.
What to say.
Sparse and zero-inflated: a large share of the entries are zero.
Non-Gaussian: the distributions are skewed, not bell-shaped, so the normality assumption of the t-test fails.
Overdispersed: the variance is larger than a simple count model predicts.
The word is “potentially”: the tests are not automatically wrong, and the next slides show they can still be good defaults.
Idea of the slide. A list of the properties of taxonomic profiling data: sparse, non-Gaussian, zero-inflated, overdispersed, and others. The conclusion in bold: the usual tests (Wilcoxon, t-test) are potentially problematic.
Teaching cues. About 2 min. Ask whether students have seen these properties in their own data. Transition: “One of these properties, variance growing with the mean, is shown on the next slide.”
What to say.
Variance increases with the mean (Taylor’s law), so the equal-variance assumption of simple tests is violated.
Abundant genera behave very differently from rare ones in terms of variability.
Idea of the slide. A screenshot of an older slide titled “Taylor’s law (in HITChip Atlas)”. The left text defines heteroscedasticity (variance increases with the mean) and overdispersion (variance increases faster than proposed by the model); the data are from the HITChip Atlas. The right plot has the mean relative abundance of genera on the x axis (log scale, from about 0.1% to 10%) and the relative abundance in individual samples on the y axis (log scale, 1% to 75%). Each vertical column of dots is one genus across many samples. Read it as: the further right (the more abundant on average), the longer the column, i.e. the larger the spread. The most abundant genera, labelled with arrows (Bacteroides, Prevotella, Faecalibacterium, Oscillospira), show the widest spread.
Teaching cues. About 2 min. Heads-up for the teacher: it is a screenshot from an older deck and has a stray page number at the bottom right; ignore it. Transition: “So, which method should we use? It matters.”
What to say.
The choice of method changes the answer: different DAA tools run on the same datasets report different sets of significant taxa.
This motivates the next slide, which asks what we should do about it.
Idea of the slide. A screenshot of the title of Nearing et al. 2022 (Nature Communications 13:342): “Microbiome differential abundance methods produce different results across 38 datasets”.
Teaching cues. About 2 min. Heads-up for the teacher: the paper is not in the reference list; cite it orally. Likely question: “So which method is correct?” There is no single correct one; the next slide gives defaults that are replicable. Transition: “A more recent study compares simple methods.”
Elementary methods provide more replicable results in microbial differential abundance analysis
Relative abundances with a Wilcoxon test
Log-transformed relative abundances with a t-test
Presence/absence of taxa with logistic regression
Pelto et al. 2025 show that simple methods often give more replicable results.
What to say.
Instead of complex pipelines, simple classical tests may be more reproducible across studies. Replicable here means that the same taxa are found in independent data sets.
The three defaults to remember: Wilcoxon on relative abundances, t-test on log relative abundances, logistic regression on presence/absence.
Presence/absence is a useful complement because of zero inflation.
Idea of the slide. The recommended simple defaults, from Pelto et al. 2025 (the link opens a preview of the paper inside the slides: hover or click). The title states the finding: elementary methods provide more replicable results. Three bullets: relative abundances with a Wilcoxon test; log-transformed relative abundances with a t-test; presence/absence of taxa with logistic regression.
Teaching cues. About 2 min. Transition: “These three methods all have something in common.”
Classical tests are linear models
Relative abundances with a Wilcoxon test
Non-parametric, but can be expressed as a rank-based linear model
\(\mathrm{Rank}(\mathrm{Relative\ abundance}) \sim \mathrm{Group}\)
Log-transformed relative abundances with a t-test
Standard linear model
\(\log(\mathrm{Relative\ abundance}) \sim \mathrm{Group}\)
Presence/absence of taxa with logistic regression
Generalized linear model with logit link
\(\mathrm{Presence} \sim \mathrm{Group}, \quad \mathrm{Presence} \in \{0,1\}\)
What to say.
All three are special cases of a (generalised) linear model with group as the explanatory variable, so you can add covariates (age, sex, batch) to the formula.
The Wilcoxon test is approximately a linear model on ranks.
Simple pipelines are more reproducible than complex ones.
Idea of the slide. It shows that the three simple methods are all linear models, with formulas written as “response ~ group”. (1) Wilcoxon on relative abundances: non-parametric, but it can be expressed as a rank-based linear model, Rank(relative abundance) ~ Group. (2) t-test on log relative abundances: a standard linear model, log(relative abundance) ~ Group. (3) Presence/absence with logistic regression: a generalised linear model with logit link, Presence ~ Group, where Presence is 0 or 1. The slide is set in smaller text.
Teaching cues. About 3 min. Do not go into the maths. Likely question: “Why does this matter?” Because the real analysis almost always needs covariates, and linear models allow that. Transition: “Let us compare Wilcoxon and the t-test on an example.”
Wilcoxon vs t-test
Wilcoxon: compares medians, robust to outliers, non-parametric
t-test: compares means, assumes normality, sensitive to outliers
What to say.
The outliers pull the mean of group 1 upward but barely move the median, so the two tests disagree: in the current rendering the Wilcoxon p-value is about 5e-06 and the t-test p-value about 0.93.
Neither is always right; they test different things (rank shift or median vs difference in means).
The data are simulated; the loaded study dataset is not used on this slide.
Idea of the slide. A comparison of the two tests, with a simulated demonstration. Bullets: Wilcoxon compares medians (strictly, ranks), is robust to outliers, non-parametric; t-test compares means, assumes normality, is sensitive to outliers. The figure shows jittered points for two simulated groups (20 values each); a red line marks each group’s median, a blue line the mean. Group 1 has 18 values around 0.2 plus two big outliers (3 and 3.5), group 2 has values around 0.5. The two p-values are printed in the plot: red for Wilcoxon, blue for the t-test.
Teaching cues. About 3 min. Likely question: “Which one is right?” Neither always; it depends on the question. For skewed microbiome data with outliers the rank-based test is usually more robust. Heads-up for the teacher: the code comment says “means differ but medians don’t”, which is the reverse of what the plot shows (the medians differ, the means are close). Transition: “Time for a demonstration of a dedicated tool.”
Demonstration
What to say. “Now we run a DAA tool on the CRC data.” The next slide shows the call and you run it live in RStudio.
Idea of the slide. A divider announcing the demo.
Teaching cues. Demo about 10 min. Prerequisites: the maaslin3 package must be installed and the data object tse (Tengeler2020) must exist in the session.
library (maaslin3)
maaslin3_out <- maaslin3 (
input_data = tse,
formula = "~ patient_status" ,
normalization = "TSS" ,
transform = "LOG" ,
)
What to say.
MaAsLin3 automates the per-taxon modelling, multiple-testing correction and summaries (tables, plots).
Idea of the slide. The call of maaslin3(). library(maaslin3) loads the package; the call gives the input (input_data = tse), a formula "~ patient_status" (the explanatory variable), normalization = "TSS" (total sum scaling, i.e. relative abundances) and transform = "LOG". So per-taxon linear models are fitted on log relative abundances with the group as explanatory variable, the “simple default” from the previous slides. The slide uses auto-animate.
Expected output: an output folder with result tables and plots, which you can open live.
Teaching cues. About 10 min with the demo. The explanatory variable is the column patient_status (ADHD or control). The output_directory argument is not set on the slide, and your version of maaslin3 may require it. Transition: “Let us summarise.”
Summary on differential abundance
To identify individual significant taxa (w.r.t. age, diet etc.).
make useful statistical assumptions for taxonomic profiling data
control for multiple testing
provide automated tools to summarize results (significances, effect sizes, visualizations)
-> Complements community level beta diversity analyses.
What to say.
DAA finds which individual taxa differ and complements the community-level beta diversity analyses.
Three requirements for a good workflow: sensible assumptions, multiple-testing control, automated summaries.
Idea of the slide. The summary of what a good DAA workflow does, with the take-away in bold. A DAA method identifies individual significant taxa (with respect to age, diet and so on). It should make useful statistical assumptions for taxonomic profiling data, control for multiple testing, and provide automated tools to summarise results (significances, effect sizes, visualisations).
Teaching cues. About 2 min. Transition: “Now the hands-on part.”
What to say. “Time for the hands-on part.”
Idea of the slide. An untitled divider that leads to the exercises.
Teaching cues. About 10 s.
Exercises
From OMA online book, Chapter 16: Differential abundance
What to say. Students work through the OMA chapter on differential abundance on their own computers.
Idea of the slide. The exercise slide: a link to Chapter 16 of the OMA online book (differential abundance); the bullet says “All exercises”, i.e. do all of them.
Teaching cues. Hands-on, about 30 min. Walk around; the likely issue is package installation. Encourage students to try the methods from the lecture and compare their results.
References
What to say. Nothing; references cited in the slides.
Idea of the slide. The reference slide, filled automatically from the bibliography.
Teaching cues. Use the time for questions.
A Critique of Differential Abundance Analysis, and Advocacy for an Alternative. Thomas P. Quinn, Elliott Gordon-Rodriguez, Ionas Erb. arXiv:2104.07266 [stat.ME]
What to say.
All three schools agree that count data must be pre-processed before analysis; they differ in the philosophy and approach.
Compositionalists use log-ratio transformations such as CLR and ALR, absolutists estimate absolute abundances (spike-ins, or methods developed for RNA-seq), proportionalists use simple scaling.
Idea of the slide. A figure from Quinn, Gordon-Rodriguez and Erb (arXiv:2104.07266), “A critique of differential abundance analysis, and advocacy for an alternative”. It is a Venn diagram of three schools of thought: proportionalism (for example proportions, CPM, TPM, rarefaction, other scaling), absolutism (for example edgeR, DESeq2, spike-in nucleotides) and compositionalism (for example CLR, ALR). The overlaps are annotated: results can be interpreted independent of a reference (where proportionalism and absolutism overlap); data carry proportional information (proportionalism and compositionalism); a reference is necessary (absolutism and compositionalism); and in the centre all three agree: the data need to be pre-processed first.
Teaching cues. Optional, about 2 min; it follows the References slide. Use it for discussion if time permits, otherwise skip.
What is a suitable unit for analysis?
What to say.
The unit of analysis does not have to be a single taxon; groups of taxa that vary together can be a useful intermediate level.
Some taxa (for example Prevotella, Dialister) are bistable: their abundance distribution has two modes, so the same individual-level model does not fit well.
Idea of the slide. A discussion slide about the unit of analysis. The question: individual taxa or the total community composition? The suggestion: consider broader sub-ecosystems as an intermediate between these two extremes. The figure (a slide from Lahti et al. 2014, Nature Communications) is titled “Mixture models bring flexibility in modeling”: a bimodal abundance histogram for bistable taxa, independently varying sub-communities drawn as network graphs, and a heatmap of five taxa across 1006 subjects showing combinations of tipping elements.
Teaching cues. Optional, about 2 min. The source is visible only in the image. Transition: “Finally, visualisation.”
Visualization techniques
What to say. “Let us finish with how to look at the data.”
Idea of the slide. A divider for the last part of the lecture, on visualisation techniques.
Teaching cues. About 1 min.
Heatmaps and other visualization techniques
Task: spend a moment testing and understanding the example visualizing taxonomic abundances on heatmaps in OMA Chapter 12
What to say.
Heatmaps show many taxa and samples at once; always say which transformation was used. Here CLR and Z-scoring make rows comparable.
Visualisations complement the statistical tests.
Idea of the slide. An exercise on heatmaps. The slide links to the OMA book section on heatmaps of taxonomic abundances. The picture shows an example heatmap: taxa (mostly phyla) in rows, samples in columns, colours showing the CLR + Z-transformed abundance (blue is below the average of that taxon, white about average, red above; the legend runs from about -4 to 4). Reading it: look for blocks of consistent colour, which indicate groups of samples or taxa that vary together.
Teaching cues. Exercise, about 10 min: students open the linked chapter and run the heatmap example. Heads-up for the teacher: the linked section is in the composition chapter (Chapter 12 in the current book; it was Chapter 9 in older versions). The sample output is the picture on the slide.