Standard curves, detection limits and omics · Choose a method
Microbiome relative abundance in mouse studies: compositional data, cage effects and the false discovery rate
Compare taxa between groups on a log-ratio (CLR) scale, control the false discovery rate across taxa, and treat the cage, not the mouse, as the unit when groups are caged separately. Python and R code.
On this page
Quick answer. 16S read counts only tell you proportions: when one taxon rises, every other taxon’s share falls, even if nothing else changed. Compare taxa on a log-ratio scale (for example, the centred log-ratio (CLR), or a dedicated method such as ALDEx2 or ANCOM-BC), control the false discovery rate across taxa, and check whether the cage is your real unit: mice in the same cage share their microbiota, so if each group lives in its own cages, compare cage averages, not mice. In our simulated studies with no genotype effect at all, CLR tests with mice as n flagged at least one taxon in 68.9% of studies; with cages as n, 2.6%. With only 4 cages per group, though, the cage-level test found a real four-fold change in just 23.4% of studies, so plan enough cages.
Terms used below. Relative abundance: a taxon’s reads ÷ all reads in the sample. Compositional data: parts of a whole that sum to a fixed total, so they cannot move independently. Centred log-ratio (CLR): the log of each taxon’s count minus the average log count across all taxa in that sample, so each taxon is expressed relative to the sample’s geometric mean. Pseudocount: a small number added to counts before taking logs, so zeros can be logged. Cage effect: mice housed together become similar in their microbiota, partly by eating each other’s faeces (coprophagy). Experimental unit: the smallest unit that could receive a different treatment independently; here, the cage when groups are housed in separate cages. Welch’s t-test: a test that compares two groups’ means without assuming equal spreads. Mixed model: a regression with a random effect for each cage (or mouse), so that observations from the same cage are not treated as independent. Degrees of freedom: roughly, the number of independent units minus the number of estimated means; with cages as the unit, it comes from the cages. Geometric mean: the back-transformed mean of the logs. Benjamini–Hochberg (BH): a correction that controls the false discovery rate. False discovery rate (FDR): the expected share of false positives among the taxa called different; q is the BH-adjusted p-value. Rarefying: randomly discarding reads so every sample has the same total. PERMANOVA: a permutation test of whether whole communities differ, using a distance between samples; the Aitchison distance is the Euclidean distance between CLR profiles. 95% confidence interval (CI): the range of values compatible with the data. Power: the chance of detecting an effect that is really there. False positive: a “significant” result when there is no real effect.
Which analysis for your question
| Question | Analysis | Report |
|---|---|---|
| Which taxa differ between groups? | Log-ratio (CLR) or a compositional method (ALDEx2, ANCOM-BC), BH across taxa; the cage as unit when groups are caged separately | Fold change (relative to the geometric mean, or the method’s log fold change) with 95% CI and q for each taxon called |
| Does the overall community differ? | PERMANOVA on the Aitchison distance; with separate caging, use cage averages as the unit; permute within cages only when cages hold both groups | Pseudo-F, R², p, and a check that the groups’ spread (dispersion) is similar; in R, the vegan package (adonis2, betadisper) |
| Groups share cages (mixed housing) | Mice as n with cage as a random effect, since cage-mates still resemble each other (nested data) | As above, with the cage term |
| Change over time in the same mice | A mixed model with mouse (and cage) as random effects | Time × group estimate with 95% CI |
| Several methods disagree | Report the method chosen in advance; treat taxa found by only one method as tentative | Taxa found and the method |
Gloor and colleagues explain that “data that are naturally described as proportions or probabilities, or with a constant or irrelevant sum, are referred to as compositional data”, and that analysing them “by traditional methods can appear to give satisfactory results. However, these results can be misleading and unpredictable”; they describe the CLR transformation for such data (Gloor et al. 2017). Methods disagree in practice: across 38 datasets, differential abundance tools “identified drastically different numbers and sets of significant ASVs, and that results depend on data pre-processing” (Nearing et al. 2022). On housing, Hildebrand and colleagues found that caging explained on average 31.7% of the variation, and advise that groups “should be kept in a mixed microenvironment, that is, in the same cages, or be separated individually. Otherwise, seeming differences between groups could be solely due to microbiota synchronization…” (Hildebrand et al. 2013); McCafferty and colleagues call cage effects “powerful confounding factors in microbiome studies” (McCafferty et al. 2013). The false discovery rate is “the expected proportion of errors among the rejected hypotheses” (Benjamini & Hochberg 1995).
Worked example: a knockout that changes one taxon
Constructed data: 16S read counts (20,000 reads per mouse) for 30 taxa in 16 wild-type (WT) and 16 knockout (KO) mice, housed 4 per cage with each genotype in its own 4 cages, a common design. By design, the knockout raises taxon 01 four-fold (from about 20% of reads); no other taxon changes in absolute amount. Mice in the same cage share a cage-specific shift in every taxon; the ratio of the cage variance to the mouse-to-mouse variance (0.71) is set close to the ratio of the caging and inter-individual shares Hildebrand and colleagues reported (31.7% and 45.5%, a ratio of 0.70). The random seed was the first one tried; the variance settings were changed once, after a first run, to match those published shares. Stored code and data: counts.csv, model.py, make_data.py, analysis.py, analysis.R and the analysis output; analysis.py and analysis.R print the same output.
| Analysis | Taxa called different |
|---|---|
| Relative abundance, Welch’s t-test per taxon, mice as n, uncorrected p < 0.05 | 14 of 30 (13 of them lower in KO) |
| CLR, Welch’s t-test per taxon, mice as n, BH q < 0.05 | 3 (taxa 01, 06, 25) |
| CLR averaged per cage, cages as n (4 vs 4), BH q < 0.05 | 1 (taxon 01) |
| Taxon 01, KO vs WT, CLR with cages as n | 3.43-fold (95% CI 2.57 to 4.58), q = 0.0014 |
On relative abundance, taxon 01’s bloom pushed down the share of almost everything else, and 13 unchanged taxa looked “lower in the knockout”. The CLR removed most of that, but with mice as n, two unchanged taxa still came up, because the mice in each cage are not independent: the cage differences look like genotype differences. Comparing cage averages found only the real change. The CLR fold change compares taxon 01 with the geometric mean of the absolute amounts of all taxa; the bloom raises that geometric mean slightly, so the expected CLR fold change is 3.8 rather than 4, the remaining difference is sampling error, and the 95% CI includes 4. In 10,000 simulated studies of this design (simulation.py, the simulation output):
| Scenario | Relative abundance, mice as n, uncorrected | CLR, mice as n, BH | CLR, cages as n, BH |
|---|---|---|---|
| No genotype effect: at least one of taxa 02–30 called different | 99.6% | 68.9% | 2.6% |
| KO raises taxon 01 four-fold: at least one unchanged taxon called different | 100.0% | 81.6% | 4.3% |
| KO raises taxon 01 four-fold: taxon 01 detected | — | — | 23.4% (power) |
The cage-level analysis keeps false findings rare, but with 4 cages per genotype it detected a four-fold change in only 23.4% of studies; the worked example was one of the luckier ones. The fix is in the design: more cages with fewer mice each, or mixed housing. Cage averages handle random cage-to-cage variation; a systematic difference between the two groups’ cages (for example, the litters they came from) remains confounded with genotype under separate caging, and only mixed housing or random allocation of mice to cages separates the two. With 4 cages per group, q > 0.05 is not evidence that there is no effect. These are rates per study (any false call among taxa 02–30), not the false discovery rate itself, which is the share of false calls among all calls.
The code expects one row per mouse with columns mouse, genotype (WT or KO), cage and one column of read counts per taxon (named taxon_…); export from your software with samples as rows, rename your columns and group labels to match, and run the code in the folder that holds the CSV file. Python needs NumPy, pandas and SciPy; the R code uses base R only.
# Condensed: analysis.py also gives the relative-abundance and mouse-level comparisons and the fold change with its CI
import numpy as np, pandas as pd
from scipy import stats
d = pd.read_csv("counts.csv")
taxa = [c for c in d.columns if c.startswith("taxon_")]
lx = np.log(d[taxa] + 0.5)
clr = lx.sub(lx.mean(axis=1), axis=0) # centred log-ratio per mouse
cm = clr.groupby(d.cage).mean() # average per cage: the cage is the unit
ko = (d.groupby("cage").genotype.first() == "KO").to_numpy()
p = stats.ttest_ind(cm[ko], cm[~ko], equal_var=False).pvalue
print(pd.Series(stats.false_discovery_control(p), index=taxa).sort_values().head()) # BH q-values
t = stats.ttest_ind(cm[ko]['taxon_01'], cm[~ko]['taxon_01'], equal_var=False)
print(np.exp(cm[ko]['taxon_01'].mean() - cm[~ko]['taxon_01'].mean()), np.exp(t.confidence_interval())) # fold change, 95% CI
d <- read.csv("counts.csv"); taxa <- grep("^taxon_", names(d), value = TRUE)
lx <- log(as.matrix(d[, taxa]) + 0.5); clr <- lx - rowMeans(lx) # centred log-ratio per mouse
cm <- apply(clr, 2, function(v) tapply(v, d$cage, mean)) # average per cage
ko <- tapply(d$genotype, d$cage, function(g) g[1]) [rownames(cm)] == "KO"
p <- apply(cm, 2, function(v) t.test(v[ko], v[!ko])$p.value)
head(sort(p.adjust(p, "BH"))) # BH q-values
tt <- t.test(cm[ko, "taxon_01"], cm[!ko, "taxon_01"])
exp(c(fold = mean(cm[ko, "taxon_01"]) - mean(cm[!ko, "taxon_01"]), tt$conf.int)) # fold change, 95% CI
Before you analyse
- Plan the housing. Put mice from both groups in the same cages where the experiment allows, or house them singly, or plan enough cages per group; record the cage of every mouse (what counts as n).
- Choose the method and the zero handling in advance. A pseudocount is the simplest way to log zeros, and its size matters for rare taxa; Gloor and colleagues prefer replacing or estimating zeros (for example with the zCompositions package or ALDEx2). Filter sparse taxa by a prevalence rule set before testing, for example keep taxa present in at least 20% of mice (the example data have no zeros, so nothing was filtered). The CLR compares taxa within each sample, so it largely handles differences in sequencing depth; the pseudocount is the exception, because adding 0.5 matters more in shallow samples.
- Decide on rarefying in advance. McMurdie and Holmes argue that rarefying “is statistically inadmissible because it requires the omission of available valid data” (McMurdie & Holmes 2014); later work defends it for some analyses (Schloss 2024). Either way, state what you did.
- Correct across taxa with Benjamini–Hochberg, and report the number of taxa tested. BH is guaranteed for independent or positively related tests; CLR values of different taxa are partly negatively related, so treat the q-values as approximate. If the study is already done with separate cages, report cage-level estimates with their intervals and state the limited power.
- Report the study fully. STORMS, “a 17-item checklist” developed for human microbiome research (Mirzayi et al. 2021), is a useful starting point; for the animal side, report housing and cage allocation as the ARRIVE 2.0 guidelines ask (Percie du Sert et al. 2020).
Check what an AI assistant ran
- The assistant ran t-tests or Wilcoxon tests on relative abundances. Ask for a log-ratio method and a check of whether one taxon’s change is driving the others.
- The assistant used each mouse as n when each group had its own cages. Ask for cage averages, or a mixed model with cage as a random effect whose genotype test uses cage-level degrees of freedom (not a default z-test).
- The assistant reported uncorrected p-values for many taxa. Ask for Benjamini–Hochberg q-values and the number of taxa tested.
- The assistant did not say how zeros, rare taxa and sequencing depth were handled. Ask for each choice.
Report it
Read counts were transformed with the centred log-ratio after adding a pseudocount of [0.5]. Because each genotype was housed in separate cages ([4] cages of [4] mice per genotype), CLR values were averaged per cage and genotypes were compared per taxon with Welch’s t-test using cages as the unit; p-values were adjusted across [30] taxa with the Benjamini–Hochberg procedure (R [4.3.3]).
One taxon differed between genotypes at q < 0.05: [taxon 01] was [3.43]-fold higher in knockout mice relative to the geometric mean of all taxa (95% CI [2.57] to [4.58]; q = [0.0014]). Because each genotype was housed separately, a systematic difference between the cages of the two genotypes remains possible, and with [4] cages per genotype the study had limited power to detect other differences.
Replace the bracketed values with your own.
References
- Gloor GB, Macklaim JM, Pawlowsky-Glahn V, Egozcue JJ (2017). Microbiome datasets are compositional: and this is not optional. Frontiers in Microbiology 8:2224. doi:10.3389/fmicb.2017.02224
- Nearing JT, Douglas GM, Hayes MG, et al. (2022). Microbiome differential abundance methods produce different results across 38 datasets. Nature Communications 13:342. doi:10.1038/s41467-022-28034-z
- Hildebrand F, Nguyen TLA, Brinkman B, et al. (2013). Inflammation-associated enterotypes, host genotype, cage and inter-individual effects drive gut microbiota variation in common laboratory mice. Genome Biology 14:R4. doi:10.1186/gb-2013-14-1-r4
- McCafferty J, Mühlbauer M, Gharaibeh RZ, et al. (2013). Stochastic changes over time and not founder effects drive cage effects in microbial community assembly in a mouse model. The ISME Journal 7:2116–2125. doi:10.1038/ismej.2013.106
- Benjamini Y, Hochberg Y (1995). Controlling the false discovery rate: a practical and powerful approach to multiple testing. Journal of the Royal Statistical Society: Series B 57:289–300. doi:10.1111/j.2517-6161.1995.tb02031.x
- McMurdie PJ, Holmes S (2014). Waste not, want not: why rarefying microbiome data is inadmissible. PLOS Computational Biology 10:e1003531. doi:10.1371/journal.pcbi.1003531
- Schloss PD (2024). Waste not, want not: revisiting the analysis that called into question the practice of rarefaction. mSphere 9:e00355-23. doi:10.1128/msphere.00355-23
- Percie du Sert N, Hurst V, Ahluwalia A, et al. (2020). The ARRIVE guidelines 2.0: updated guidelines for reporting animal research. PLOS Biology 18:e3000410. doi:10.1371/journal.pbio.3000410
- Mirzayi C, Renson A, Genomic Standards Consortium, et al. (2021). Reporting guidelines for human microbiome research: the STORMS checklist. Nature Medicine 27:1885–1892. doi:10.1038/s41591-021-01552-x
How this page was made
- Written and published by Licklider. Recommendations cite peer-reviewed methods papers and reporting guidelines listed under References; cited passages were checked against the source text.
- The worked example uses constructed data. Its numbers were produced by stored code (Python 3.13 with SciPy 1.18.1; R 4.3.3, base R), and the two languages print identical output; the simulation was run in Python.
- Separate review passes checked the statistics, the citations and readability before publication.