Skip to content

Compare shotgun profilers

Bracken and MetaPhlAn assign different meanings to relative abundance. Bracken redistributes classified fragments using database expectations, while MetaPhlAn estimates organism abundance from clade specific markers. Agreement between the two therefore depends on the database, taxonomic definitions, genome lengths, and detection limits.

The Bracken method describes read reestimation. The MetaPhlAn documentation describes marker based abundance and its output format. Neither profile alone provides absolute microbial cell counts.

Align taxa without changing the denominator

Section titled “Align taxa without changing the denominator”

Use the participants selected in the human shotgun cohort. The preparation script retains bacterial and archaeal species from both tools. It uses the Kraken2 hierarchy to identify those branches in Bracken and the clade paths in MetaPhlAn. It excludes other domains and aggregates MetaPhlAn species entries that share a valid terminal NCBI taxonomic identifier.

Every sample has a row for every species observed anywhere in its profiler’s archived table. An unreported entry becomes an arithmetic zero. This rule makes a group mean include every selected participant, including participants whose profile does not report that species. It does not prove biological absence.

Each profile is normalized over its full retained bacterial and archaeal table. The intersection of NCBI species identifiers then defines shared coverage. The code does not renormalize that intersection to 100 percent, which would conceal profiler specific assignments. Species without an NCBI identifier remain in the MetaPhlAn denominator but cannot join the shared identifier set.

Segatella copri has NCBI identifier 165179. Older references call it Prevotella copri. The example prints its mean across all selected participants in each diagnosis and the conditional mean among positive profile entries. These answer different questions. Use the complete mean when describing the average profile of a diagnosis group.

Both tabs run in the companion microbiome:0.1.0 container. The cohort page explains fixture access and the archived primary run.

The archived read analyses use 30 public runs from the Lloyd-Price and colleagues IBDMDB study, covered by the INSDC data policy. The original iHMP data-use policy also permits use of the clinical metadata; its publication moratorium ended by fall 2018. These data were supplied by Ramnik Xavier and Curtis Huttenhower through the HMP program with NIH Common Fund grant 8U54DK102557.

The archived profiles were produced by MetaPhlAn 4.1.1 with the mpa_vJan25_CHOCOPhlAnSGB_202503 marker database. The bioBakery database policy permits ChocoPhlAn databases with their associated software. This example compares abundance outputs and does not redistribute or modify the marker database. The retained policy notice states the database restrictions. The method credit belongs to Blanco-Míguez and colleagues, MetaPhlAn 4.

library(ggplot2)
library(jsonlite)
metadata <- read.delim("/fixtures/ibdmdb_metadata.tsv",
row.names = 1, check.names = FALSE)
metadata <- metadata[metadata$selected == "True", ]
counts <- t(as.matrix(read.delim("/fixtures/ibdmdb_bracken_counts.tsv",
row.names = 1, check.names = FALSE)))
counts <- counts[rownames(metadata), , drop = FALSE]
stopifnot(identical(rownames(counts), rownames(metadata)))
stopifnot(!anyDuplicated(metadata$subject_id), all(rowSums(counts) > 0))
groups <- c("nonIBD", "CD", "UC")
metadata$diagnosis <- factor(metadata$diagnosis, levels = groups)
dir.create("outputs", showWarnings = FALSE)
metaphlan <- t(as.matrix(read.delim("/fixtures/ibdmdb_metaphlan_percent.tsv",
row.names = 1, check.names = FALSE)))
metaphlan <- metaphlan[rownames(metadata), , drop = FALSE]
stopifnot(all(rowSums(metaphlan) > 0))
bracken <- counts / rowSums(counts)
metaphlan <- metaphlan / rowSums(metaphlan)
shared <- sort(intersect(colnames(bracken), colnames(metaphlan)))
bracken_mass <- rowSums(bracken[, shared, drop = FALSE])
metaphlan_mass <- rowSums(metaphlan[, shared, drop = FALSE])
cat(sprintf("Shared NCBI species IDs: %d\n", length(shared)))
cat(sprintf("Median shared mass, Bracken: %.6f\n", median(bracken_mass)))
cat(sprintf("Median shared mass, MetaPhlAn: %.6f\n", median(metaphlan_mass)))
copri <- "165179"
stopifnot(copri %in% shared)
means <- data.frame()
for (group in groups) {
selected <- metadata$diagnosis == group
values <- 100 * metaphlan[selected, copri]
complete_mean <- mean(values)
positive_mean <- NA_real_
if (any(values > 0)) {
positive_mean <- mean(values[values > 0])
}
cat(sprintf("%s copri: %d/%d reported; all=%.6f%%; positive=%.6f%%\n",
group, sum(values > 0), length(values),
complete_mean, positive_mean))
means <- rbind(means, data.frame(diagnosis = group,
bracken = 100 *
mean(bracken[selected, copri]),
metaphlan = complete_mean))
}
write.table(means, "outputs/copri_means_r.tsv",
sep = "\t", row.names = FALSE, quote = FALSE)
plot_data <- data.frame(bracken = 100 * bracken[, copri],
metaphlan = 100 * metaphlan[, copri],
diagnosis = metadata$diagnosis)
figure <- ggplot(plot_data, aes(bracken, metaphlan, color = diagnosis)) +
geom_abline(slope = 1, intercept = 0, color = "gray", linetype = "dashed") +
geom_point(size = 2.7) + coord_equal(xlim = c(0, 100), ylim = c(0, 100)) +
scale_color_manual(values = c("#287d8e", "#c95d35", "#8462ab")) +
theme_bw(base_size = 11) +
labs(x = "Bracken microbial fragment share (%)",
y = "MetaPhlAn microbial organism share (%)", color = "Diagnosis",
title = "Segatella copri: matched species ID 165179")
ggsave("outputs/shotgun_tool_comparison_r.png", figure,
width = 7, height = 5, dpi = 160)
write_json(list(shared = length(shared),
bracken_mass = median(bracken_mass),
metaphlan_mass = median(metaphlan_mass),
nonibd_copri = means$metaphlan[1],
cd_copri = means$metaphlan[2], uc_copri = means$metaphlan[3]),
"outputs/metrics_r.json", auto_unbox = TRUE, digits = 16)
Shared NCBI species IDs: 163
Median shared mass, Bracken: 0.934260
Median shared mass, MetaPhlAn: 0.821527
nonIBD copri: 4/9 reported; all=24.820718%; positive=55.846616%
CD copri: 1/10 reported; all=0.012442%; positive=0.124420%
UC copri: 1/7 reported; all=8.066254%; positive=56.463780%

The paired profiler plot compares Segatella copri estimates for each participant.

Each point represents the same participant in both profilers. The diagonal shows numerical equality, although the axes measure different abundance targets. Several participants overlap near zero, so visible points do not count participants. Distance from that line is not an error rate. This cohort has no independent species abundance measurement with which to score accuracy.

The shared mass calculation also has a narrow meaning. A shared identifier appears somewhere in both archived feature sets; it need not be reported by both tools in every sample. The two database releases can split or merge taxa differently even when some identifiers match. A broader benchmark needs a documented taxonomy crosswalk and an independent reference.

Keep Bracken’s estimated counts and MetaPhlAn’s abundance percentages separate. Multiplying a marker based percentage by library size does not recover observed species counts. The cohort statistics lesson states which profile defines each analysis.

  • Bracken abundance estimation

    The original documentation explains how database and read length distributions redistribute classified reads. These estimates retain a different target from marker based organismal abundance.

  • MetaPhlAn 4 documentation

    The documentation describes clade specific markers, organismal relative abundance, and taxonomically unidentified species bins. Those distinctions explain why a shared identifier set does not define equal profiler coverage.