# ebispot/gwas-sumstats-harmoniser architecture

> Architecture diagram of the GitHub repository ebispot/gwas-sumstats-harmoniser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ebispot/gwas-sumstats-harmoniser
- Repository: https://github.com/ebispot/gwas-sumstats-harmoniser

## Overview

##### Main Components

a) Input Layer:
- GWAS Summary Statistics Files (.tsv)
- Metadata Files (.yaml)
- Reference Data (VCF files, Ensembl variants)

b) Pipeline Infrastructure:
- Nextflow Workflow Engine
- Container/Environment Management (Docker/Singularity/Conda)

c) Processing Modules:
- Reference Preparation Module
- Harmonisation Module
- Quality Control Module
- File Management Module

**┌─ Input Layer ─┐    ┌─ Processing Layer ─┐    ┌─ Output Layer ─┐**
- GWAS Files  │ -> │ - Harmonisation    │ -> │ - Harmonised   │
- Meta YAML   │    │ - QC               │    │   Files        │
- References  │    │ - Mapping          │    └────────────────┘
- ┘    └──────────────────────┘

##### Key Workflow Elements to Highlight

a) Main Processing Pipeline:
**[Input Files] → [Mapping Variants] → [Orientation Detection] →**
**[RSID Resolution] → [Reference Strand Orientation] → [Output Files]**

b) Infrastructure Components:
- Container/environment management options
- Memory requirements (28GB allocation)
- Executor options (local/cluster)

##### Specific Implementation Details

**Main Workflow**
- Reference Preparation
- VCF Processing
- Quality Control
- Basic QC
- Strand Counts
- Harmonisation
- Variant Mapping
- Orientation Detection
- RSID Resolution

##### Resource Management

A separate section showing:
- Memory allocation (28GB requirement)
- Containerization options
- Execution environments

##### Configuration Management

Configuration hierarchy:
- Basic config
- Container config
- Reference config
- Executor config

Remember to indicate:
- Input/output formats
- Processing steps
- Resource requirements
- Configuration options
- Error handling paths

This will create a comprehensive yet clear representation of the GWAS Summary Statistics Harmonisation pipeline's architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input["Input Layer"]
        GWAS[("GWAS Summary<br/>Statistics (.tsv)")]
        META[("Metadata Files<br/>(.yaml)")]
        REF[("Reference Data<br/>(VCF, Ensembl)")]
    end

    subgraph Infrastructure["Infrastructure Layer"]
        NF["Nextflow Engine"]:::infra
        CONT["Container/Environment<br/>Management"]:::infra
        MEM["Memory Management<br/>(28GB)"]:::infra
    end

    subgraph Processing["Processing Layer"]
        direction TB
        subgraph RefPrep["Reference Preparation"]
            REFP["Reference Processing"]:::process
            REFC["Reference Checking"]:::process
        end

        subgraph Harm["Harmonisation"]
            VMAP["Variant Mapping"]:::process
            ODET["Orientation Detection"]:::process
            RSID["RSID Resolution"]:::process
        end

        subgraph QC["Quality Control"]
            BQC["Basic QC"]:::process
            STRAND["Strand Counts"]:::process
        end

        subgraph FileM["File Management"]
            FMAN["File Operations"]:::process
        end
    end

    subgraph Config["Configuration Layer"]
        BCONF["Basic Config"]:::config
        CCONF["Container Config"]:::config
        RCONF["Reference Config"]:::config
        ECONF["Executor Config"]:::config
    end

    subgraph Output["Output Layer"]
        HOUT[("Harmonised Files")]:::output
        QOUT[("QC Reports")]:::output
    end

    %% Connections
    GWAS --> REFP
    META --> REFP
    REF --> REFP
    REFP --> REFC
    REFC --> VMAP
    VMAP --> ODET
    ODET --> RSID
    RSID --> BQC
    BQC --> STRAND
    STRAND --> FMAN
    FMAN --> HOUT
    BQC --> QOUT

    %% Infrastructure connections
    NF -.-> Processing
    CONT -.-> Processing
    MEM -.-> Processing
    
    %% Config connections
    BCONF -.-> NF
    CCONF -.-> CONT
    RCONF -.-> RefPrep
    ECONF -.-> NF

    %% Click events
    click NF "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/main.nf"
    click REFP "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/subworkflows/local/prepare_reference.nf"
    click REFC "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/subworkflows/local/check_reference.nf"
    click BQC "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/subworkflows/local/quality_control.nf"
    click VMAP "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/subworkflows/local/main_harm.nf"
    click FMAN "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/subworkflows/local/move_files.nf"
    click BCONF "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/config/basic.config"
    click CCONF "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/config/container.config"
    click RCONF "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/config/reference.config"
    click ECONF "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/config/executor.config"
    click CONT "https://github.com/EBISPOT/gwas-sumstats-harmoniser/blob/master/environments/conda_environment.yml"

    %% Styling
    classDef process fill:#90EE90,stroke:#333,stroke-width:2px
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef config fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef output fill:#87CEEB,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        P1["Process"]:::process
        I1["Infrastructure"]:::infra
        C1["Configuration"]:::config
        O1["Data"]:::output
    end
```
