# gauravj49/nfatacseq architecture

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

- Interactive diagram: https://gitdiagram.com/gauravj49/nfatacseq
- Repository: https://github.com/gauravj49/nfatacseq

## Overview

##### Project Type and Purpose
- The pipeline is designed for processing ATAC-seq data, handling everything from raw read quality control to differential accessibility analysis.
- It automates several sequential bioinformatics tasks (e.g., FastQC, adapter trimming, alignment with BWA, duplicate marking with Picard, filtering with SAMtools/BEDTools, peak calling with MACS2, and downstream analysis using R/DESeq2) and utilizes containerization (Docker/Singularity) for reproducibility.
- The design also has an integration point for external resources like reference genome configurations and visualizations (IGV sessions, MultiQC reports).

##### File Structure Analysis
- Key directories include:
- “docs” for documentation, images, and usage details.
- “assets” which contains JSON config files, templates (email, MultiQC headers), and blacklists used during filtering.
- “bin” and “scripts” directories holding various custom scripts and tools that perform specific tasks during the pipeline’s execution.
- “conf” which holds configuration files for different environments (base, test, etc.).
- Main pipeline orchestration files “main.nf” and “nextflow.config” that establish how Nextflow manages the tasks.
- The presence of GitHub workflows (.github/workflows) and Dockerfile indicate continuous integration, testing, and containerized execution.

##### Architectural Elements
a. Main Components:
- Nextflow Workflow Engine: Acts as the central coordinator that triggers each component/module in the correct order.
- Input Data: Raw FASTQ files (not directly shown in the file tree, but implied by the “design.csv” input file in the README and typical pipeline use-case).
- Pipeline Stages/Modules:
⁃ Quality Control: FastQC for raw read QC.
⁃ Preprocessing: Adapter trimming using Trim Galore!
⁃ Alignment: BWA alignment.
⁃ Post-Alignment Processing: Duplicate marking (Picard), merging libraries, re-marking, and filtering of reads (using SAMtools, BEDTools, BAMTools, and Pysam).
⁃ QC and Reporting: Generation of bigWig files (BEDTools, bedGraphToBigWig), MultiQC reports, and ATAC-seq-specific QC (ataqv).
⁃ Peak Calling and Annotation: MACS2 for peak calling, HOMER for peak annotation, and generation of consensus peak sets.
⁃ Downstream Analysis: Differential accessibility analysis using R/DESeq2, PCA, and clustering.
⁃ Visualization: IGV session file creation and generation of additional plots and meta-profiles using deepTools and R scripts.
- External Tools & Containers: Docker/Singularity images ensure reproducibility and encapsulate the external software dependencies.
- Configuration Management: "conf" and "nextflow.config" files for setting the pipeline’s running parameters across different environments.

b. Relationships and Interactions:
- There should be visible integration between individual scripts (located in “bin” and “scripts”) and the modular tasks defined within the Nextflow workflow.
- Configuration management, where the Nextflow engine reads different configuration files (base.config, test.config, etc.) to adjust parameters for various environments.

c. Architectural Patterns & Design Principles:
- Modular Pipeline: Each bioinformatics step is encapsulated as a module/task that can be independently executed and tested.
- Reproducibility: Use of Docker/Singularity containers is central to ensuring that each task is executed in the same environment regardless of the underlying infrastructure.
- Scalability and Portability: The use of Nextflow facilitates distributed computation, enabling the pipeline to run on various compute platforms (local machine, cloud, or HPC).

d. Technologies / Frameworks:
- Nextflow for workflow orchestration.
- Docker/Singularity for containerization.
- Programming/Scripting Tools: Python, R (and associated bioinformatics packages like DESeq2), Bash scripts, and workflow-specific utilities.
- External bioinformatics tools: FastQC, Trim Galore!, BWA, Picard, SAMtools, BEDTools, MACS2, HOMER, deepTools, and IGV.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Configuration & Orchestration
    subgraph "Configuration & Orchestration"
        NF("Nextflow Workflow Engine"):::engine
        CONFIG("Configuration Files"):::config
        NF -->|"reads"| CONFIG
    end

    %% Input Data and Documentation
    Input("Input Data (FASTQ/design.csv)"):::data
    DOC("Documentation & Usage"):::doc
    Input -->|"triggers"| NF
    Input --> DOC

    %% Pipeline Modules
    subgraph "Pipeline Modules"
        QC("Quality Control (FastQC)"):::module
        PRE("Preprocessing (Adapter Trimming)"):::module
        ALIGN("Alignment (BWA)"):::module
        POST("Post-Alignment Processing (Picard, SAMtools, BEDTools)"):::module
        PEAK("Peak Calling & Annotation (MACS2, HOMER)"):::module
        ANALYSIS("Differential Analysis (DESeq2, R)"):::module
        VIS("Visualization (IGV, deepTools)"):::module

        QC --> PRE
        PRE --> ALIGN
        ALIGN --> POST
        POST --> PEAK
        PEAK --> ANALYSIS
        ANALYSIS --> VIS
    end

    %% Custom Scripts & Tools
    subgraph "Custom Scripts & Tools"
        QC_SCRIPT("QC & Preprocessing Scripts"):::script
        PEAK_SCRIPT("Peak Calling Script"):::script
        DUP_SCRIPT("Duplicate/Filtering Scripts"):::script
        IGV_SCRIPT("IGV Session Generation Script"):::script
        DIFF_ANALYSIS("Differential Analysis Scripts"):::script
        ADD_ANALYSIS("Additional Analysis & Visualization Scripts"):::script
        USAGE_BACKUP("Usage & Backup Scripts"):::script
    end

    %% Linking Modules to Corresponding Scripts
    QC ---|"script"| QC_SCRIPT
    POST ---|"script"| DUP_SCRIPT
    PEAK ---|"script"| PEAK_SCRIPT
    VIS ---|"script"| IGV_SCRIPT
    ANALYSIS ---|"script"| DIFF_ANALYSIS
    ANALYSIS ---|"script"| ADD_ANALYSIS

    %% QC Reporting Node
    REPORT("QC & Reporting (MultiQC, Email)"):::asset
    QC -->|"reports"| REPORT

    %% External Containerization & CI
    CONT("Containers (Docker/Singularity & CI)"):::container
    NF -->|"runs in"| CONT

    %% Reference Genome & Assets
    REF("Reference Genome & Assets"):::asset
    CONFIG -->|"includes"| REF

    %% Click Events
    click NF "https://github.com/gauravj49/nfatacseq/blob/master/main.nf"
    click NF "https://github.com/gauravj49/nfatacseq/blob/master/nextflow.config"
    click CONFIG "https://github.com/gauravj49/nfatacseq/tree/master/conf"
    click DOC "https://github.com/gauravj49/nfatacseq/tree/master/docs"
    click REF "https://github.com/gauravj49/nfatacseq/tree/master/conf"
    click REF "https://github.com/gauravj49/nfatacseq/blob/master/assets/design_pe.csv"
    click REF "https://github.com/gauravj49/nfatacseq/blob/master/assets/design_se.csv"
    click CONT "https://github.com/gauravj49/nfatacseq/tree/master/Dockerfile"
    click CONT "https://github.com/gauravj49/nfatacseq/tree/master/.github/workflows"
    click REPORT "https://github.com/gauravj49/nfatacseq/tree/master/assets/multiqc"
    click REPORT "https://github.com/gauravj49/nfatacseq/blob/master/assets/email_template.html"
    click REPORT "https://github.com/gauravj49/nfatacseq/blob/master/assets/email_template.txt"
    click QC_SCRIPT "https://github.com/gauravj49/nfatacseq/blob/master/bin/check_design.py"
    click QC_SCRIPT "https://github.com/gauravj49/nfatacseq/blob/master/scripts/usage/01_pipeline_run_usage.sh"
    click PEAK_SCRIPT "https://github.com/gauravj49/nfatacseq/blob/master/bin/macs2_merged_expand.py"
    click DUP_SCRIPT "https://github.com/gauravj49/nfatacseq/blob/master/bin/bampe_rm_orphan.py"
    click DUP_SCRIPT "https://github.com/gauravj49/nfatacseq/blob/master/bin/get_autosomes.py"
    click DUP_SCRIPT "https://github.com/gauravj49/nfatacseq/tree/master/bin/gtf2bed"
    click IGV_SCRIPT "https://github.com/gauravj49/nfatacseq/blob/master/bin/igv_files_to_session.py"
    click DIFF_ANALYSIS "https://github.com/gauravj49/nfatacseq/blob/master/bin/featurecounts_deseq2.r"
    click DIFF_ANALYSIS "https://github.com/gauravj49/nfatacseq/blob/master/scripts/R_RUVseq_DESeq2_DAR_analysis.R"
    click ADD_ANALYSIS "https://github.com/gauravj49/nfatacseq/blob/master/bin/plot_peak_intersect.r"
    click ADD_ANALYSIS "https://github.com/gauravj49/nfatacseq/blob/master/bin/plot_macs_qc.r"
    click ADD_ANALYSIS "https://github.com/gauravj49/nfatacseq/blob/master/scripts/R_annotate_peaks_chipseeker.R"
    click ADD_ANALYSIS "https://github.com/gauravj49/nfatacseq/blob/master/scripts/R_get_DARs_deseq2.R"
    click USAGE_BACKUP "https://github.com/gauravj49/nfatacseq/tree/master/scripts/backup"
    click USAGE_BACKUP "https://github.com/gauravj49/nfatacseq/tree/master/scripts/usage"

    %% Styles
    classDef engine fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef config fill:#aed6f1,stroke:#333,stroke-width:2px;
    classDef data fill:#a9dfbf,stroke:#333,stroke-width:2px;
    classDef module fill:#d7bde2,stroke:#333,stroke-width:2px;
    classDef container fill:#f5cba7,stroke:#333,stroke-width:2px;
    classDef asset fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef script fill:#fadbd8,stroke:#333,stroke-width:2px;
    classDef doc fill:#f9e79f,stroke:#333,stroke-width:2px;
```
