# chenzrg/gesubnet architecture

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

- Interactive diagram: https://gitdiagram.com/chenzrg/gesubnet
- Repository: https://github.com/chenzrg/gesubnet

## Overview

##### Main Components
a. Data Ingestion Layer
- “data/” directory with four cancer datasets (BRCA, GBM, LGG, OV)
- File formats: zipped gene‐expression data
b. Data Loading & Preprocessing
- dataloader.py
- utils.py (feature normalization, graph construction helpers)
c. Model Definitions
- model/GAT.py, model/GCN.py, model/NeoGNN.py, model/SELM_NN.py
d. Training Orchestration
- GeSubNet_main.py (experiment entry point)
- trainer.py (training loop, evaluation, checkpointing)
- GeSubNet_para_log.py (hyperparameter logging)
e. Persistence & Logging
- log/ (model checkpoints, intermediate figures, result spreadsheets)
f. Case Analysis & Reporting
- Case Analysis/ (post-training network visualizations, example outputs)

##### Relationships & Data Flows
- Data files ─► dataloader.py ─► PyTorch DataLoader ─► trainer.py
- trainer.py ─► model/*.py (calls forward/backward on chosen GNN)
- trainer.py ─► utils.py (for loss calculation, metrics)
- trainer.py ─► logs (checkpoints: GRN.pt; matrices: PDF; results: XLSX)
- GeSubNet_main.py ties together dataloader, trainer, model selection, and logging
- Post-training, Case Analysis module reads saved models and results to generate figures

##### Architectural Patterns & Principles
- Modular separation: data loading vs. model logic vs. training orchestration
- Pipeline pattern: clear, linear flow from raw data to final outputs
- Configuration-driven: GeSubNet_para_log.py captures hyperparameters, enabling reproducible experiments
- Persistence layer: file-system based checkpoints for reproducibility and analysis

##### Technologies & Frameworks
- Python 3.x
- PyTorch (torch, torchvision, torchaudio)
- Standard Python libs (numpy, pandas, matplotlib, networkx, etc., as in requirements.txt)
- File I/O (zip, PDF generation, Excel via pandas/xlsxwriter)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Entry Point
    User["User runs GeSubNet_main.py"]:::compute

    %% Data Ingestion Layer
    subgraph "Data Ingestion Layer"
        Data["data/ (BRCA.zip, GBM.zip, LGG.zip, OV.zip)"]:::datastores
    end

    %% Data Loading & Preprocessing
    subgraph "Data Loading & Preprocessing"
        Dataloader["dataloader.py"]:::compute
        Utils["utils.py"]:::util
        PyTorchLoader["PyTorch DataLoader"]:::compute
    end

    %% Model Definitions
    subgraph "Model Definitions"
        GAT["GAT"]:::compute
        GCN["GCN"]:::compute
        NeoGNN["NeoGNN"]:::compute
        SELM["SELM_NN"]:::compute
    end

    %% Training Orchestration
    subgraph "Training Orchestration"
        Main["GeSubNet_main.py"]:::compute
        ParaLog["GeSubNet_para_log.py"]:::util
        Trainer["trainer.py"]:::compute
    end

    %% Persistence & Logging
    subgraph "Persistence & Logging"
        Logs["log/ (checkpoints, PDFs, XLSX)"]:::datastores
    end

    %% Case Analysis & Reporting
    subgraph "Case Analysis & Reporting"
        CaseAnalysis["Case Analysis/"]:::report
    end

    %% Data & Control Flow
    User --> Main
    Main --> ParaLog
    Main --> Dataloader
    Dataloader -->|"loads raw data"| PyTorchLoader
    PyTorchLoader -->|"batches data"| Trainer
    Trainer -->|"forward/backward"| GAT
    Trainer -->|"forward/backward"| GCN
    Trainer -->|"forward/backward"| NeoGNN
    Trainer -->|"forward/backward"| SELM
    Trainer -->|"calls metrics"| Utils
    Trainer -->|"checkpoint .pt, PDF, XLSX"| Logs
    Logs -->|"reads models/results"| CaseAnalysis

    %% Click Events
    click Data "https://github.com/chenzrg/gesubnet/tree/main/data/"
    click Dataloader "https://github.com/chenzrg/gesubnet/blob/main/dataloader.py"
    click Utils "https://github.com/chenzrg/gesubnet/blob/main/utils.py"
    click GAT "https://github.com/chenzrg/gesubnet/blob/main/model/GAT.py"
    click GCN "https://github.com/chenzrg/gesubnet/blob/main/model/GCN.py"
    click NeoGNN "https://github.com/chenzrg/gesubnet/blob/main/model/NeoGNN.py"
    click SELM "https://github.com/chenzrg/gesubnet/blob/main/model/SELM_NN.py"
    click Main "https://github.com/chenzrg/gesubnet/blob/main/GeSubNet_main.py"
    click Trainer "https://github.com/chenzrg/gesubnet/blob/main/trainer.py"
    click ParaLog "https://github.com/chenzrg/gesubnet/blob/main/GeSubNet_para_log.py"
    click Logs "https://github.com/chenzrg/gesubnet/tree/main/log/"
    click CaseAnalysis "https://github.com/chenzrg/gesubnet/tree/main/Case Analysis/"

    %% Styles
    classDef datastores fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef compute fill:#c2f0c2,stroke:#333,stroke-width:1px
    classDef util fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef report fill:#e0b3ff,stroke:#333,stroke-width:1px
```
