# steffiroseck/rna-seqanalysispipeline architecture

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

- Interactive diagram: https://gitdiagram.com/steffiroseck/rna-seqanalysispipeline
- Repository: https://github.com/steffiroseck/rna-seqanalysispipeline

## Overview

##### Project Type and Purpose
- This is a shell-and-R “bioinformatics pipeline” for end-to-end RNA-Seq analysis (sheep samples).
- It ingests raw FASTQ files, runs quality control, trimming, alignment, read counting, then performs sequential R-based downstream analyses (differential expression, co-expression, enrichment, StringDB).

##### File Structure
- Top level:
- README.md – overview and tool prerequisites
- extract.IDs.from.GTF.sh – helper script (gene ID extraction)
- rna-seq-pipeline/ – core workflow scripts
- Inside rna-seq-pipeline/:
- 1.RNASeqPipeline.sh – orchestrates FastQC → Trimmomatic → Hisat2 → featureCounts
- 2.*.Rmd & .R files – various downstream analyses (DESeq2, WGCNA, enrichment, StringDB)
- wgcna.locID.annotation.R – supporting annotation for WGCNA step.

##### README for Insights
- The execution order is explicitly listed:
1. Shell pipeline (V1.0.RNASeqPipeline.sh)
2. Rscript V1.0_Deseq2.R (differential expression)
3. Rscript V1.0_GO_KEGG_enrichment_analysis.R
4. Rscript V1.0_wgcna.R
5. Rscript V1.0_Stringdb.R
- External tools: FastQC, Trimmomatic, Hisat2, featureCounts.

a. Main Components
- Input Data Store: FASTQ files (raw reads)
- QC Module: FastQC
- Trimming Module: Trimmomatic
- Alignment Module: Hisat2
- Counting Module: featureCounts → produces gene‐count matrix
- Downstream Analysis Modules (R):
– Differential Expression (DESeq2)
– Enrichment Analysis (GO/KEGG via clusterProfiler or custom R script)
– WGCNA (weighted co‐expression networks + annotation)
– StringDB Analysis
- Helper Scripts: extract.IDs.from.GTF.sh, wgcna.locID.annotation.R
- Outputs: QC reports, trimmed FASTQ, BAM/SAM, count tables, HTML/PDF reports, plots.

b. Relationships & Data Flow

c. Architectural Patterns & Principles
- Linear, modular pipeline (each tool/script is a stage)
- Separation of concerns: shell for data prep, R for statistical analysis
- Reproducibility via versioned scripts and conda/install instructions
- Extensibility: new R modules or QC tools can slot in.

d. Technologies & Frameworks
- Shell scripting (bash)
- Bioconda / apt installs for external tools
- R / R Markdown / Rscript
- Bioconductor packages: DESeq2, WGCNA, clusterProfiler (GO/KEGG), STRINGdb
- Auxiliary: FastQC, Trimmomatic, Hisat2, featureCounts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Pre-processing stage
    subgraph "Pre-processing (bash)"
        direction TB
        RAW_FASTQ["Raw FASTQ Files"]:::data
        PIPELINE["1.RNASeqPipeline.sh"]:::script
        QC_TOOL["FastQC"]:::external
        QC_REPORT["QC Reports"]:::data
        TRIM_TOOL["Trimmomatic"]:::external
        TRIMMED_FASTQ["Trimmed FASTQ Files"]:::data
        ALIGN_TOOL["Hisat2"]:::external
        ALIGNED_BAM["Aligned BAM Files"]:::data
        COUNT_TOOL["featureCounts"]:::external
        COUNT_MATRIX["Gene-count Matrix"]:::data
        ID_EXTRACT["extract.IDs.from.GTF.sh"]:::script

        RAW_FASTQ --> PIPELINE
        PIPELINE --> QC_TOOL
        QC_TOOL --> QC_REPORT
        PIPELINE --> TRIM_TOOL
        TRIM_TOOL --> TRIMMED_FASTQ
        TRIMMED_FASTQ --> ALIGN_TOOL
        ALIGN_TOOL --> ALIGNED_BAM
        ALIGNED_BAM --> COUNT_TOOL
        COUNT_TOOL --> COUNT_MATRIX
        PIPELINE --> ID_EXTRACT
    end

    %% Statistical Analysis stage
    subgraph "Statistical Analysis (R)"
        direction TB
        DE_SEQ["2.differential_gene_expression_updated.Rmd"]:::rmodule
        DE_RESULTS["Differential Expression Results"]:::data
        ENRICH["4.enrichment.analysis.R"]:::rmodule
        ENRICH_RESULTS["GO/KEGG Tables & Plots"]:::data
        WGCNA_ANNOT["wgcna.locID.annotation.R"]:::script
        WGCNA["3.weighted-gene.correlation.Rmd"]:::rmodule
        WGCNA_RESULTS["WGCNA Modules & Plots"]:::data
        STRINGDB["5.stringdb.analysis.R"]:::rmodule
        STRINGDB_RESULTS["Protein-Protein Network"]:::data
        COMBINED["6.differential.expression.and.pathway.on.wgcna.modules.R"]:::rmodule
        FULL_REPORT["2.Downstream_analyses_Full.Rmd"]:::rmodule

        COUNT_MATRIX --> DE_SEQ
        DE_SEQ --> DE_RESULTS
        DE_RESULTS --> ENRICH
        ENRICH --> ENRICH_RESULTS

        COUNT_MATRIX --> WGCNA_ANNOT
        WGCNA_ANNOT --> WGCNA
        WGCNA --> WGCNA_RESULTS

        COUNT_MATRIX --> STRINGDB
        DE_RESULTS --> STRINGDB
        STRINGDB --> STRINGDB_RESULTS

        DE_RESULTS --> COMBINED
        WGCNA_RESULTS --> COMBINED
        STRINGDB_RESULTS --> COMBINED
        ENRICH_RESULTS --> COMBINED

        COMBINED --> FULL_REPORT
    end

    %% Click events
    click PIPELINE "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/rna-seq-pipeline/1.RNASeqPipeline.sh"
    click ID_EXTRACT "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/extract.IDs.from.GTF.sh"
    click DE_SEQ "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/rna-seq-pipeline/2.differential_gene_expression_updated.Rmd"
    click FULL_REPORT "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/rna-seq-pipeline/2.Downstream_analyses_Full.Rmd"
    click WGCNA "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/rna-seq-pipeline/3.weighted-gene.correlation.Rmd"
    click WGCNA_ANNOT "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/wgcna.locID.annotation.R"
    click ENRICH "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/rna-seq-pipeline/4.enrichment.analysis.R"
    click STRINGDB "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/rna-seq-pipeline/5.stringdb.analysis.R"
    click COMBINED "https://github.com/steffiroseck/rna-seqanalysispipeline/blob/main/rna-seq-pipeline/6.differential.expression.and.pathway.on.wgcna.modules.R"

    %% Styles
    classDef external fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef script fill:#90EE90,stroke:#000,stroke-width:1px
    classDef rmodule fill:#FFA500,stroke:#000,stroke-width:1px
    classDef data fill:#D3D3D3,stroke:#000,stroke-width:1px
```
