# Microbial diversity: reproducible teaching example

All four samples and all counts are synthetic. No experimental data, treatment labels or inference are included.

Requirements: Python 3 with the standard library; no external packages.

From this directory:

```bash
python3 diversity_demo.py --self-test
python3 diversity_demo.py synthetic_counts.csv --out results
```

Outputs: results/alpha.csv and results/bray_curtis.csv. The console prints the validation and processing summary. Capture it with `python3 diversity_demo.py synthetic_counts.csv --out results > run.log 2>&1` if desired.

- Richness: number of nonzero taxa.
- Shannon: negative sum of p times ln(p).
- Pielou: Shannon divided by ln(richness), undefined for richness below two.
- Bray–Curtis: sum of absolute differences divided by sum of abundances, calculated here on sample-wise relative abundances; distances involving empty samples are undefined.
- All metrics for an empty sample are marked NA as a quality-control convention.
- This demonstrates calculation, not statistical evidence of treatment effects. It does not substitute for a sequencing or compositional-analysis workflow.

The script includes seven deterministic checks that run before output generation.
