# nf-core/rnaseq architecture

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

- Interactive diagram: https://gitdiagram.com/nf-core/rnaseq
- Repository: https://github.com/nf-core/rnaseq

## Overview

##### Main Components
- Input Data and Preprocessing:
– Show the Samplesheet and FASTQ files as the initial data inputs.
– Include preprocessing steps such as merging FASTQ files (using “cat”), quality control (e.g. FastQC), UMI extraction, adapter/quality trimming (Trim Galore!), and removal of contaminants.
- Alignment/Quantification Modules:
– Display a split into multiple quantification paths: for example, one branch using STAR alignment followed by Salmon quantification; an alternative STAR → RSEM path; and a branch for HISAT2 (which in this case does not perform quantification).
– Add nodes for tools like STAR, HISAT2, Salmon, and RSEM.
- Data Processing and Post-Alignment:
– Include nodes for alignment post-processing using tools such as SAMtools (for sorting and indexing), duplicate marking (Picard MarkDuplicates and UMI-tools deduplication), and transcript assembly (StringTie) as needed.
- Quality Control and Reporting:
– Represent the comprehensive QC components including tools like RSeQC, Qualimap, dupRadar, Preseq, and the final MultiQC aggregation.
- Configuration and Modular Setup:
– Illustrate the “main.nf” as the central Nextflow entry point.
– Indicate the “modules” and “subworkflows” directories which encapsulate individual functions (with local modules and nf-core modules distinguished).
– Show configuration (conf/* and nextflow.config) which govern pipeline behavior, profiles (docker, singularity, conda), and test environments.
- Deployment & Environment:
– Represent containerization options (Docker, Singularity) and the support for cloud environments (as indicated by the Seqera Platform and GitHub Actions workflows).

##### Relationships and Data Flow
- How alignment outputs flow into post-alignment processing (sorting, indexing, deduplication) and then into the QC modules.

##### Architectural Patterns or Design Principles
- Modular and Configurable: Emphasize that the system is built using modular Nextflow components (modules, subworkflows) which can be independently developed and tested.
- Pipeline-as-Code: Indicate the declarative nature (DSL2) where pipeline steps, dependencies, and parameters are defined in code.
- Containerization & Portability: Show that container images (Docker, Singularity) are part of the design to ensure reproducibility.
- Continuous Integration: Reference the presence of CI workflows (under .github/workflows) that automate linting, testing, and deployment.

##### Relevant Technologies and Frameworks
- Nextflow DSL2 (workflow orchestration)
- nf-core modules and community guidelines
- Container technologies: Docker, Singularity, Conda for dependency management
- Bioinformatics tools (FastQC, Trim Galore!, STAR, HISAT2, Salmon, RSEM, SAMtools, Picard, MultiQC, etc.)

##### Additional Details
- Structure emphasizes the modular, extensible nature of the pipeline, capturing each of the functional components described in the README and reflected in the file tree.
- Integration points for external dependencies and document tests and CI/CD as auxiliary infrastructure ensuring code quality.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Deployment Cluster
    subgraph "Configuration & Deployment"
        NF["Main Nextflow Entry"]:::config
        MOD["Modules"]:::config
        SUB["Subworkflows"]:::config
        CONF["Pipeline Configuration"]:::config
        CI["CI/CD Workflows"]:::config
        NFCORE["nf-core Metadata"]:::config
    end

    %% Input & Preprocessing Cluster
    subgraph "Input & Preprocessing"
        IN["Samplesheet & FASTQ Input"]:::input
        PS["Preprocessing Script"]:::input
        CAT["Data Concatenation (cat)"]:::input
        TG["Trim Galore!"]:::input
    end

    %% Alignment & Quantification Cluster
    subgraph "Alignment & Quantification"
        STAR["STAR Alignment"]:::alignment
        HISAT2["HISAT2 Alignment"]:::alignment
        SAL["Salmon Quantification"]:::alignment
        RSEM["RSEM Quantification"]:::alignment
    end

    %% Post-Processing Cluster
    subgraph "Post-Processing"
        SAM["SAMtools Processing"]:::process
        DUP["Duplicate Marking"]:::process
        ST["StringTie Assembly"]:::process
    end

    %% Quality Control & Reporting Cluster
    subgraph "Quality Control & Reporting"
        FQC["FastQC"]:::qc
        MQC["MultiQC Reporting"]:::qc
        OUTPUT["Final Outputs"]:::qc
    end

    %% Pipeline Flow Connections
    %% Start pipeline from Main Nextflow Entry to Input
    NF -->|"initiates"| IN

    %% Input & Preprocessing Flow
    IN -->|"processes"| PS
    PS -->|"merges data"| CAT
    CAT -->|"trims adapters"| TG

    %% Branching to Alignment & Quantification
    TG -->|"alignment choice"| STAR
    TG -->|"alignment choice"| HISAT2

    %% STAR branch splits into two quantification paths
    STAR -->|"quantifies"| SAL
    STAR -->|"quantifies"| RSEM

    %% Merge branches into Post-Processing
    SAL -->|"processed by"| SAM
    RSEM -->|"processed by"| SAM
    HISAT2 -->|"processed by"| SAM

    %% Continue Post-Processing
    SAM -->|"marks duplicates"| DUP
    DUP -->|"assembles transcripts"| ST

    %% Quality Control & Reporting Flow
    ST -->|"QC assessment"| FQC
    FQC -->|"aggregated by"| MQC
    MQC -->|"finalizes"| OUTPUT

    %% Define Styles
    classDef input fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef alignment fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef process fill:#A9DFBF,stroke:#145A32,stroke-width:2px;
    classDef qc fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef config fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef deployment fill:#FAD7A0,stroke:#D35400,stroke-width:2px;

    %% Click Events for Input & Preprocessing
    click IN "https://github.com/nf-core/rnaseq/blob/master/assets/samplesheet.csv"
    click PS "https://github.com/nf-core/rnaseq/blob/master/bin/fastq_dir_to_samplesheet.py"
    click CAT "https://github.com/nf-core/rnaseq/tree/master/modules/nf-core/cat/fastq"

    %% Click Events for Alignment & Quantification
    click STAR "https://github.com/nf-core/rnaseq/tree/master/modules/local/star_align_igenomes"
    click HISAT2 "https://github.com/nf-core/rnaseq/tree/master/modules/nf-core/hisat2/align"
    click SAL "https://github.com/nf-core/rnaseq/tree/master/modules/nf-core/salmon/quant"
    click RSEM "https://github.com/nf-core/rnaseq/tree/master/modules/local/rsem_merge_counts"

    %% Click Events for Post-Processing & QC
    click SAM "https://github.com/nf-core/rnaseq/tree/master/modules/nf-core/samtools/sort"
    click DUP "https://github.com/nf-core/rnaseq/tree/master/modules/nf-core/picard/markduplicates"
    click FQC "https://github.com/nf-core/rnaseq/tree/master/modules/nf-core/fastqc"
    click MQC "https://github.com/nf-core/rnaseq/tree/master/modules/local/multiqc_custom_biotype"

    %% Click Events for Configuration & Deployment
    click NF "https://github.com/nf-core/rnaseq/blob/master/main.nf"
    click CONF "https://github.com/nf-core/rnaseq/tree/master/conf"
    click CI "https://github.com/nf-core/rnaseq/tree/master/.github/workflows"
    click NFCORE "https://github.com/nf-core/rnaseq/blob/master/nf-core.yml"
    click MOD "https://github.com/nf-core/rnaseq/tree/master/modules"
    click SUB "https://github.com/nf-core/rnaseq/tree/master/subworkflows"
```
