A human shotgun cohort
Repeated stool samples do not provide independent participants. This case study starts from archived IBDMDB shotgun profiles and selects one eligible sample per participant before comparing nonIBD, Crohn’s disease, and ulcerative colitis. The abbreviations CD and UC refer to the two disease groups.
What these profiles contain
Section titled “What these profiles contain”The source study is IBDMDB, PRJNA398089,
a longitudinal study with repeated samples. This teaching subset is a small
selection from that study, not a reproduction of its full cohort analysis.
The source selection contains ten samples per diagnosis. Participant identifiers
come from ENA’s host_subject_id, and dates come from collection_date.
Diagnoses are checked against the official
IBDMDB metadata, dated August 20, 2018.
The original selector filled missing disease fields with nonIBD. This
preparation instead matches each ENA participant to the official participant
record and requires agreement with the archived label. All archived labels
agree with that independent source. Missing ENA disease fields alone do not
establish that a participant belongs to the nonIBD group.
The profiles come from an archived March 2026 AWS Batch run. Its recorded
software includes nf-core/taxprofiler 1.2.6, Kraken2 2.1.5, Bracken 3.0.1,
and MetaPhlAn 4.1.1. The Kraken2 database is PlusPF capped at 8 GB, dated
June 5, 2024. MetaPhlAn uses mpa_vJan25_CHOCOPhlAnSGB_202503.
The parameters enable fastp and BBDuk filtering and disable host removal.
This case study reruns the downstream R and Python analyses. It does not rerun the primary pipeline, verify the original FASTQ files, or recover the missing database archive checksums. Disabled host removal limits interpretation of classification fractions and does not establish that the input lacked human DNA. The separately executed taxprofiler example uses another dataset and a newer pipeline release.
Select the analysis unit
Section titled “Select the analysis unit”The teaching eligibility rule requires at least 100,000 Kraken2 input fragments. This threshold removes an extreme low depth sample; it is not a validated clinical cutoff. Kraken2 reports paired fragments as units, so this count does not mean the number of individual FASTQ records or the original library size.
Among eligible samples, retain the earliest collection date for each participant. Break date ties by run accession. The earliest archived eligible sample need not be that participant’s baseline visit. A low depth sample can be excluded while a later eligible sample from the same participant remains.
The code recalculates this selection from the committed manifest and verifies that it matches the preparation script. Both languages preserve an exclusion reason for every omitted sample and check participant uniqueness.
Run the selection and depth checks
Section titled “Run the selection and depth checks”The companion repository
requires access. It preserves the original reports, ENA XML records, source
hashes, and preparation script. Its microbiome:0.1.0 container mounts the
checked fixtures at /fixtures and runs without network access. Public study
accessions remain available through ENA.
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.
library(ggplot2)library(jsonlite)
metadata <- read.delim("/fixtures/ibdmdb_metadata.tsv", colClasses = "character", check.names = FALSE)metadata$kraken_fragments <- as.numeric(metadata$kraken_fragments)metadata$selected <- metadata$selected == "True"stopifnot(!anyDuplicated(metadata$sample_id))eligible <- metadata[metadata$kraken_fragments >= 100000, ]eligible <- eligible[order(eligible$collection_date, eligible$sample_id), ]selected <- eligible[!duplicated(eligible$subject_id), ]stopifnot(setequal(selected$sample_id, metadata$sample_id[metadata$selected]))stopifnot(!anyDuplicated(selected$subject_id))groups <- c("nonIBD", "CD", "UC")cat(sprintf("Archived samples: %d; selected participants: %d\n", nrow(metadata), nrow(selected)))for (group in groups) { cat(sprintf("%s: %d\n", group, sum(selected$diagnosis == group)))}excluded <- metadata[!metadata$selected, ]for (i in seq_len(nrow(excluded))) { cat(sprintf("Excluded %s: %s; %d fragments\n", excluded$sample_id[i], excluded$reason[i], excluded$kraken_fragments[i]))}cat(sprintf("Selected input fragments: %d to %d\n", min(selected$kraken_fragments), max(selected$kraken_fragments)))dir.create("outputs", showWarnings = FALSE)write.table(selected, "outputs/selected_r.tsv", sep = "\t", row.names = FALSE, quote = FALSE)metadata$diagnosis <- factor(metadata$diagnosis, levels = groups)metadata$position <- ave(seq_len(nrow(metadata)), metadata$diagnosis, FUN = seq_along)figure <- ggplot(metadata, aes(position, kraken_fragments, color = diagnosis, shape = selected)) + geom_point(size = 2.7) + geom_hline(yintercept = 100000, linetype = "dashed") + scale_y_log10() + facet_wrap(~diagnosis, nrow = 1) + scale_color_manual(values = c("#287d8e", "#c95d35", "#8462ab")) + theme_bw(base_size = 11) + labs(x = "Sample order within diagnosis", y = "Kraken2 input fragments", color = "Diagnosis", shape = "Selected")ggsave("outputs/human_shotgun_depth_r.png", figure, width = 8, height = 4.2, dpi = 160)write_json(list(samples = nrow(metadata), participants = nrow(selected), nonibd = sum(selected$diagnosis == "nonIBD"), cd = sum(selected$diagnosis == "CD"), uc = sum(selected$diagnosis == "UC"), min_fragments = min(selected$kraken_fragments)), "outputs/metrics_r.json", auto_unbox = TRUE, digits = 16)Archived samples: 30; selected participants: 26nonIBD: 9CD: 10UC: 7Excluded SRR5936190: later_eligible_sample; 915707 fragmentsExcluded SRR5946728: below_depth_threshold; 1901 fragmentsExcluded SRR5946791: later_eligible_sample; 16280054 fragmentsExcluded SRR5950641: later_eligible_sample; 8442926 fragmentsSelected input fragments: 791120 to 20363047
import jsonfrom pathlib import Path
import matplotlib.pyplot as pltimport numpy as npimport pandas as pd
metadata = pd.read_csv("/fixtures/ibdmdb_metadata.tsv", sep="\t", dtype=str)metadata["kraken_fragments"] = metadata["kraken_fragments"].astype(int)metadata["selected"] = metadata["selected"].eq("True")assert metadata["sample_id"].is_uniqueeligible = metadata.loc[metadata["kraken_fragments"] >= 100000]selected = eligible.sort_values(["collection_date", "sample_id"])selected = selected.drop_duplicates("subject_id")assert set(selected["sample_id"]) == set( metadata.loc[metadata["selected"], "sample_id"])assert selected["subject_id"].is_uniquegroups = ["nonIBD", "CD", "UC"]print(f"Archived samples: {len(metadata)}; " f"selected participants: {len(selected)}")for group in groups: print(f"{group}: {selected['diagnosis'].eq(group).sum()}")for row in metadata.loc[~metadata["selected"]].itertuples(): print(f"Excluded {row.sample_id}: {row.reason}; " f"{row.kraken_fragments} fragments")print(f"Selected input fragments: {selected['kraken_fragments'].min()} " f"to {selected['kraken_fragments'].max()}")output = Path("outputs")output.mkdir(exist_ok=True)selected.to_csv(output / "selected_python.tsv", sep="\t", index=False)figure, axes = plt.subplots(1, 3, figsize=(8, 4.2), sharey=True)colors = ["#287d8e", "#c95d35", "#8462ab"]for axis, group, color in zip(axes, groups, colors): rows = metadata.loc[metadata["diagnosis"].eq(group)] positions = np.arange(1, len(rows) + 1) for retained, marker in [(True, "o"), (False, "x")]: mask = rows["selected"].eq(retained) axis.scatter(positions[mask], rows.loc[mask, "kraken_fragments"], marker=marker, color=color, label=f"Selected: {retained}") axis.axhline(100000, color="gray", linestyle="--") axis.set(title=group, yscale="log", xlabel="Sample order")axes[0].set_ylabel("Kraken2 input fragments")axes[0].legend(fontsize=8)figure.tight_layout()figure.savefig(output / "human_shotgun_depth_python.png", dpi=160)plt.close(figure)metrics = {"samples": len(metadata), "participants": len(selected), "min_fragments": int(selected["kraken_fragments"].min())}for group, key in zip(groups, ["nonibd", "cd", "uc"]): metrics[key] = int(selected["diagnosis"].eq(group).sum())(output / "metrics_python.json").write_text(json.dumps(metrics))Archived samples: 30; selected participants: 26nonIBD: 9CD: 10UC: 7Excluded SRR5936190: later_eligible_sample; 915707 fragmentsExcluded SRR5946728: below_depth_threshold; 1901 fragmentsExcluded SRR5946791: later_eligible_sample; 16280054 fragmentsExcluded SRR5950641: later_eligible_sample; 8442926 fragmentsSelected input fragments: 791120 to 20363047
Interpret the retained cohort
Section titled “Interpret the retained cohort”The depth figure includes every archived sample. The dashed line marks the eligibility threshold, and the point shape identifies the final selection. The retained samples still differ in sequencing effort. A depth threshold does not make their detection limits equal.
The next page compares Bracken and MetaPhlAn on these same participants. The cohort statistics lesson uses bacterial and archaeal species estimates from Bracken. These estimates exclude viral, eukaryotic, unclassified, and other unresolved assignments.
The selected cohort supports a cross sectional teaching comparison. Treatment, age, collection site, disease activity, and sequencing effort can confound it. The examples do not estimate a disease effect adjusted for those variables or reproduce the original longitudinal study’s conclusions.
Further reading
Section titled “Further reading”-
The original study describes repeated measurements and links its sequence data to PRJNA398089. The small selection in this lesson does not reproduce its longitudinal analysis.
-
The study download page identifies the metadata update from August 20, 2018. This is the participant source used to check diagnoses separately from missing ENA fields.
-
The manual defines a paired sequence as one classification unit and distinguishes clade fragments from directly assigned fragments. Those definitions determine the depth threshold denominator.