A Biological Hybrid AI pipeline for molecular subtyping of gastric cancer integrating WES mutational signatures, DNA methylation, and clinical data
Results β’ Architecture β’ Install β’ Quick Start β’ Methodology
An end-to-end multi-omics pipeline for classifying TCGA-STAD gastric cancer into 5 molecular subtypes β CIN, EBV, GS, MSI, and POLE.
Standard ML classifiers suffer from the accuracy paradox β a model can hit ~89% accuracy by favoring the majority CIN class while catastrophically failing on rare but clinically critical subtypes like POLE (1.9% of samples) and GS (12.3%). This pipeline solves that with the Biological Hybrid AI (BHAI) framework β deterministic biological rules for POLE and GS that supplement SMOTE-XGBoost where synthetic data alone isn't enough.
| Data Layer | Source | Samples |
|---|---|---|
| Somatic Mutations | GDC Masked MAF files (WES) | 431 |
| DNA Methylation | Illumina 450K Ξ²-values | 457 |
| Clinical Labels | GDC + cBioPortal | 375 labelled |
Improved version of Machine-Learning-Mutational-Signatures
Original used MAF only β this adds DNA methylation, 20 driver gene features, and the Hybrid AI framework.
| Strategy | Accuracy | Macro F1 | MSI Recall | GS Recall | POLE Recall |
|---|---|---|---|---|---|
| SMOTE + XGBoost Baseline | 89.3% | 0.812 | 100% | 41.3% | 28.6% |
| + Hybrid Biological Rules | 90.5% | 0.847 | 100% | 58.7% | 57.1% |
| + Threshold Optimisation | 91.2% | 0.860 | 100% | 63.0% | 57.1% |
| Subtype | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| CIN | 0.94 | 0.96 | 0.95 | 219 |
| EBV | 0.90 | 0.83 | 0.86 | 30 |
| GS | 0.72 | 0.63 | 0.67 | 46 |
| MSI | 0.99 | 1.00 | 0.99 | 73 |
| POLE | 0.80 | 0.57 | 0.67 | 7 |
- POLE recall: 28.6% β 57.1% via single biological rule (SBS10 + TMB)
- GS recall: 41.3% β 63.0% via CDH1/RHOA mutation logic + threshold tuning
- MSI recall: 100% maintained across all strategies
- COSMIC reconstruction: 0.933 avg cosine similarity across 431 samples
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β INPUT DATA SOURCES β
β MAF Files (431) β Methylation (457) β Clinical (GDC) β
βββββββββ¬βββββββββββββ΄βββββββββββ¬βββββββββββ΄βββββββββββ¬ββββββββββ
β β β
βΌ β β
ββ Step 1 ββββββββββββββ β β
β Process MAF Files β β β
β β’ 96-ch SBS Matrix β β β
β β’ 20 Driver Genes β β β
βββββββββ¬ββββββββββββββββ β β
βΌ β β
ββ Step 2 ββββββββββββββ β β
β NMF Extraction (k=9) β β β
βββββββββ¬ββββββββββββββββ β β
βΌ β β
ββ Step 3 ββββββββββββββ β β
β COSMIC v3.4 NNLS β β β
β 83 active signatures β β β
βββββββββ¬ββββββββββββββββ β β
β β β
βΌ βΌ βΌ
ββ Step 4 ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Multi-Omics Feature Matrix β 281 features β
βββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββ Step 5 ββββββββββββββ
β Methylation Processingβ
β Two-pass, RAM-optimizedβ
βββββββββ¬ββββββββββββββββ
βΌ
ββ Step 6 ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Biological Hybrid AI Classification β
β POLE Rule (SBS10+TMB) β GS Rule (CDH1/RHOA) β SMOTE-XGB β
βββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βΌ
ββ Step 7 ββββββββββββββ
β Visualization (SHAP, β
β t-SNE, UMAP, Survival)β
βββββββββββββββββββββββββ
βββ 02_methylation_data/ # Processed methylation features
β βββ methylation_features.csv
β βββ methylation_pca.csv (30 PCA components)
β βββ methylation_targeted.csv (MLH1, CDH1, CDKN2A, MGMT, BRCA1, RUNX3)
β βββ methylation_summary.csv (CIMP score, global stats)
β
βββ 03_pipeline_scripts/ # Core pipeline
β βββ step1_process_maf.py β SBS96 + gene features
β βββ step2_extract_signatures.py β NMF (k=9)
β βββ step3_cosmic_assignment.py β COSMIC v3.4 NNLS
β βββ step4_build_features.py β 281-feature matrix
β βββ step5_process_methylation.py β Two-pass methylation
β βββ step6_classify.py β Hybrid AI classifier
β βββ step7_visualize.py β Publication figures
β βββ run_pipeline.sh β Master runner
β
βββ 07_figures/ # Publication-ready figures
βββ 08_clinical_data/ # Clinical + subtype labels
βββ 09_documentation/ # Detailed docs
βββ requirements.txt
βββ LICENSE
βββ README.md
git clone https://github.com/Ahsansayz/AI-Driven-Multi-Omics-Gastric-Cancer-Subtyping.git
cd AI-Driven-Multi-Omics-Gastric-Cancer-Subtyping
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt- MAF Files β Download TCGA-STAD masked somatic MAFs from GDC β
01_raw_data/maf_files/ - COSMIC Reference β Download COSMIC v3.4 SBS signatures β
01_raw_data/cosmic_reference/ - Methylation (optional) β Pre-processed features already included in
02_methylation_data/
# Full pipeline
bash 03_pipeline_scripts/run_pipeline.sh
# Individual steps
python 03_pipeline_scripts/step1_process_maf.py # MAF β SBS96 + genes
python 03_pipeline_scripts/step2_extract_signatures.py # NMF extraction
python 03_pipeline_scripts/step3_cosmic_assignment.py # COSMIC mapping
python 03_pipeline_scripts/step4_build_features.py # Feature matrix
python 03_pipeline_scripts/step5_process_methylation.py # Methylation
python 03_pipeline_scripts/step6_classify.py # Classification
python 03_pipeline_scripts/step7_visualize.py # Figures
# Run specific steps only
bash 03_pipeline_scripts/run_pipeline.sh 6 7Three strategies combined:
1. POLE Override β SBS10 total > threshold + TMB > 7.0 mut/Mb + MSI safeguard (SBS15 check)
2. GS Rescue β Evidence scoring: CDH1 truncating (3pt) + RHOA (2pt) + CDH1 missense (1pt) + TP53 wt (1pt). Override at score β₯ 3 when ML confidence < 0.50
3. SMOTE-XGBoost β 500 trees, stratified 5-fold CV, per-class threshold optimization
| Block | Count | Source |
|---|---|---|
| COSMIC activities (abs + proportional) | 166 | NNLS fitting |
| Engineered + Clinical | 15 | TMB, MSI burden, age, etc. |
| Methylation (targeted + PCA + summary) | 47 | Two-pass processing |
| Gene mutations (20 genes Γ binary + count + CDH1 detail + variant stats) | 53 | MAF parsing |
| Total | 281 |
| Original | This Version | |
|---|---|---|
| Data | MAF only | MAF + Methylation + Clinical |
| Features | ~179 | 281 |
| Gene Mutations | β | β 20 driver genes |
| Methylation | β | β CpGs + CIMP + PCA |
| Classification | XGBoost | Hybrid Biological AI |
| POLE Recall | ~28% | 57.1% |
| GS Recall | ~41% | 63.0% |
| Accuracy | ~85% | 91.2% |
MIT License β see LICENSE
Built for precision oncology research



