# genepi/nf-gwas architecture

> Architecture diagram of the GitHub repository genepi/nf-gwas, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/genepi/nf-gwas
- Repository: https://github.com/genepi/nf-gwas

## Overview

##### Main Components Identification

The system should be represented as a pipeline with the following major components:

a) Input Processing Layer
- Input validation modules
- Data preprocessing components
- File format conversion utilities

b) Core Analysis Layer
- REGENIE analysis components (Step 1 and Step 2)
- Gene-based testing modules
- Single variant testing modules
- Interaction testing components

c) Post-processing Layer
- Results annotation
- Filtering mechanisms
- Liftover functionality
- Results merging

d) Reporting Layer
- Interactive visualization components
- Statistical reporting
- Web-based result navigation

**Input Data → Preprocessing → Core Analysis → Post-processing → Reporting**

##### Specific Components

a) Input Section:
- Input file types (VCF, BGEN, PLINK)
- Phenotype and covariate validation
- Quality control workflows

b) Processing Section:
- Chunking workflow
- Pruning workflow
- Quality control workflow

c) Analysis Section:
- REGENIE Step 1 (prediction model)
- REGENIE Step 2 (association testing)
- Gene-based testing
- Single variant testing

d) Post-processing Section:
- Results annotation
- Filtering
- Liftover
- Results merging

e) Reporting Section:
- Manhattan plot generation
- Statistical summaries
- Interactive web reports

##### Important Connections

- Parallel processing capabilities
- Data transformation points
- Where results are merged or split

##### Technical Details

- Nextflow workflow engine integration
- Container support (Docker/Singularity)
- Resource management connections
- File system interactions

##### Additional Elements

- Version information
- Configuration points
- Where logging occurs

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Input Processing Layer
    subgraph Input
        InputFiles[("Input Files")]
        PhenoVal["Phenotype Validation"]
        CovVal["Covariate Validation"]
        FormatConv["Format Conversion"]
    end

    %% Core Processing Layer
    subgraph Processing
        QC["Quality Control"]
        Pruning["Pruning"]
        Chunking["Chunking"]
    end

    %% Analysis Layer
    subgraph Analysis
        RegPipe["REGENIE Pipeline"]
        Reg1["REGENIE Step 1"]
        Reg2["REGENIE Step 2"]
        GeneTest["Gene-based Testing"]
        SVTest["Single Variant Testing"]
    end

    %% Post-processing Layer
    subgraph PostProcess
        Annot["Results Annotation"]
        Filter["Filtering"]
        Lift["Liftover"]
        Merge["Results Merging"]
    end

    %% Reporting Layer
    subgraph Reporting
        MainReport["Main Report"]
        GeneReport["Gene-based Report"]
        InteractReport["Interaction Report"]
    end

    %% Connections
    InputFiles --> PhenoVal & CovVal
    PhenoVal & CovVal --> FormatConv
    FormatConv --> QC
    QC --> Pruning
    Pruning --> Chunking
    Chunking --> RegPipe
    RegPipe --> Reg1
    Reg1 --> Reg2
    Reg2 --> GeneTest & SVTest
    GeneTest & SVTest --> Annot
    Annot --> Filter
    Filter --> Lift
    Lift --> Merge
    Merge --> MainReport & GeneReport & InteractReport

    %% Click Events
    click PhenoVal "https://github.com/genepi/nf-gwas/blob/main/modules/local/input_validation/validate_phenotypes.nf"
    click CovVal "https://github.com/genepi/nf-gwas/blob/main/modules/local/input_validation/validate_covariates.nf"
    click FormatConv "https://github.com/genepi/nf-gwas/blob/main/modules/local/imputed_to_plink2.nf"
    click QC "https://github.com/genepi/nf-gwas/blob/main/modules/local/qc_filter_genotyped.nf"
    click Pruning "https://github.com/genepi/nf-gwas/blob/main/modules/local/prune_genotyped.nf"
    click RegPipe "https://github.com/genepi/nf-gwas/blob/main/workflows/regenie/regenie.nf"
    click Reg1 "https://github.com/genepi/nf-gwas/blob/main/workflows/regenie/regenie_step1.nf"
    click Reg2 "https://github.com/genepi/nf-gwas/blob/main/workflows/regenie/regenie_step2.nf"
    click GeneTest "https://github.com/genepi/nf-gwas/blob/main/workflows/gene_based_tests.nf"
    click SVTest "https://github.com/genepi/nf-gwas/blob/main/workflows/single_variant_tests.nf"
    click Annot "https://github.com/genepi/nf-gwas/blob/main/modules/local/annotation/annotate_results.nf"
    click Filter "https://github.com/genepi/nf-gwas/blob/main/modules/local/filter_results.nf"
    click Lift "https://github.com/genepi/nf-gwas/blob/main/modules/local/liftover_results.nf"
    click Merge "https://github.com/genepi/nf-gwas/blob/main/modules/local/merge_results.nf"
    click MainReport "https://github.com/genepi/nf-gwas/blob/main/modules/local/reporting/report.nf"
    click GeneReport "https://github.com/genepi/nf-gwas/blob/main/modules/local/reporting/report_gene_based_tests.nf"

    %% Styling
    classDef input fill:#AEC6CF
    classDef processing fill:#98FB98
    classDef analysis fill:#FFE5B4
    classDef postprocess fill:#DDA0DD
    classDef reporting fill:#F0E68C

    class InputFiles,PhenoVal,CovVal,FormatConv input
    class QC,Pruning,Chunking processing
    class RegPipe,Reg1,Reg2,GeneTest,SVTest analysis
    class Annot,Filter,Lift,Merge postprocess
    class MainReport,GeneReport,InteractReport reporting
```
