Run date
SciFlow lab notebook · Shared read-only
Which microbes live at four human body sites, and how distinct are those communities?
Run date
Stages
Pipeline
Software
Outputs
Which microbes live at four human body sites, and how distinct are those communities? This demo runs the real QIIME 2 Moving Pictures 16S dataset (Caporaso et al. 2011, 34 samples across gut, tongue, left palm, and right palm) through denoising, taxonomy assignment, and community analysis.
Key results from this run: PERMANOVA on body_site R²=0.563, p=0.001 — body site explains 56% of community variance and the separation is highly significant. PCoA (Bray–Curtis) captures 50.3% + 21.6% of variance on the first two axes. 42 indicator species identified after BH correction. The gut community separates strongly from oral and skin sites; left and right palm are not distinct from each other, reflecting a shared skin microenvironment.
Note on the ordination: NMDS collapses to a near-zero stress solution on this dataset because the body-site groups are so well-separated — the PCoA is the more informative ordination here.
Pipeline: DADA2 denoising → QIIME 2 taxonomy (Silva 138) → alpha/beta diversity → PERMANOVA → indicator species (IndVal).
Built for microbiome labs who want a defensible, end-to-end 16S profiling and diversity workflow on real, well-characterised human data.
3 stages, 3 completed. Each stage below lists the parameters it ran with, the software the run recorded, and the files it produced.
Classify the mock 16S rRNA community to genus level with the Ribosomal Database Project naive-Bayes classifier (bootstrap confidence >= 0.8). Directly answers 'what microbes are in this sample'.
Verbatim command / script not recorded in this run's stage record.
Pivot the RDP fixrank output into a taxa x samples relative-abundance matrix (mock_abundance.csv) and carry env.csv (sample biome metadata) through for between-group comparison.
# Pivot RDP fixrank output -> taxa x samples abundance matrix (INTEGER COUNTS)
# Output named exactly abundance.csv + env.csv (community_analysis.R hardcodes these)
# FIX(C1 2026-05-31): was dividing by sample_tot to emit relative proportions
# (0.0-1.0), causing detect_data_type() to classify as plant_community and
# skip rarefaction + collapse NMDS to stress=0. Now emits raw integer read counts.
import os, csv, glob, shutil
from collections import defaultdict
INPUT_DIR = os.environ.get("INPUT_DIR", "/work/input")
OUTPUT_DIR = os.environ.get("OUTPUT_DIR", "/work/output")
os.makedirs(OUTPUT_DIR, exist_ok=True)
CONF = 0.8
def sample_of(seqid):
return seqid.split("_", 1)[0]
def parse_fixrank(path, counts):
with open(path) as fh:
for line in fh:
line = line.rstrip("\n")
if not line:
continue
parts = line.split("\t")
if len(parts) < 5:
continue
sample = sample_of(parts[0])
best = None
i = 2
while i + 2 < len(parts):
taxon = parts[i].strip().strip('"')
try:
conf = float(parts[i + 2])
except ValueError:
i += 3; continue
if conf >= CONF and taxon and taxon.lower() != "root":
best = taxon
i += 3
if best:
counts[(sample, best)] += 1
counts = defaultdict(int)
rdp_files = glob.glob(os.path.join(INPUT_DIR, "*.rdp"))
print("RDP files found:", rdp_files)
for p in rdp_files:
parse_fixrank(p, counts)
samples = sorted({s for (s, _t) in counts})
taxa = sorted({t for (_s, t) in counts})
print(f"Parsed {len(taxa)} taxa across {len(samples)} samples")
total_reads = sum(counts.values())
print(f"Total read assignments: {total_reads} (integer counts, rarefaction-ready)")
# Write taxa-as-rows, samples-as-columns (community_analysis.R auto-transposes via
# env-overlap detection or dimension heuristic to get samples-as-rows for analysis)
out = os.path.join(OUTPUT_DIR, "abundance.csv")
with open(out, "w", newline="") as fh:
w = csv.writer(fh)
w.writerow(["taxon"] + samples)
for t in taxa:
row = [t] + [counts.get((s, t), 0) for s in samples]
w.writerow(row)
print("Wrote", out)
src_env = os.path.join(INPUT_DIR, "env.csv")
if os.path.exists(src_env):
shutil.copy2(src_env, os.path.join(OUTPUT_DIR, "env.csv"))
print("Carried env.csv through")
else:
print("No env.csv in input dir")
Alpha diversity (Shannon/Simpson/observed), beta diversity (Bray-Curtis), and ordination (PCoA/NMDS) across the 6 samples, tested between gut and soil biomes. Produces the interactive community report.
Verbatim command / script not recorded in this run's stage record.
+ 19 more output file(s) — see Raw artifacts.
50 output files produced across all stages (109.3 MB total). This report is self-contained; structures and trajectories are listed below for reference.