# rgcgithub/regenie architecture

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

- Interactive diagram: https://gitdiagram.com/rgcgithub/regenie
- Repository: https://github.com/rgcgithub/regenie

## Overview

regenie is a C++ whole-genome regression tool for GWAS. Users supply genetic and phenotype data and request association analyses; the product supports quantitative, binary, and time-to-event traits, relatedness adjustment, multiple phenotypes, variant and region tests, interactions, and conditional analyses. The source index identifies Data.cpp as a central coordinator and shows its references to the analysis modules, while the README documents the two-step modeling capability. Several implementation paths were not sampled, so uncertain runtime calls are shown as unverified rather than asserted.

Main entry points: [`src/Data.cpp`](https://github.com/rgcgithub/regenie/blob/master/src/Data.cpp) (Analysis coordinator), [`src/Geno.cpp`](https://github.com/rgcgithub/regenie/blob/master/src/Geno.cpp) (Genotype input), [`src/Regenie.cpp`](https://github.com/rgcgithub/regenie/blob/master/src/Regenie.cpp) (Program options), [`src/Step2_Models.hpp`](https://github.com/rgcgithub/regenie/blob/master/src/Step2_Models.hpp) (Step 2 models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Analysis workflow"]
  node_coordinator["Analysis coordinator<br/>[Data.cpp]"]
  node_entry["Program options<br/>[Regenie.cpp]"]
end

subgraph group_inputs["Analysis inputs"]
  node_files["File handling<br/>[Files.cpp]"]
  node_genotypes["Genotype input<br/>[Geno.cpp]"]
  node_pgen["PGEN reader<br/>[pgenlib_read.cc]"]
  node_phenotypes["Phenotype input<br/>[Pheno.cpp]"]
end

subgraph group_models["Regression models"]
  node_step1["Step 1 models<br/>[Step1_Models.hpp]"]
  node_step2["Step 2 models<br/>[Step2_Models.hpp]"]
  node_ordinal["Ordinal traits<br/>[Ordinal.cpp]"]
  node_survival["Survival models<br/>[survival_data.cpp]"]
  node_cox["Cox regression<br/>[cox_score.cpp]"]
end

subgraph group_tests["Association tests"]
  node_single["Single-variant tests<br/>[Step2_Models.hpp]"]
  node_regions["Region tests<br/>[SKAT.cpp]"]
  node_masks["Variant masks<br/>[Masks.cpp]"]
  node_interactions["Interaction tests<br/>[Interaction.cpp]"]
  node_joint["Joint tests<br/>[Joint_Tests.cpp]"]
  node_multitrait["Multi-trait tests"]
end

subgraph group_engines["Numerical engines"]
  node_optimizer["L-BFGS optimizer<br/>[BFGSMat.h]"]
  node_optimizer_params["Optimizer parameters<br/>[Param.h]"]
  node_quadratic["Quadratic-form engine<br/>[qfc.cpp]"]
  node_ld_writer["LD matrix output"]
  node_ld_writer_api["LD writer API"]
  node_simd["SIMD math<br/>[avx2.h]"]
  node_eigen_lapack["Eigen LAPACK support<br/>[lapacke.h]"]
end

node_user(("GWAS analyst"))

node_user -->|"sets options"| node_entry
node_entry -.->|"starts analysis"| node_coordinator
node_coordinator -.->|"uses genotype module"| node_genotypes
node_coordinator -.->|"uses phenotype module"| node_phenotypes
node_coordinator -.->|"uses file module"| node_files
node_coordinator -.->|"uses model module"| node_step1
node_coordinator -.->|"uses model module"| node_step2
node_coordinator -.->|"uses trait module"| node_ordinal
node_coordinator -.->|"uses survival module"| node_survival
node_genotypes -.->|"reads PGEN"| node_pgen
node_coordinator -.->|"uses test module"| node_joint
node_coordinator -.->|"uses test module"| node_multitrait
node_coordinator -.->|"uses test module"| node_regions
node_coordinator -.->|"uses test module"| node_interactions
node_coordinator -.->|"uses mask module"| node_masks
node_step2 -.->|"implements tests"| node_single
node_survival -.->|"uses Cox code"| node_cox
node_optimizer -->|"uses parameters"| node_optimizer_params
node_ld_writer -->|"implements API"| node_ld_writer_api
node_genotypes -.->|"uses SIMD routines"| node_simd

click node_coordinator "https://github.com/rgcgithub/regenie/blob/master/src/Data.cpp"
click node_entry "https://github.com/rgcgithub/regenie/blob/master/src/Regenie.cpp"
click node_files "https://github.com/rgcgithub/regenie/blob/master/src/Files.cpp"
click node_genotypes "https://github.com/rgcgithub/regenie/blob/master/src/Geno.cpp"
click node_pgen "https://github.com/rgcgithub/regenie/blob/master/external_libs/pgenlib/include/pgenlib_read.cc"
click node_phenotypes "https://github.com/rgcgithub/regenie/blob/master/src/Pheno.cpp"
click node_step1 "https://github.com/rgcgithub/regenie/blob/master/src/Step1_Models.hpp"
click node_step2 "https://github.com/rgcgithub/regenie/blob/master/src/Step2_Models.hpp"
click node_ordinal "https://github.com/rgcgithub/regenie/blob/master/src/Ordinal.cpp"
click node_survival "https://github.com/rgcgithub/regenie/blob/master/src/survival_data.cpp"
click node_cox "https://github.com/rgcgithub/regenie/blob/master/src/cox_score.cpp"
click node_single "https://github.com/rgcgithub/regenie/blob/master/src/Step2_Models.hpp"
click node_regions "https://github.com/rgcgithub/regenie/blob/master/src/SKAT.cpp"
click node_masks "https://github.com/rgcgithub/regenie/blob/master/src/Masks.cpp"
click node_interactions "https://github.com/rgcgithub/regenie/blob/master/src/Interaction.cpp"
click node_joint "https://github.com/rgcgithub/regenie/blob/master/src/Joint_Tests.cpp"
click node_multitrait "https://github.com/rgcgithub/regenie/blob/master/src/MultiTrait_Tests.cpp"
click node_optimizer "https://github.com/rgcgithub/regenie/blob/master/external_libs/LBFGSpp/include/LBFGSpp/BFGSMat.h"
click node_optimizer_params "https://github.com/rgcgithub/regenie/blob/master/external_libs/LBFGSpp/include/LBFGSpp/Param.h"
click node_quadratic "https://github.com/rgcgithub/regenie/blob/master/external_libs/qf/qfc.cpp"
click node_ld_writer "https://github.com/rgcgithub/regenie/blob/master/external_libs/remeta/regenie_ld_matrix_writer.cpp"
click node_ld_writer_api "https://github.com/rgcgithub/regenie/blob/master/external_libs/remeta/regenie_ld_matrix_writer.hpp"
click node_simd "https://github.com/rgcgithub/regenie/blob/master/external_libs/pgenlib/simde/x86/avx2.h"
click node_eigen_lapack "https://github.com/rgcgithub/regenie/blob/master/external_libs/eigen-3.4.0/Eigen/src/misc/lapacke.h"

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_coordinator,node_entry toneBlue
class node_files,node_genotypes,node_pgen,node_phenotypes toneAmber
class node_step1,node_step2,node_ordinal,node_survival,node_cox toneMint
class node_single,node_regions,node_masks,node_interactions,node_joint,node_multitrait toneRose
class node_optimizer,node_optimizer_params,node_quadratic,node_ld_writer,node_ld_writer_api,node_simd,node_eigen_lapack,node_user toneIndigo
```

## Components

### Analysis workflow

- [Analysis coordinator](https://github.com/rgcgithub/regenie/blob/master/src/Data.cpp): `src/Data.cpp`
- [Program options](https://github.com/rgcgithub/regenie/blob/master/src/Regenie.cpp): `src/Regenie.cpp`

### Analysis inputs

- [File handling](https://github.com/rgcgithub/regenie/blob/master/src/Files.cpp): `src/Files.cpp`
- [Genotype input](https://github.com/rgcgithub/regenie/blob/master/src/Geno.cpp): `src/Geno.cpp`
- [PGEN reader](https://github.com/rgcgithub/regenie/blob/master/external_libs/pgenlib/include/pgenlib_read.cc): `external_libs/pgenlib/include/pgenlib_read.cc`
- [Phenotype input](https://github.com/rgcgithub/regenie/blob/master/src/Pheno.cpp): `src/Pheno.cpp`

### Regression models

- [Step 1 models](https://github.com/rgcgithub/regenie/blob/master/src/Step1_Models.hpp): `src/Step1_Models.hpp`
- [Step 2 models](https://github.com/rgcgithub/regenie/blob/master/src/Step2_Models.hpp): `src/Step2_Models.hpp`
- [Ordinal traits](https://github.com/rgcgithub/regenie/blob/master/src/Ordinal.cpp): `src/Ordinal.cpp`
- [Survival models](https://github.com/rgcgithub/regenie/blob/master/src/survival_data.cpp): `src/survival_data.cpp`
- [Cox regression](https://github.com/rgcgithub/regenie/blob/master/src/cox_score.cpp): `src/cox_score.cpp`

### Association tests

- [Single-variant tests](https://github.com/rgcgithub/regenie/blob/master/src/Step2_Models.hpp): `src/Step2_Models.hpp`
- [Region tests](https://github.com/rgcgithub/regenie/blob/master/src/SKAT.cpp): `src/SKAT.cpp`
- [Variant masks](https://github.com/rgcgithub/regenie/blob/master/src/Masks.cpp): `src/Masks.cpp`
- [Interaction tests](https://github.com/rgcgithub/regenie/blob/master/src/Interaction.cpp): `src/Interaction.cpp`
- [Joint tests](https://github.com/rgcgithub/regenie/blob/master/src/Joint_Tests.cpp): `src/Joint_Tests.cpp`
- [Multi-trait tests](https://github.com/rgcgithub/regenie/blob/master/src/MultiTrait_Tests.cpp): `src/MultiTrait_Tests.cpp`

### Numerical engines

- [L-BFGS optimizer](https://github.com/rgcgithub/regenie/blob/master/external_libs/LBFGSpp/include/LBFGSpp/BFGSMat.h): `external_libs/LBFGSpp/include/LBFGSpp/BFGSMat.h`
- [Optimizer parameters](https://github.com/rgcgithub/regenie/blob/master/external_libs/LBFGSpp/include/LBFGSpp/Param.h): `external_libs/LBFGSpp/include/LBFGSpp/Param.h`
- [Quadratic-form engine](https://github.com/rgcgithub/regenie/blob/master/external_libs/qf/qfc.cpp): `external_libs/qf/qfc.cpp`
- [LD matrix output](https://github.com/rgcgithub/regenie/blob/master/external_libs/remeta/regenie_ld_matrix_writer.cpp): `external_libs/remeta/regenie_ld_matrix_writer.cpp`
- [LD writer API](https://github.com/rgcgithub/regenie/blob/master/external_libs/remeta/regenie_ld_matrix_writer.hpp): `external_libs/remeta/regenie_ld_matrix_writer.hpp`
- [SIMD math](https://github.com/rgcgithub/regenie/blob/master/external_libs/pgenlib/simde/x86/avx2.h): `external_libs/pgenlib/simde/x86/avx2.h`
- [Eigen LAPACK support](https://github.com/rgcgithub/regenie/blob/master/external_libs/eigen-3.4.0/Eigen/src/misc/lapacke.h): `external_libs/eigen-3.4.0/Eigen/src/misc/lapacke.h`

### Other components

- **GWAS analyst**

## Connections

- GWAS analyst → Program options: sets options
- Program options → Analysis coordinator: starts analysis
- Analysis coordinator → Genotype input: uses genotype module (evidence: `src/Data.cpp`)
- Analysis coordinator → Phenotype input: uses phenotype module (evidence: `src/Data.cpp`)
- Analysis coordinator → File handling: uses file module (evidence: `src/Data.cpp`)
- Analysis coordinator → Step 1 models: uses model module (evidence: `src/Data.cpp`)
- Analysis coordinator → Step 2 models: uses model module (evidence: `src/Data.cpp`)
- Analysis coordinator → Ordinal traits: uses trait module (evidence: `src/Data.cpp`)
- Analysis coordinator → Survival models: uses survival module (evidence: `src/Data.cpp`)
- Genotype input → PGEN reader: reads PGEN
- Analysis coordinator → Joint tests: uses test module (evidence: `src/Data.cpp`)
- Analysis coordinator → Multi-trait tests: uses test module (evidence: `src/Data.cpp`)
- Analysis coordinator → Region tests: uses test module (evidence: `src/Data.cpp`)
- Analysis coordinator → Interaction tests: uses test module (evidence: `src/Data.cpp`)
- Analysis coordinator → Variant masks: uses mask module (evidence: `src/Data.cpp`)
- Step 2 models → Single-variant tests: implements tests
- Survival models → Cox regression: uses Cox code
- L-BFGS optimizer → Optimizer parameters: uses parameters (evidence: `external_libs/LBFGSpp/include/LBFGSB.h`)
- LD matrix output → LD writer API: implements API (evidence: `external_libs/remeta/regenie_ld_matrix_writer.cpp`)
- Genotype input → SIMD math: uses SIMD routines
