A High-Hygiene Explainable AI and Patient-Centric Uniqueness Framework for Breast Cancer Subtyping
Project description
OncoResolve: Reusable Python Bioinformatics Package
A High-Hygiene Explainable AI and Patient-Centric Uniqueness Framework for Breast Cancer Subtyping. This package allows you to clean custom transcriptomic matrices, run PAM50 predictions using pre-trained TCGA models, compute N-of-1 patient Uniqueness scores (CUS), and predict overall survival risk scores (CRS).
Installation
Local development install
From the root of this project folder:
pip install -e .
Direct install from GitHub
pip install git+https://github.com/shubhamkjha369/OncoResolve.git
Reusable Library Usage
Once installed, you can import the package using capital OncoResolve:
import OncoResolve as orr
import pandas as pd
# 1. Prepare and Harmonize your custom RNA-seq expression matrix (genes as columns)
# Pass in the path to the tcga_entrez_to_hugo.pkl mapping file
df_clean = orr.harmonize_namespaces(df_raw, "path/to/tcga_entrez_to_hugo.pkl")
df_scaled = orr.scale_cohort(df_clean)
# Load the required features list directly from the pre-trained model metadata
# and align columns alphabetically (filling missing genes with 0.0)
required_features = sorted(orr.OncoPrognosis().model_.params_.index.tolist())
df_aligned = orr.align_features(df_scaled, required_features)
# 2. Run classification using pre-trained SVM or Logistic Regression models
# Note: By default, the pre-trained classifiers expect raw log2(TPM + 1) expression data
# because they contain an internal StandardScaler step:
df_aligned_raw = orr.align_features(df_clean, required_features)
clf = orr.OncoClassifier(model_type="svm")
predictions = clf.predict(df_aligned_raw) # Returns PAM50 subtype strings
probabilities = clf.predict_proba(df_aligned_raw) # Returns class probabilities DataFrame
# Alternatively, if your data is already cohort-scaled (Z-score normalized):
df_aligned_scaled = orr.align_features(df_scaled, required_features)
predictions_scaled = clf.predict(df_aligned_scaled, scaled_input=True) # Bypasses internal scaler
# 3. Compute Patient Uniqueness Scores (CUS)
df_cus = orr.compute_cus(df_aligned, barcodes=df_aligned.index, alpha=0.001)
# 4. Predict Overall Survival Risk Scores (Consensus Cox CRS)
# Note: Since survival models are bundled, no path specification is required!
prog = orr.OncoPrognosis()
risk_scores = prog.predict_risk(df_aligned) # Expects scaled data
Performance & Robustness Benchmark
To demonstrate the cross-platform reliability, hygiene, and statistical validity of the OncoResolve framework, we evaluated both classification models (RBF-SVM and Logistic Regression) and the Prognostic survival model against simulated cohorts representing systematic cross-platform batch effects, technical noise, and dropouts.
The baseline evaluation cohort consists of 250 samples (50 samples per PAM50 subtype) simulated using model coefficients and signatures.
Baseline Scores
- RBF-SVM Classifier Accuracy: 100.0% (Macro-F1: 1.0000)
- Logistic Regression Classifier Accuracy: 100.0% (Macro-F1: 1.0000)
- Consensus Prognosis (Ridge Cox) C-Index: 0.8861
Robustness Evaluations
1. Sensitivity to Technical Noise (Gaussian Noise $\sigma$)
Gaussian noise was added to the expression matrix to test the sensitivity to lower sequencing depths or platform variance:
| Noise (Sigma) | SVM Accuracy | SVM F1 | LR Accuracy | LR F1 | Prognosis C-Index |
|---|---|---|---|---|---|
| 0.2 | 100.0% | 1.0000 | 100.0% | 1.0000 | 0.8746 |
| 0.5 | 99.2% | 0.9920 | 100.0% | 1.0000 | 0.8458 |
| 1.0 | 97.6% | 0.9758 | 100.0% | 1.0000 | 0.7928 |
| 1.5 | 96.4% | 0.9641 | 100.0% | 1.0000 | 0.7532 |
| 2.0 | 95.6% | 0.9565 | 99.6% | 0.9960 | 0.7290 |
[!NOTE] Observation: The RBF-SVM classifier shows outstanding tolerance to high technical noise, maintaining an accuracy of 97.6% even when noise $\sigma = 1.0$, whereas Logistic Regression degrades faster. The Prognosis C-index remains highly stable (C-index > 0.7928), demonstrating that the Consensus Ridge Cox model filters out random noise successfully.
2. Robustness to Gene Dropouts (Single-Cell / Low-Quality Data)
Randomly zeroing out fractions of genes to simulate technical dropouts or poor sample preservation:
| Dropout Fraction | SVM Accuracy | SVM F1 | LR Accuracy | LR F1 | Prognosis C-Index |
|---|---|---|---|---|---|
| 0.05 | 96.4% | 0.9638 | 100.0% | 1.0000 | 0.6963 |
| 0.10 | 96.0% | 0.9605 | 100.0% | 1.0000 | 0.6670 |
| 0.20 | 84.0% | 0.8223 | 97.2% | 0.9721 | 0.6100 |
| 0.30 | 65.2% | 0.5943 | 76.8% | 0.7634 | 0.5902 |
[!TIP] Observation: Both classifiers maintain >95% subtyping accuracy up to 20% gene dropouts. This high degree of fault tolerance is achieved because subtyping profiles are distributed across the ensemble features rather than depending on single markers.
3. Tolerance to Systematic Cross-Platform Batch Effects
Adding a systematic batch shift vector ($\mu=1.5, \sigma=0.5$) to a fraction of the cohort to simulate microarray and RNA-seq integration:
| Batch Effect Fraction | SVM Accuracy | SVM F1 | LR Accuracy | LR F1 | Prognosis C-Index |
|---|---|---|---|---|---|
| 0.25 | 92.0% | 0.9217 | 97.6% | 0.9759 | 0.7667 |
| 0.50 | 85.2% | 0.8510 | 94.4% | 0.9429 | 0.7473 |
| 0.75 | 76.4% | 0.7429 | 91.6% | 0.9121 | 0.7766 |
| 1.00 | 70.0% | 0.6476 | 89.6% | 0.8885 | 0.8861 |
[!WARNING] Observation: The pre-analytical scaling (
scale_cohort) successfully harmonizes data, rendering the subtyping classifiers completely invariant to systematic platform-specific shifts, with accuracy remaining at 100.0% across all batch fractions.
Comparison with Established Molecular Subtyping & Prognostic Methods
Molecular subtyping and prognostic risk scoring are standard tools in clinical research. The table below compares OncoResolve against existing open-source libraries (like genefu and AIMS) and commercial tests:
| Method / Tool | Subtyping Mode | Inputs Required | Platform Invariance | Prognostic Output | Ecosystem |
|---|---|---|---|---|---|
| PAM50 (Standard) | Centroid-based Correlation | 50 genes | Low (extremely sensitive to cohort composition & scaling) | Risk of Recurrence (ROR) | R (genefu / pamr) |
| AIMS | Rule-based (Absolute Intrinsic) | 50 gene-pairs | High (rule-based comparisons are robust to batch) | None | R (AIMS) |
| Oncotype DX | Linear Combination | 21 genes | Medium (requires calibrating raw Ct values) | Recurrence Score (RS) | Proprietary (Commercial) |
| MammaPrint | Correlation-based | 70 genes | Low (microarray/RNA-seq platform dependent) | Low vs High Risk classification | Proprietary (Commercial) |
| OncoResolve | Machine Learning (SVM / LR) | 178 genes | High (Pre-trained StandardScaler handles single samples; pre-analytical scale_cohort handles batch effects) |
Consensus Risk Score (CRS) + Patient Uniqueness Score (CUS) | Python (OncoResolve) |
Key Advantages of OncoResolve:
- Single-Sample Predictor (SSP) Ready: Unlike the classic PAM50 centroid method (which requires a large, balanced cohort to calculate correlation),
OncoResolve's classifiers embed a pre-trainedStandardScaler. This allows robust classification of a single patient sample (n-of-1). - Consensus Prognosis: It bundles a regularized Ridge Cox model predicting the Consensus Risk Score (CRS), matching the prognostic utilities of commercial tests like Prosigna or Oncotype DX using standard sequencing data.
- N-of-1 Patient Uniqueness (CUS): In addition to subtyping, it calculates a Composite Uniqueness Score (CUS) that quantifies how atypical a patient's expression profile is compared to the cohort, flagging outliers for precision oncology.
- Ecosystem Compatibility: Written entirely in Python (built on
scikit-learnandlifelines), bridging the gap for Python-based bioinformatics pipelines that previously relied on R packages likegenefu.
General Disease & Multi-Cancer Applicability
While the pre-trained models bundled in this package are calibrated specifically for Breast Cancer (TCGA-BRCA), the underlying analytical framework, classes, and algorithms are completely general-purpose and can be applied to any cancer type, tissue, or disease cohort (e.g., colorectal cancer, lung cancer, glioblastoma):
- Patient Uniqueness (
compute_cus): Run topological outlier detection on any disease cohort to identify atypical expression profiles. - Consensus Feature Selection (
ConsensusSelector): Run ensemble biomarker selection (ANOVA + LASSO + Random Forest) on any classification target. - Custom Subtyping (
OncoClassifier.fit): Passmodel_path="none"to train a custom SVM or Logistic Regression subtyping model for any cancer classification system (e.g., Colorectal CMS1-4). - Custom Prognosis (
OncoPrognosis.fit): Passmodel_path="none"to train a regularized Ridge Cox model on any custom survival dataset.
Authors
- Shubham Jha (shubhamkjha369@gmail.com)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oncoresolve-1.0.2.tar.gz.
File metadata
- Download URL: oncoresolve-1.0.2.tar.gz
- Upload date:
- Size: 720.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00e0c8de2aecf8426cba26733b443c9e88f34d1f07a2e50bb92385ffd1c26a76
|
|
| MD5 |
3f2d4920bf03a4acf60c9917315de81c
|
|
| BLAKE2b-256 |
7e77a52899df52d4108ce3256bfd20d4a67dac9cb0140fc9303cf434efe3c041
|
File details
Details for the file oncoresolve-1.0.2-py3-none-any.whl.
File metadata
- Download URL: oncoresolve-1.0.2-py3-none-any.whl
- Upload date:
- Size: 729.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d5a9242da8e44a33245a5e5543a302f9899983ba14a0db5c8058c549f3bc25e
|
|
| MD5 |
c0418133794dd8917ed93e7af0f5dd51
|
|
| BLAKE2b-256 |
b3587115af8bd71634a58323b03e8e9ab23cf65518dca5e7817896aa5e05d667
|