# mortazavilab/pywgcna architecture

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

- Interactive diagram: https://gitdiagram.com/mortazavilab/pywgcna
- Repository: https://github.com/mortazavilab/pywgcna

## Overview

##### Main Components Identification

a. Core Analysis Components:
- Gene Expression Analysis Module (geneExp.py)
- WGCNA Analysis Module (wgcna.py)
- Comparison Module (comparison.py)
- Utilities Module (utils.py)

b. External Integrations:
- Database Connections (STRING for PPI)
- Enrichment Analysis Services (GO, KEGG, REACTOME)

**Input Layer**

**Core Processing Layer**

**Analysis Layer**

**Output/Visualization Layer**

##### Component Relationships

- Rectangles: Core processing modules
- Hexagons: External services
- Rounded rectangles: Input/Output components

- Blue: Core WGCNA functionality
- Green: Data input/preprocessing
- Orange: Analysis and comparison features
- Purple: External integrations

##### Data Flow Directions

Following flows:
**Gene Expression Data → Data Preprocessing → Module Detection →**
- → Network Analysis
- → Trait Correlation
- → Functional Enrichment
- → Network Comparison

##### Specific Implementation Details

a. Input Processing:
- Gene expression matrix
- Sample trait data
- Network parameters

b. Core WGCNA Pipeline:
- Data cleaning
- Network construction
- Module detection
- Eigengene calculation

c. Analysis Features:
- Module-trait relationships
- Network comparison
- Functional enrichment
- PPI network integration

##### Integration Points

Connections to:
- External databases (STRING)
- Enrichment services (GO, KEGG, REACTOME)
- Visualization outputs (networks, heatmaps, plots)

##### Additional Elements

- File format support
- Visualization capabilities
- Analysis options
- External dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef input fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef analysis fill:#FFA500,stroke:#333,stroke-width:2px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef output fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% Input Layer
    subgraph Input
        GE[Gene Expression Matrix]:::input
        ST[Sample Trait Data]:::input
        NP[Network Parameters]:::input
    end

    %% Core Processing Layer
    subgraph Core
        GEM["Gene Expression Module"]:::core
        WM["WGCNA Module"]:::core
        UM["Utilities Module"]:::core
    end

    %% Analysis Layer
    subgraph Analysis
        CM["Comparison Module"]:::analysis
        MTA["Module-Trait Analysis"]:::analysis
        NA["Network Analysis"]:::analysis
        FEA["Functional Enrichment"]:::analysis
        PPI["PPI Network Analysis"]:::analysis
    end

    %% External Integration Layer
    subgraph External
        STRING[("STRING DB")]:::external
        GO["GO Enrichment"]:::external
        KEGG["KEGG Pathways"]:::external
        REACTOME["REACTOME"]:::external
    end

    %% Output Layer
    subgraph Visualization
        NV["Network Visualization"]:::output
        HM["Heatmaps"]:::output
        PLOTS["Analysis Plots"]:::output
    end

    %% Relationships
    GE --> GEM
    ST --> GEM
    NP --> WM
    
    GEM --> WM
    WM --> CM
    WM --> MTA
    WM --> NA
    
    NA --> PPI
    PPI --> STRING
    
    NA --> FEA
    FEA --> GO
    FEA --> KEGG
    FEA --> REACTOME
    
    NA --> NV
    MTA --> HM
    FEA --> PLOTS

    %% Click Events
    click GEM "https://github.com/mortazavilab/PyWGCNA/blob/main/PyWGCNA/geneExp.py"
    click WM "https://github.com/mortazavilab/PyWGCNA/blob/main/PyWGCNA/wgcna.py"
    click CM "https://github.com/mortazavilab/PyWGCNA/blob/main/PyWGCNA/comparison.py"
    click UM "https://github.com/mortazavilab/PyWGCNA/blob/main/PyWGCNA/utils.py"
    click GO "https://github.com/mortazavilab/PyWGCNA/tree/main/tutorials/figures/GO"
    click KEGG "https://github.com/mortazavilab/PyWGCNA/tree/main/tutorials/figures/KEGG"
    click REACTOME "https://github.com/mortazavilab/PyWGCNA/tree/main/tutorials/figures/REACTOME"
    click PPI "https://github.com/mortazavilab/PyWGCNA/tree/main/tutorials/figures/PPI"
    click NV "https://github.com/mortazavilab/PyWGCNA/tree/main/tutorials/figures/network"
    click MTA "https://github.com/mortazavilab/PyWGCNA/blob/main/tutorials/module_trait_relationships_heatmap.ipynb"
    click NA "https://github.com/mortazavilab/PyWGCNA/blob/main/tutorials/network_analysis.ipynb"
    click PPI "https://github.com/mortazavilab/PyWGCNA/blob/main/tutorials/protein_protein_interaction.ipynb"
    click FEA "https://github.com/mortazavilab/PyWGCNA/blob/main/tutorials/functional_enrichment_analysis.ipynb"

    %% Legend
    subgraph Legend
        I["Input"]:::input
        C["Core Processing"]:::core
        A["Analysis"]:::analysis
        E["External Services"]:::external
        O["Output"]:::output
    end
```
