# epi2me-labs/wf-metagenomics architecture

> Architecture diagram of the GitHub repository epi2me-labs/wf-metagenomics, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/epi2me-labs/wf-metagenomics
- Repository: https://github.com/epi2me-labs/wf-metagenomics

## Overview

Metagenomics is a Nextflow workflow for classifying sequencing reads and producing taxonomic profiles, with optional host depletion, AMR detection, and alignment-focused outputs. The documented path is input FASTQ/BAM through concatenation and read statistics, optional host filtering, one of two classification approaches, then abundance and report outputs. The graph also retains the substantial report-analysis modules identified in the source index. Workflow wiring beyond the README-described stages is not verified from sampled Nextflow source, so edges use the README as evidence.

Main entry points: [`subworkflows/minimap_pipeline.nf`](https://github.com/epi2me-labs/wf-metagenomics/blob/master/subworkflows/minimap_pipeline.nf) (Minimap2 alignment), [`bin/workflow_glue/abundance_tables.py`](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/abundance_tables.py) (Abundance tables), [`subworkflows/common_pipeline.nf`](https://github.com/epi2me-labs/wf-metagenomics/blob/master/subworkflows/common_pipeline.nf) (Concatenate and stats), [`bin/workflow_glue/report.py`](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/report.py) (Interactive report)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Workflow stages"]
  node_orchestrator["Nextflow workflow<br/>[main.nf]"]
  node_readprep["Concatenate and stats<br/>[common_pipeline.nf]"]
  node_hostfilter["Host depletion<br/>[common.nf]"]
end

subgraph group_classify["Classification"]
  node_kraken["Kraken2 classification<br/>[kraken_pipeline.nf]"]
  node_bracken["Bracken abundance<br/>[run_bracken.py]"]
  node_minimap["Minimap2 alignment"]
  node_amr["AMR detection<br/>[amr.nf]"]
end

subgraph group_reporting["Analysis and reports"]
  node_abundance["Abundance tables"]
  node_alignstats["Alignment statistics<br/>[alignment_stats.py]"]
  node_reportutils["Report analytics<br/>[report_utils.py]"]
  node_diversity["Diversity metrics<br/>[diversity.py]"]
  node_report["Interactive report<br/>[report.py]"]
end

subgraph group_glue["Workflow glue"]
  node_lineages["Lineage aggregation"]
  node_models["Result models<br/>[common.py]"]
  node_igv["IGV configuration<br/>[configure_igv.py]"]
end

node_user(("Sequencing data"))
node_alignmentfiles["Alignment outputs"]
node_profile["Taxonomic profile"]

node_user -->|"provides reads"| node_orchestrator
node_orchestrator -->|"starts with"| node_readprep
node_readprep -.->|"optionally filters"| node_hostfilter
node_readprep -->|"classifies with"| node_kraken
node_readprep -->|"aligns with"| node_minimap
node_kraken -->|"estimates abundance"| node_bracken
node_kraken -.->|"feeds profiles"| node_abundance
node_bracken -.->|"produces counts"| node_abundance
node_minimap -->|"reports alignment stats"| node_alignstats
node_minimap -.->|"optionally outputs BAMs"| node_alignmentfiles
node_minimap -.->|"optionally configures IGV"| node_igv
node_abundance -->|"writes abundance table"| node_profile
node_abundance -.->|"supplies profile data"| node_report
node_alignstats -.->|"supplies alignment plots"| node_report
node_reportutils -->|"supports report"| node_report
node_diversity -->|"calculates diversity"| node_reportutils
node_lineages -.->|"aggregates lineages"| node_abundance
node_amr -->|"reports AMR results"| node_report
node_hostfilter -->|"excludes mapped reads"| node_minimap

click node_orchestrator "https://github.com/epi2me-labs/wf-metagenomics/blob/master/main.nf"
click node_readprep "https://github.com/epi2me-labs/wf-metagenomics/blob/master/subworkflows/common_pipeline.nf"
click node_hostfilter "https://github.com/epi2me-labs/wf-metagenomics/blob/master/modules/local/common.nf"
click node_kraken "https://github.com/epi2me-labs/wf-metagenomics/blob/master/subworkflows/kraken_pipeline.nf"
click node_bracken "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/run_bracken.py"
click node_minimap "https://github.com/epi2me-labs/wf-metagenomics/blob/master/subworkflows/minimap_pipeline.nf"
click node_amr "https://github.com/epi2me-labs/wf-metagenomics/blob/master/modules/local/amr.nf"
click node_abundance "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/abundance_tables.py"
click node_lineages "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/aggregate_lineages.py"
click node_alignstats "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/alignment_stats.py"
click node_reportutils "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/report_utils/report_utils.py"
click node_diversity "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/diversity.py"
click node_report "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/report.py"
click node_models "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/models/common.py"
click node_igv "https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/wfg_helpers/configure_igv.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_orchestrator,node_readprep,node_hostfilter toneBlue
class node_kraken,node_bracken,node_minimap,node_amr toneAmber
class node_abundance,node_alignstats,node_reportutils,node_diversity,node_report toneMint
class node_lineages,node_models,node_igv toneRose
class node_user,node_alignmentfiles,node_profile toneIndigo
```

## Components

### Workflow stages

- [Nextflow workflow](https://github.com/epi2me-labs/wf-metagenomics/blob/master/main.nf): `main.nf`
- [Concatenate and stats](https://github.com/epi2me-labs/wf-metagenomics/blob/master/subworkflows/common_pipeline.nf): `subworkflows/common_pipeline.nf`
- [Host depletion](https://github.com/epi2me-labs/wf-metagenomics/blob/master/modules/local/common.nf): `modules/local/common.nf`

### Classification

- [Kraken2 classification](https://github.com/epi2me-labs/wf-metagenomics/blob/master/subworkflows/kraken_pipeline.nf): `subworkflows/kraken_pipeline.nf`
- [Bracken abundance](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/run_bracken.py): `bin/workflow_glue/run_bracken.py`
- [Minimap2 alignment](https://github.com/epi2me-labs/wf-metagenomics/blob/master/subworkflows/minimap_pipeline.nf): `subworkflows/minimap_pipeline.nf`
- [AMR detection](https://github.com/epi2me-labs/wf-metagenomics/blob/master/modules/local/amr.nf): `modules/local/amr.nf`

### Analysis and reports

- [Abundance tables](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/abundance_tables.py): `bin/workflow_glue/abundance_tables.py`
- [Alignment statistics](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/alignment_stats.py): `bin/workflow_glue/alignment_stats.py`
- [Report analytics](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/report_utils/report_utils.py): `bin/workflow_glue/report_utils/report_utils.py`
- [Diversity metrics](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/diversity.py): `bin/workflow_glue/diversity.py`
- [Interactive report](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/report.py): `bin/workflow_glue/report.py`

### Workflow glue

- [Lineage aggregation](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/aggregate_lineages.py): `bin/workflow_glue/aggregate_lineages.py`
- [Result models](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/models/common.py): `bin/workflow_glue/models/common.py`
- [IGV configuration](https://github.com/epi2me-labs/wf-metagenomics/blob/master/bin/workflow_glue/wfg_helpers/configure_igv.py): `bin/workflow_glue/wfg_helpers/configure_igv.py`

### Other components

- **Sequencing data**
- **Alignment outputs**
- **Taxonomic profile**

## Connections

- Sequencing data → Nextflow workflow: provides reads (evidence: `README.md`)
- Nextflow workflow → Concatenate and stats: starts with (evidence: `README.md`)
- Concatenate and stats → Host depletion: optionally filters (evidence: `README.md`)
- Concatenate and stats → Kraken2 classification: classifies with (evidence: `README.md`)
- Concatenate and stats → Minimap2 alignment: aligns with (evidence: `README.md`)
- Kraken2 classification → Bracken abundance: estimates abundance (evidence: `README.md`)
- Kraken2 classification → Abundance tables: feeds profiles
- Bracken abundance → Abundance tables: produces counts
- Minimap2 alignment → Alignment statistics: reports alignment stats (evidence: `README.md`)
- Minimap2 alignment → Alignment outputs: optionally outputs BAMs (evidence: `README.md`)
- Minimap2 alignment → IGV configuration: optionally configures IGV (evidence: `README.md`)
- Abundance tables → Taxonomic profile: writes abundance table (evidence: `README.md`)
- Abundance tables → Interactive report: supplies profile data
- Alignment statistics → Interactive report: supplies alignment plots (evidence: `README.md`)
- Report analytics → Interactive report: supports report (evidence: `bin/workflow_glue/report.py`)
- Diversity metrics → Report analytics: calculates diversity (evidence: `bin/workflow_glue/report_utils/report_utils.py`)
- Lineage aggregation → Abundance tables: aggregates lineages
- AMR detection → Interactive report: reports AMR results (evidence: `README.md`)
- Host depletion → Minimap2 alignment: excludes mapped reads (evidence: `README.md`)
