# cbg-innov/map architecture

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

- Interactive diagram: https://gitdiagram.com/cbg-innov/map
- Repository: https://github.com/cbg-innov/map

## Overview

MAP is a containerized metabarcoding pipeline that turns read files and a parameter spreadsheet into OTU, taxonomy, and BIN results plus reports. Its documented workflow covers demultiplexing and trimming, per-sample and run-wide clustering, sequence correction, chimera and contaminant screening, classification, and reporting. The README documents the stage order and major capabilities; only the sequence-correction implementation was sampled, so other component links reflect documented workflow rather than inspected calls.

Main entry points: [`Docker/5-MAP_final_results.R`](https://github.com/cbg-innov/map/blob/main/Docker/5-MAP_final_results.R) (Final result tables), [`Docker/MAP.sh`](https://github.com/cbg-innov/map/blob/main/Docker/MAP.sh) (Pipeline launcher), [`Docker/2-MAP_runwideotuformat.R`](https://github.com/cbg-innov/map/blob/main/Docker/2-MAP_runwideotuformat.R) (Taxonomy assignment), [`Docker/1-MAP_heatmap.R`](https://github.com/cbg-innov/map/blob/main/Docker/1-MAP_heatmap.R) (Demultiplex and trim)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Run setup"]
  node_launcher["Pipeline launcher<br/>[MAP.sh]"]
  node_inputs["Reads and parameters"]
end

subgraph group_cluster["Read processing"]
  node_demux["Demultiplex and trim<br/>[1-MAP_heatmap.R]"]
  node_sample_cluster["Per-sample clustering<br/>[1-MAP_heatmap.R]"]
  node_runwide["Run-wide clustering"]
end

subgraph group_quality["Sequence quality"]
  node_correction["Sequence correction"]
  node_chimera["Chimera screening"]
  node_contaminants["Contaminant removal"]
end

subgraph group_classify["Classification"]
  node_taxonomy["Taxonomy assignment"]
  node_references[("Reference sequences")]
  node_binmatch["BOLD BIN matching<br/>[6-MAP_binmatch.R]"]
end

subgraph group_results["Results"]
  node_final_results["Final result tables"]
  node_report["Interactive reporting"]
  node_outputs["Run outputs"]
end

node_user(("Researcher"))

node_user -->|"runs pipeline"| node_launcher
node_inputs -->|"supplies inputs"| node_launcher
node_launcher -->|"starts workflow"| node_demux
node_demux -->|"produces reads"| node_sample_cluster
node_sample_cluster -->|"clusters OTUs"| node_runwide
node_runwide -->|"sends sequences"| node_correction
node_correction -->|"passes sequences"| node_chimera
node_chimera -->|"passes OTUs"| node_contaminants
node_contaminants -->|"assigns taxonomy"| node_taxonomy
node_references -->|"provides library"| node_taxonomy
node_taxonomy -->|"provides OTUs"| node_binmatch
node_binmatch -->|"provides matches"| node_final_results
node_final_results -->|"renders results"| node_report
node_final_results -->|"writes tables"| node_outputs
node_report -->|"writes report"| node_outputs

click node_launcher "https://github.com/cbg-innov/map/blob/main/Docker/MAP.sh"
click node_inputs "https://github.com/cbg-innov/map/tree/main/workdir/data"
click node_demux "https://github.com/cbg-innov/map/blob/main/Docker/1-MAP_heatmap.R"
click node_sample_cluster "https://github.com/cbg-innov/map/blob/main/Docker/1-MAP_heatmap.R"
click node_runwide "https://github.com/cbg-innov/map/blob/main/Docker/2-MAP_runwideotuformat.R"
click node_correction "https://github.com/cbg-innov/map/blob/main/Docker/3-MAP_sequence_correction.py"
click node_chimera "https://github.com/cbg-innov/map/blob/main/Docker/2-MAP_runwideotuformat.R"
click node_contaminants "https://github.com/cbg-innov/map/blob/main/Docker/4-RemoveContaminants.R"
click node_taxonomy "https://github.com/cbg-innov/map/blob/main/Docker/2-MAP_runwideotuformat.R"
click node_references "https://github.com/cbg-innov/map/blob/main/Docker/reference_seqs_327K.fasta.zip"
click node_binmatch "https://github.com/cbg-innov/map/blob/main/Docker/6-MAP_binmatch.R"
click node_final_results "https://github.com/cbg-innov/map/blob/main/Docker/5-MAP_final_results.R"
click node_report "https://github.com/cbg-innov/map/blob/main/Docker/7a-MAP_reporting.qmd"
click node_outputs "https://github.com/cbg-innov/map/tree/main/workdir/data/run"

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_launcher,node_inputs toneBlue
class node_demux,node_sample_cluster,node_runwide toneAmber
class node_correction,node_chimera,node_contaminants toneMint
class node_taxonomy,node_references,node_binmatch toneRose
class node_final_results,node_report,node_outputs,node_user toneIndigo
```

## Components

### Run setup

- [Pipeline launcher](https://github.com/cbg-innov/map/blob/main/Docker/MAP.sh): `Docker/MAP.sh`
- [Reads and parameters](https://github.com/cbg-innov/map/tree/main/workdir/data): `workdir/data`

### Read processing

- [Demultiplex and trim](https://github.com/cbg-innov/map/blob/main/Docker/1-MAP_heatmap.R): `Docker/1-MAP_heatmap.R`
- [Per-sample clustering](https://github.com/cbg-innov/map/blob/main/Docker/1-MAP_heatmap.R): `Docker/1-MAP_heatmap.R`
- [Run-wide clustering](https://github.com/cbg-innov/map/blob/main/Docker/2-MAP_runwideotuformat.R): `Docker/2-MAP_runwideotuformat.R`

### Sequence quality

- [Sequence correction](https://github.com/cbg-innov/map/blob/main/Docker/3-MAP_sequence_correction.py): `Docker/3-MAP_sequence_correction.py`
- [Chimera screening](https://github.com/cbg-innov/map/blob/main/Docker/2-MAP_runwideotuformat.R): `Docker/2-MAP_runwideotuformat.R`
- [Contaminant removal](https://github.com/cbg-innov/map/blob/main/Docker/4-RemoveContaminants.R): `Docker/4-RemoveContaminants.R`

### Classification

- [Taxonomy assignment](https://github.com/cbg-innov/map/blob/main/Docker/2-MAP_runwideotuformat.R): `Docker/2-MAP_runwideotuformat.R`
- [Reference sequences](https://github.com/cbg-innov/map/blob/main/Docker/reference_seqs_327K.fasta.zip): `Docker/reference_seqs_327K.fasta.zip`
- [BOLD BIN matching](https://github.com/cbg-innov/map/blob/main/Docker/6-MAP_binmatch.R): `Docker/6-MAP_binmatch.R`

### Results

- [Final result tables](https://github.com/cbg-innov/map/blob/main/Docker/5-MAP_final_results.R): `Docker/5-MAP_final_results.R`
- [Interactive reporting](https://github.com/cbg-innov/map/blob/main/Docker/7a-MAP_reporting.qmd): `Docker/7a-MAP_reporting.qmd`
- [Run outputs](https://github.com/cbg-innov/map/tree/main/workdir/data/run): `workdir/data/run`

### Other components

- **Researcher**

## Connections

- Researcher → Pipeline launcher: runs pipeline (evidence: `README.md`)
- Reads and parameters → Pipeline launcher: supplies inputs (evidence: `README.md`)
- Pipeline launcher → Demultiplex and trim: starts workflow (evidence: `README.md`)
- Demultiplex and trim → Per-sample clustering: produces reads (evidence: `README.md`)
- Per-sample clustering → Run-wide clustering: clusters OTUs (evidence: `README.md`)
- Run-wide clustering → Sequence correction: sends sequences (evidence: `README.md`)
- Sequence correction → Chimera screening: passes sequences (evidence: `README.md`)
- Chimera screening → Contaminant removal: passes OTUs (evidence: `README.md`)
- Contaminant removal → Taxonomy assignment: assigns taxonomy (evidence: `README.md`)
- Reference sequences → Taxonomy assignment: provides library (evidence: `README.md`)
- Taxonomy assignment → BOLD BIN matching: provides OTUs (evidence: `README.md`)
- BOLD BIN matching → Final result tables: provides matches (evidence: `README.md`)
- Final result tables → Interactive reporting: renders results (evidence: `README.md`)
- Final result tables → Run outputs: writes tables (evidence: `README.md`)
- Interactive reporting → Run outputs: writes report (evidence: `README.md`)
