# ritatalu/atacgraph architecture

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

- Interactive diagram: https://gitdiagram.com/ritatalu/atacgraph
- Repository: https://github.com/ritatalu/atacgraph

## Overview

##### Project Type and Purpose
- Type: A command-line bioinformatics pipeline (open-source tool), implemented in Python, wrapping standard genomics tools.
- Purpose: Automate end-to-end ATAC-Seq analysis in discrete modules (filtering, fragment stats, peak calling, differential analysis, plotting).

##### File Structure
- Top level
– script/ : all Python subcommands (00_rmChr.py, 01_calFragDist.py, …, extract_transcript_regions.py, GTF.py)
– Figures/ : output figures used in the README and final reports
– demo/, Tutorial.md, README.md, base.txt, LICENSE
- Pattern: Each numbered script corresponds to a pipeline stage (00 → 05).
- Config/deployment: base.txt installs tools; optional Docker image for Galaxy integration.

##### README for Insights
- Single entrypoint: “ATACgraph” CLI dispatches to subcommands.
- Dependencies: Python 2.7 for core, Python 3.5 for IDR, external tools (BEDtools, MACS2, deepTools, IDR).
- Data flow described in “ATACgraph modules” section.

##### Main Components and Interactions
a. Entrypoint
– “ATACgraph” wrapper script (argparse)
b. Module Scripts
– 00_rmChr → 01_calFragDist → 02_selectFragSize / 02_gtftoBed → 03_callPeak / 03_genePlot / 03_junctionBed → 04_specificPeaks / 04_specificPeaksIDR → 05_seqCompare / 05_compareToRNA
c. External Tools
– bedtools, MACS2, deepTools, idr command
d. Python Libraries
– numpy, pandas, matplotlib, pysam, pybedtools, scikit-learn, matplotlib-venn
e. Data Inputs/Outputs
– Inputs: BAM files, GTF files, peak BEDs, bigWig files, expression tables
– Outputs: filtered BAMs, BED tracks, bigWig coverage, figures (PDF/PNG), Venn/bar plots, matrix tables
f. Environment
– Local Linux/Mac OS or Docker/Galaxy container

##### Architectural Patterns and Design Principles
- Modular pipeline: each script follows single‐responsibility
- Data‐flow orchestration: file-based handoff between stages
- Wrapper pattern: Python code delegates heavy lifting to external tools
- Extensibility: add new numbered script in script/ and register subcommand

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI & Orchestration
    subgraph "CLI & Orchestration"
        ATACgraph["ATACgraph CLI"]:::python
    end

    %% Pipeline Stages
    subgraph "Pipeline Stages"
        rmChr["00_rmChr.py"]:::python
        calFrag["01_calFragDist.py"]:::python
        gtftoBed["02_gtftoBed.py"]:::python
        selectFrag["02_selectFragSize.py"]:::python
        callPeak["03_callPeak.py"]:::python
        genePlot["03_genePlot.py"]:::python
        junctionBed["03_junctionBed.py"]:::python
        specPeaks["04_specificPeaks.py"]:::python
        specIDR["04_specificPeaksIDR.py"]:::python
        specProm["04_specificPromoter.py"]:::python
        seqCompare["05_seqCompare.py"]:::python
        compareRNA["05_compareToRNA.py"]:::python
        GTFutil["GTF.py"]:::python
        extractTR["extract_transcript_regions.py"]:::python
    end

    %% External Tools & Libraries
    subgraph "External Tools & Libraries"
        bedtools["bedtools"]:::external
        MACS2["MACS2"]:::external
        deepTools["deepTools"]:::external
        idr["idr"]:::external
        libs["numpy,pandas,matplotlib,..."]:::external
    end

    %% Data & Config
    subgraph "Data & Config"
        rawIn["Raw Inputs (BAM, GTF, etc)"]:::datastore
        intermediate["Intermediate Files (BAM, BED, bigWig)"]:::datastore
        Figures["Figures/"]:::output
        demoData["demo/demo.tar.gz"]:::output
        baseTxt["base.txt"]:::datastore
        readme["README.md"]:::datastore
        tutorial["Tutorial.md"]:::datastore
        license["LICENSE"]:::datastore
    end

    %% Data Flows
    ATACgraph -->|dispatch| rmChr
    rmChr -->|BAM→BAM| calFrag
    calFrag -->|BAM→BAM| gtftoBed
    calFrag -->|BAM→BAM| selectFrag
    gtftoBed -->|GTF→BED| callPeak
    selectFrag -->|BAM→BAM| callPeak
    callPeak -->|BED→BED| genePlot
    callPeak -->|BED→BED| junctionBed
    genePlot -->|coverage→PDF/PNG| specPeaks
    junctionBed -->|BED→BED| specPeaks
    specPeaks -->|BED→BED| specProm
    specPeaks -->|BED→BED| specIDR
    specProm -->|BED→matrix| seqCompare
    specIDR -->|BED→matrix| seqCompare
    seqCompare -->|matrix→plots| compareRNA
    compareRNA -->|plots→Figures| Figures

    %% Intermediate to storage
    rmChr --> intermediate
    calFrag --> intermediate
    gtftoBed --> intermediate
    selectFrag --> intermediate
    callPeak --> intermediate

    %% Raw inputs
    rawIn --> rmChr
    rawIn --> gtftoBed

    %% Config & docs
    baseTxt --> ATACgraph
    readme --> ATACgraph
    tutorial --> ATACgraph
    license --> ATACgraph

    %% External tool invocations (dashed)
    callPeak -.->|uses| bedtools
    callPeak -.->|uses| MACS2
    genePlot -.->|uses| deepTools
    specIDR -.->|uses| idr
    rmChr -.->|libs| libs
    calFrag -.->|libs| libs
    gtftoBed -.->|libs| libs
    selectFrag -.->|libs| libs
    specProm -.->|libs| libs
    seqCompare -.->|libs| libs
    compareRNA -.->|libs| libs

    %% Helper modules usage
    gtftoBed -.->|imports| GTFutil
    specProm -.->|imports| extractTR

    %% Click Events
    click ATACgraph "https://github.com/ritatalu/atacgraph/tree/master/script/ATACgraph"
    click rmChr "https://github.com/ritatalu/atacgraph/blob/master/script/00_rmChr.py"
    click calFrag "https://github.com/ritatalu/atacgraph/blob/master/script/01_calFragDist.py"
    click gtftoBed "https://github.com/ritatalu/atacgraph/blob/master/script/02_gtftoBed.py"
    click selectFrag "https://github.com/ritatalu/atacgraph/blob/master/script/02_selectFragSize.py"
    click callPeak "https://github.com/ritatalu/atacgraph/blob/master/script/03_callPeak.py"
    click genePlot "https://github.com/ritatalu/atacgraph/blob/master/script/03_genePlot.py"
    click junctionBed "https://github.com/ritatalu/atacgraph/blob/master/script/03_junctionBed.py"
    click specPeaks "https://github.com/ritatalu/atacgraph/blob/master/script/04_specificPeaks.py"
    click specIDR "https://github.com/ritatalu/atacgraph/blob/master/script/04_specificPeaksIDR.py"
    click specProm "https://github.com/ritatalu/atacgraph/blob/master/script/04_specificPromoter.py"
    click seqCompare "https://github.com/ritatalu/atacgraph/blob/master/script/05_seqCompare.py"
    click compareRNA "https://github.com/ritatalu/atacgraph/blob/master/script/05_compareToRNA.py"
    click GTFutil "https://github.com/ritatalu/atacgraph/blob/master/script/GTF.py"
    click extractTR "https://github.com/ritatalu/atacgraph/blob/master/script/extract_transcript_regions.py"
    click Figures "https://github.com/ritatalu/atacgraph/tree/master/Figures/"
    click demoData "https://github.com/ritatalu/atacgraph/blob/master/demo/demo.tar.gz"
    click baseTxt "https://github.com/ritatalu/atacgraph/blob/master/base.txt"
    click readme "https://github.com/ritatalu/atacgraph/blob/master/README.md"
    click tutorial "https://github.com/ritatalu/atacgraph/blob/master/Tutorial.md"
    click license "https://github.com/ritatalu/atacgraph/tree/master/LICENSE"

    %% Styles
    classDef python fill:#c2f0c2,stroke:#333,stroke-width:1px
    classDef external fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef datastore fill:#e6e6e6,stroke:#333,stroke-width:1px
    classDef output fill:#ffe6cc,stroke:#333,stroke-width:1px
```
