Skip to main content

title: Chara Survival emoji: ๐Ÿงฌ colorFrom: blue colorTo: gray sdk: gradio pinned: false

๏ปฟ

IIT Mandi

Chara Survival

Thermodynamic Graph Laplacian Survival Inference for Transcriptomic Oncology

PyPI version Python License: MIT Gradio Space IIT Mandi

A frozen 4,337-gene thermodynamic intersection signature that transfers across sequencing platforms โ€” zero retraining required.


The Problem

Standard survival models โ€” Cox proportional hazards, Random Survival Forests, DeepSurv โ€” are trained on RNA-seq cohorts (typically TCGA) and collapse catastrophically when applied to microarray data (GEO). The cause is structural: uncorrected platform variance and feature distribution shift corrupt the learned risk landscape. The concordance index, already noisy at 0.50โ€“0.55 on in-distribution data, degrades to random or sub-random when the platform changes.

This failure is not a modelling artefact. It is a physical problem โ€” raw transcript counts do not encode the molecular interaction topology that determines biological function. Chara corrects this at the feature level, before training even begins.

The Solution

Chara grounds gene expression features in thermodynamic graph Laplacians derived from MARTINI 3 coarse-grained molecular dynamics (MD) simulations. Specifically:

  1. MARTINI 3 MD trajectories are run for key oncogenic protein systems (KRAS, CMYC/MAX, PTPN11, MUT-TP53) across biological replicates.
  2. Exponential heat kernels are computed from the symmetrised graph Laplacian of the STRING proteinโ€“protein interaction network, weighted by MD-derived edge variances via the Chara exponential operator.
  3. The resulting thermodynamic Laplacian representation produces a platform-invariant feature space โ€” the spectral geometry of molecular interaction rather than raw transcript abundance.
  4. A frozen CoxNet trained on TCGA-LUAD using these 4,337 thermodynamically-stabilised features is applied directly to unseen cohorts without fine-tuning.

The result is a model that generalises across the RNA-seq โ†” microarray boundary as a matter of physical principle, not statistical luck.


Performance

Evaluated zero-shot on GSE31210 (Affymetrix Human Genome U133 Plus 2.0, n = 226, completely held-out lung adenocarcinoma microarray cohort โ€” never seen during training):

Model OOD C-Index 1-Year AUC 3-Year AUC 5-Year AUC
Clinical Cox-PH (Age, Gender, Stage) 0.5000 0.5000 0.5000 0.5000
Random Survival Forest (RSF) 0.4041 0.4175 0.3657 0.4842
Elastic Net Coxnet (Raw 5,200 genes) 0.5248 0.4664 0.4081 0.2428
DeepSurv (Deep Neural Network) 0.5537 0.5465 0.3937 0.3122
Chara (Thermodynamic Laplacian) 0.7311 0.7463 0.7826 0.8195

Chara achieves a +0.267 absolute improvement in OOD C-index over the next-best deep learning baseline, with monotonically improving time-horizon AUC โ€” an unusual and clinically meaningful signature of robust calibration rather than threshold overfitting.


Live Inference

A zero-install interactive inference interface is hosted on Hugging Face Spaces:

โ†’ https://huggingface.co/spaces/Sharon-codes/Chara

Upload a patient-by-gene CSV (rows = samples, columns = HGNC symbols). The app aligns your cohort to the frozen 4,337-gene signature, computes risk scores, renders Kaplanโ€“Meierโ€“style survival curves, and returns a downloadable report โ€” all in seconds.


Python Package

Installation

pip install chara-survival

Requires Python โ‰ฅ 3.10. The frozen model artefact (chara_model_4337.pkl) must be placed in your working directory or downloaded from the Releases page.

Programmatic Inference

import pandas as pd
from chara import CharaModel

# Load the frozen model
model = CharaModel.load("chara_model_4337.pkl")

# expression_matrix: patients ร— HGNC gene symbols
expression_matrix = pd.read_csv("patient_expression.csv", index_col=0)

# Align, scale, and infer
risk_scores, x_scaled, aligned_df, scaler, alpha_index = model.predict(expression_matrix)

print(f"Processed {len(expression_matrix)} patients")
print(f"Risk score range: [{risk_scores.min():.4f}, {risk_scores.max():.4f}]")

Survival Curve Extraction

import numpy as np

# Retrieve full survival functions for all patients
curves, times = model.survival_curves(x_scaled, alpha_index)

# Interpolate to clinical horizons
horizons = np.array([365.0, 1095.0, 1825.0])  # 1, 3, 5 years
survival = np.array([
    np.interp(horizons, times, row, left=1.0, right=row[-1])
    for row in curves
])
# survival[:, 0]  โ†’  1-year survival probability per patient
# survival[:, 1]  โ†’  3-year survival probability per patient
# survival[:, 2]  โ†’  5-year survival probability per patient

Thermodynamic Graph Utilities

The chara package also exposes the graph primitives used during training:

from chara.graph import laplacian_from_edges, heat_kernel, exponential_chara_laplacian

# Construct a graph Laplacian from an edge list (e.g., STRING interactions)
L = laplacian_from_edges(edge_df, node_list, source="protein1", target="protein2", weight="score")

# Standard heat kernel (diffusion on Laplacian spectrum)
K = heat_kernel(L, diffusion_time=0.1)

# Chara exponential operator โ€” weights edges by MD variance
L_chara = exponential_chara_laplacian(adjacency, edge_variance, tau=0.5)

API Reference

CharaModel

Method Signature Description
load cls, path: str | Path โ†’ CharaModel Deserialise a frozen Chara model bundle.
predict expression: DataFrame โ†’ (risk, x_scaled, aligned, scaler, alpha) Align, scale, and score a patient cohort.
align_and_scale expression: DataFrame โ†’ (x, aligned, scaler) Feature alignment only.
survival_curves x, alpha_index โ†’ (curves, times) Full survival functions via the frozen CoxNet.

scale_external_expression

from chara import scale_external_expression

x, aligned, scaler = scale_external_expression(expression_df, feature_list)

Aligns an external expression matrix to a target feature list (zero-imputing missing genes, averaging duplicate symbols) and applies StandardScaler.


Input Specification

Property Requirement
Format CSV, rows = patients/samples, columns = HGNC gene symbols
Values Continuous numeric (TPM, FPKM, log2-counts, normalised microarray intensities)
Missing genes Zero-imputed against the 4,337-gene signature
Duplicate symbols Averaged automatically
Platforms tested TCGA RNA-Seq (TPM), Affymetrix HG U133 Plus 2.0, Illumina microarray
Minimum cohort 1 patient (single-sample inference is supported)

Repository Architecture

chara-survival/
โ”œโ”€โ”€ chara/
โ”‚   โ”œโ”€โ”€ __init__.py          # Public API: CharaModel, scale_external_expression
โ”‚   โ”œโ”€โ”€ model.py             # Frozen CoxNet wrapper with strict feature alignment
โ”‚   โ”œโ”€โ”€ graph.py             # Thermodynamic Laplacian and heat-kernel operators
โ”‚   โ””โ”€โ”€ preprocessing.py    # Cross-platform StandardScaler pipeline
โ”‚
โ”œโ”€โ”€ scripts/                 # Full research pipeline (01 โ†’ 19)
โ”‚   โ”œโ”€โ”€ 01_fetch_tcga.py     # TCGA-LUAD expression + survival data
โ”‚   โ”œโ”€โ”€ 02_generate_string.py
โ”‚   โ”œโ”€โ”€ 03_generate_chara.py # Thermodynamic Laplacian construction
โ”‚   โ”œโ”€โ”€ 04_chara_ood_validation.py
โ”‚   โ”œโ”€โ”€ 05_adversarial_poisoning.py
โ”‚   โ”œโ”€โ”€ 06_dirichlet_energy.py
โ”‚   โ”œโ”€โ”€ 07_biological_gsea.py
โ”‚   โ”œโ”€โ”€ 09_zeroshot_external_validation.py
โ”‚   โ”œโ”€โ”€ 11_clinical_frontier_metrics.py
โ”‚   โ”œโ”€โ”€ benchmark_frontiers.py
โ”‚   โ””โ”€โ”€ ...
โ”‚
โ”œโ”€โ”€ assets/                  # Logos and figures
โ”œโ”€โ”€ app.py                   # Gradio inference interface
โ”œโ”€โ”€ chara_model_4337.pkl     # Frozen model artefact (4,337-gene signature)
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ setup.py
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ LICENSE

Reproducibility

The complete research pipeline is contained in scripts/. Execution order follows the numeric prefix (01 โ†’ 19). MARTINI 3 MD trajectories require GROMACS โ‰ฅ 2023.3; all downstream graph construction and survival modelling is pure Python.

Key intermediate artefacts required to reproduce the frozen model from scratch:

File Description
Laplacian_Chara_4337.csv Chara thermodynamic Laplacian (4,337-gene intersection)
Laplacian_STRING_4337.csv Pure STRING Laplacian (ablation baseline)
TCGA-LUAD_expression.csv Training expression matrix
TCGA-LUAD_survival.csv Training survival outcomes
frontier_benchmark_results.csv Full benchmark table

Citation

If you use Chara in published research, please cite this repository until a formal preprint is available:

Sharon Melhi (2026). Chara Survival: Thermodynamic Graph Laplacian Survival Inference
for Out-of-Distribution Transcriptomic Oncology.
GitHub: https://github.com/Sharon-codes/Chara

People

Dr. Kharerin Hungyo
Dr. Kharerin Hungyo
Principal Investigator
Computational & Physical Genomics Lab
Indian Institute of Technology Mandi

kharerin@iitmandi.ac.in
Sharon Melhi
Sharon Melhi
Computational Biologist
Creator, Chara Survival

LinkedIn ยท Email

Special thanks to Khushi Mhamane for her continuous support and invaluable assistance throughout this project.


License

Released under the MIT License. ยฉ 2026 Sharon Melhi.


Developed at the Computational and Physical Genomics Lab ยท Indian Institute of Technology Mandi

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chara_survival-0.1.6.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chara_survival-0.1.6-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file chara_survival-0.1.6.tar.gz.

File metadata

  • Download URL: chara_survival-0.1.6.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for chara_survival-0.1.6.tar.gz
Algorithm Hash digest
SHA256 97270aea4f16396192ef4d3ce3e2901858214b34dfc26d3e4df6105d99ac96c8
MD5 ba5c3ee67fb3210f6b435fddc4bd7fdb
BLAKE2b-256 2e6fb076693d6ce42f0cb6b02a30397a83e22e78542641e9a252053827c3dc30

See more details on using hashes here.

File details

Details for the file chara_survival-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: chara_survival-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for chara_survival-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 acfc872d59c5ab19fddee572e72301178b22a5711a688c8260f446f76625766e
MD5 4e8daa75f4851a471ad20eedbc000262
BLAKE2b-256 57a88c643e838022c4c029ad21823075c4573e539df171ca22149925342a9c02

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

This release

0.1.6 This release

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page