# rinaldi-rpy/downstream_bioinformatic architecture

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

- Interactive diagram: https://gitdiagram.com/rinaldi-rpy/downstream_bioinformatic
- Repository: https://github.com/rinaldi-rpy/downstream_bioinformatic

## Overview

This repository is a buffalo population-genomics analysis workflow. Users provide a merged VCF and sample metadata; the launchers select stages, which perform genotype QC, LD pruning, PCA, replicated ADMIXTURE, windowed FST, block-bootstrap FST, and replicated TreeMix analysis with summaries and plots. Metadata validation and chromosome remapping are useful shared internal layers. The README documents the principal stage order and capabilities; links among unsampled stage implementations reflect that documentation, not inspected calls. The graph omits deployment and legacy material.

Main entry points: [`run_pipeline.sh`](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/run_pipeline.sh) (Stage-select launcher), [`run_treemix.sh`](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/run_treemix.sh) (Replicated TreeMix), [`shell/admixture.sh`](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/admixture.sh) (Replicated ADMIXTURE), [`python/fst_analysis.py`](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/fst_analysis.py) (FST block bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Workflow entry"]
  node_all_launcher["All-stage launcher<br/>[run_all.sh]"]
  node_stage_launcher["Stage-select launcher<br/>[run_pipeline.sh]"]
end

subgraph group_genotypes["Genotype analyses"]
  node_qc["SNP QC<br/>[qc.sh]"]
  node_ld["LD pruning<br/>[ld.sh]"]
  node_pca["PCA<br/>[pca.sh]"]
end

subgraph group_population["Population analyses"]
  node_admixture["Replicated ADMIXTURE<br/>[admixture.sh]"]
  node_fst["Windowed pairwise FST<br/>[fst.sh]"]
  node_fst_bootstrap["FST block bootstrap<br/>[fst_analysis.py]"]
  node_treemix["Replicated TreeMix<br/>[run_treemix.sh]"]
end

subgraph group_reporting["Summaries and plots"]
  node_admixture_summary["ADMIXTURE summaries"]
  node_treemix_summary["TreeMix summaries<br/>[treemix_summary.py]"]
  node_fst_plot["FST and NJ plots<br/>[plot_fst.R]"]
  node_treemix_plot["TreeMix plots<br/>[plot_treemix.R]"]
end

subgraph group_shared["Shared analysis layers"]
  node_treemix_mapping["TreeMix population mapping<br/>[treemix_map.py]"]
  node_treemix_conversion["TreeMix input conversion<br/>[treemix_convert.py]"]
  node_metadata_layer["Metadata validation<br/>[metadata.py]"]
  node_chromosome_layer["Chromosome remapping<br/>[remap_bim.py]"]
end

node_researcher(("Researcher"))
node_vcf["Merged VCF"]
node_metadata_input["Sample metadata"]
node_tools["Analysis executables"]

node_researcher -->|"starts workflow"| node_all_launcher
node_researcher -->|"selects stages"| node_stage_launcher
node_vcf -->|"supplies input"| node_all_launcher
node_metadata_input -->|"supplies metadata"| node_all_launcher
node_all_launcher -->|"runs stages"| node_qc
node_stage_launcher -->|"selects stages"| node_qc
node_stage_launcher -->|"selects stages"| node_ld
node_stage_launcher -->|"selects stages"| node_pca
node_stage_launcher -->|"selects stages"| node_admixture
node_stage_launcher -->|"selects stages"| node_fst
node_stage_launcher -->|"selects stages"| node_fst_bootstrap
node_stage_launcher -->|"selects stages"| node_treemix
node_qc -->|"feeds next stage"| node_ld
node_ld -->|"feeds next stage"| node_pca
node_pca -->|"feeds next stage"| node_admixture
node_admixture -->|"feeds next stage"| node_fst
node_admixture -.->|"summarizes runs"| node_admixture_summary
node_metadata_input -->|"validates groups"| node_metadata_layer
node_fst_bootstrap -->|"matches samples"| node_metadata_layer
node_fst_bootstrap -->|"loads chromosome map"| node_chromosome_layer
node_treemix -.->|"prepares populations"| node_treemix_mapping
node_treemix_mapping -->|"loads metadata"| node_metadata_layer
node_treemix_mapping -->|"loads chromosome map"| node_chromosome_layer
node_treemix -.->|"converts frequencies"| node_treemix_conversion
node_treemix -->|"summarizes replicates"| node_treemix_summary
node_fst_bootstrap -.->|"supports visualization"| node_fst_plot
node_treemix_summary -->|"plots summaries"| node_treemix_plot
node_qc -->|"uses executables"| node_tools
node_ld -->|"uses PLINK"| node_tools
node_admixture -->|"uses ADMIXTURE"| node_tools
node_treemix -->|"uses TreeMix"| node_tools

click node_all_launcher "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/run_all.sh"
click node_stage_launcher "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/run_pipeline.sh"
click node_qc "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/qc.sh"
click node_ld "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/ld.sh"
click node_pca "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/pca.sh"
click node_admixture "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/admixture.sh"
click node_admixture_summary "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/admixture_summary.py"
click node_fst "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/fst.sh"
click node_fst_bootstrap "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/fst_analysis.py"
click node_treemix "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/run_treemix.sh"
click node_treemix_mapping "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/treemix_map.py"
click node_treemix_conversion "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/treemix_convert.py"
click node_treemix_summary "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/treemix_summary.py"
click node_fst_plot "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/r/plot_fst.R"
click node_treemix_plot "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/r/plot_treemix.R"
click node_metadata_layer "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/metadata.py"
click node_chromosome_layer "https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/remap_bim.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_all_launcher,node_stage_launcher toneBlue
class node_qc,node_ld,node_pca toneAmber
class node_admixture,node_fst,node_fst_bootstrap,node_treemix toneMint
class node_admixture_summary,node_treemix_summary,node_fst_plot,node_treemix_plot toneRose
class node_treemix_mapping,node_treemix_conversion,node_metadata_layer,node_chromosome_layer,node_researcher,node_vcf,node_metadata_input,node_tools toneIndigo
```

## Components

### Workflow entry

- [All-stage launcher](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/run_all.sh): `run_all.sh`
- [Stage-select launcher](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/run_pipeline.sh): `run_pipeline.sh`

### Genotype analyses

- [SNP QC](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/qc.sh): `shell/qc.sh`
- [LD pruning](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/ld.sh): `shell/ld.sh`
- [PCA](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/pca.sh): `shell/pca.sh`

### Population analyses

- [Replicated ADMIXTURE](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/admixture.sh): `shell/admixture.sh`
- [Windowed pairwise FST](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/shell/fst.sh): `shell/fst.sh`
- [FST block bootstrap](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/fst_analysis.py): `python/fst_analysis.py`
- [Replicated TreeMix](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/run_treemix.sh): `run_treemix.sh`

### Summaries and plots

- [ADMIXTURE summaries](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/admixture_summary.py): `python/admixture_summary.py`
- [TreeMix summaries](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/treemix_summary.py): `python/treemix_summary.py`
- [FST and NJ plots](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/r/plot_fst.R): `r/plot_fst.R`
- [TreeMix plots](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/r/plot_treemix.R): `r/plot_treemix.R`

### Shared analysis layers

- [TreeMix population mapping](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/treemix_map.py): `python/treemix_map.py`
- [TreeMix input conversion](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/treemix_convert.py): `python/treemix_convert.py`
- [Metadata validation](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/metadata.py): `python/metadata.py`
- [Chromosome remapping](https://github.com/rinaldi-rpy/downstream_bioinformatic/blob/main/python/remap_bim.py): `python/remap_bim.py`

### Other components

- **Researcher**
- **Merged VCF**
- **Sample metadata**
- **Analysis executables**

## Connections

- Researcher → All-stage launcher: starts workflow (evidence: `README.md`)
- Researcher → Stage-select launcher: selects stages (evidence: `README.md`)
- Merged VCF → All-stage launcher: supplies input (evidence: `README.md`)
- Sample metadata → All-stage launcher: supplies metadata (evidence: `README.md`)
- All-stage launcher → SNP QC: runs stages (evidence: `README.md`)
- Stage-select launcher → SNP QC: selects stages (evidence: `README.md`)
- Stage-select launcher → LD pruning: selects stages (evidence: `README.md`)
- Stage-select launcher → PCA: selects stages (evidence: `README.md`)
- Stage-select launcher → Replicated ADMIXTURE: selects stages (evidence: `README.md`)
- Stage-select launcher → Windowed pairwise FST: selects stages (evidence: `README.md`)
- Stage-select launcher → FST block bootstrap: selects stages (evidence: `README.md`)
- Stage-select launcher → Replicated TreeMix: selects stages (evidence: `README.md`)
- SNP QC → LD pruning: feeds next stage (evidence: `README.md`)
- LD pruning → PCA: feeds next stage (evidence: `README.md`)
- PCA → Replicated ADMIXTURE: feeds next stage (evidence: `README.md`)
- Replicated ADMIXTURE → Windowed pairwise FST: feeds next stage (evidence: `README.md`)
- Replicated ADMIXTURE → ADMIXTURE summaries: summarizes runs
- Sample metadata → Metadata validation: validates groups (evidence: `python/metadata.py`)
- FST block bootstrap → Metadata validation: matches samples (evidence: `python/fst_analysis.py`)
- FST block bootstrap → Chromosome remapping: loads chromosome map (evidence: `python/fst_analysis.py`)
- Replicated TreeMix → TreeMix population mapping: prepares populations
- TreeMix population mapping → Metadata validation: loads metadata (evidence: `python/treemix_map.py`)
- TreeMix population mapping → Chromosome remapping: loads chromosome map (evidence: `python/treemix_map.py`)
- Replicated TreeMix → TreeMix input conversion: converts frequencies
- Replicated TreeMix → TreeMix summaries: summarizes replicates (evidence: `README.md`)
- FST block bootstrap → FST and NJ plots: supports visualization
- TreeMix summaries → TreeMix plots: plots summaries (evidence: `README.md`)
- SNP QC → Analysis executables: uses executables (evidence: `README.md`)
- LD pruning → Analysis executables: uses PLINK (evidence: `README.md`)
- Replicated ADMIXTURE → Analysis executables: uses ADMIXTURE (evidence: `README.md`)
- Replicated TreeMix → Analysis executables: uses TreeMix (evidence: `README.md`)
