# gauravj49/bulkrnaseqde architecture

> Architecture diagram of the GitHub repository gauravj49/bulkrnaseqde, 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/bulkrnaseqde
- Repository: https://github.com/gauravj49/bulkrnaseqde

## Overview

##### Main Components
- Input Data & Annotations:
- “input” folder, highlighting its subdirectories, especially the “annotation” files (with bed files for hg, mm, and sacCer gene symbols).
- Wrapper/Control Scripts:
- Two main shell scripts (01_user_projectname_rnaseq_deseq2_wrapper.sh and 02_user_projectname_rnaseq_ohneOutliers_wrapper.sh) that initiate the pipeline.
- Pre-Processing & Data Normalization:
- Components for normalization (scripts/R_normalize_data.R) and unwanted variation removal.
- Differential Expression Analysis:
- DE analysis module (scripts/R_RUVseq_DESeq2_DEanalysis.R) which runs DESeq2 and integrates RUVseq.
- Post-Processing & Visualization:
- A module for heatmap generation (scripts/R_heatmap.R and scripts/draw_mirs_heatmap.py).
- Gene Annotation:
- Sorting & Logging:
- Additional processing steps like sorting count files (scripts/sort_counts_dir.sh) and generating diagnostic plots/logs as noted in the README.

##### Relationships and Data Flow
- Data normalization (R script) → unwanted variation removal and DE analysis (R_RUVseq_DESeq2_DEanalysis.R).
- Next, the pipeline splits into two branches: one that goes to statistical result post-processing (gene annotation with Python script) and one that goes to result visualization (heatmaps).

##### Architectural Patterns and Design Principles
- Modular Pipeline Architecture: The design clearly separates the functions (data normalization, differential expression analysis, annotation, and visualization) into individual, script-based modules.
- Script Orchestration: The wrapper Bash scripts tie everything together and manage the workflow, which is typical in computational pipelines.
- Reusability & Extensibility: Notice the separation between R and Python scripts, which can be updated individually as needed.
- Data Flow (Linear & Branching): Emphasize the sequential steps with branching for multiple outputs (heatmaps, annotated results, and diagnostic plots).

##### Key Technologies and Frameworks
- R: For normalization, DE analysis (DESeq2), heatmap drawing.
- Python: For adding gene annotations, additional heatmap drawing.
- Shell Scripts: For orchestrating the workflow.
- Cluster Environment: Execution is targeted for an HPCC cluster though the pipeline is adaptable.

## Diagram (Mermaid)

```mermaid
flowchart TD
    E("Execution Environment: HPCC Cluster/Local"):::environment
    I("Input Data (Annotations, BED Files)"):::input
    W1("Wrapper Script: 01_user_projectname_rnaseq_deseq2_wrapper.sh"):::bash
    W2("Wrapper Script: 02_user_projectname_rnaseq_ohneOutliers_wrapper.sh"):::bash
    N("Normalization (R)"):::r
    S("Sorting & Logging"):::sorting
    D("Differential Expression (DESeq2+RUVseq)"):::r
    VR("Heatmap Generation (R)"):::visualization
    VP("Heatmap Generation (Python)"):::visualization
    G("Gene Annotation (Python)"):::python

    E --> I
    I --> W1
    I --> W2
    W1 --> N
    W2 --> N
    N --> S
    S --> D
    D --> VR
    D --> VP
    D --> G

    click I "https://github.com/gauravj49/bulkrnaseqde/tree/master/input/annotation/bed"
    click W1 "https://github.com/gauravj49/bulkrnaseqde/blob/master/01_user_projectname_rnaseq_deseq2_wrapper.sh"
    click W2 "https://github.com/gauravj49/bulkrnaseqde/blob/master/02_user_projectname_rnaseq_ohneOutliers_wrapper.sh"
    click N "https://github.com/gauravj49/bulkrnaseqde/blob/master/scripts/R_normalize_data.R"
    click S "https://github.com/gauravj49/bulkrnaseqde/blob/master/scripts/sort_counts_dir.sh"
    click D "https://github.com/gauravj49/bulkrnaseqde/blob/master/scripts/R_RUVseq_DESeq2_DEanalysis.R"
    click VR "https://github.com/gauravj49/bulkrnaseqde/blob/master/scripts/R_heatmap.R"
    click VP "https://github.com/gauravj49/bulkrnaseqde/blob/master/scripts/draw_mirs_heatmap.py"
    click G "https://github.com/gauravj49/bulkrnaseqde/blob/master/scripts/add_gene_annotation2deseq2_results.py"

    classDef environment fill:#f9f,stroke:#333,stroke-width:2px;
    classDef input fill:#bbf,stroke:#333,stroke-width:2px;
    classDef bash fill:#fbb,stroke:#333,stroke-width:2px;
    classDef r fill:#bfb,stroke:#333,stroke-width:2px;
    classDef sorting fill:#fbf,stroke:#333,stroke-width:2px;
    classDef visualization fill:#bff,stroke:#333,stroke-width:2px;
    classDef python fill:#ffb,stroke:#333,stroke-width:2px;
```
