Skip to content
GavinHaLabPublic

About

Proteus is a deep learning framework which utilizes information contained in the cell-free DNA (cfDNA) coverage profiles of individual genes to accurately and directly predict underlying mRNA abundance, providing a wholistic, liquid-biopsy-based analog to traditional RNA-seq assays using standard WGS.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Proteus

Uncertainty-aware inference of tumor gene expression from standard-depth cell-free DNA whole-genome sequencing.

Proteus is a PyTorch-based train/run framework that infers per-gene tumor mRNA abundance (log₂(CPM + 1)) as calibrated probability distributions directly from standard-depth whole-genome sequencing of cell-free DNA (cfDNA). It compiles Triton signal profiles into per-sample Zarr stores, trains BioDVN-family models, tunes them with Optuna, and runs inference with either the bundled production checkpoints or your own full-train outputs.

Proteus, the prophetic "old man of the sea," would change form before ultimately revealing the truth. Like Proteus, this tool transforms cfDNA data to reveal the expression landscape hidden within.

The Pantheon

Proteus is part of The Pantheon — a suite of cfDNA processing and analysis tools. Triton generates bp-resolution fragmentomic and nucleosome signal profiles from cfDNA BAM/CRAM files. Proteus consumes these profiles to predict tumor gene expression, while Keraon uses them to predict tumor subtypes and their proportions.

What Proteus Supports

  • Run the bundled BioDVN, BioDVN_NoSeq, and BioDVN_OnlySeq checkpoints on compiled datasets immediately.
  • Reproduce the included training runs using the provided split TSVs and experiment YAMLs.
  • Fine-tune from an existing checkpoint with --base_weights.
  • Add a new dataset or experiment spec without changing framework code.

Bundled experiment files and trained checkpoints are named for the study used in the manuscript (tds_* experiment YAMLs and proteus_tds-model* checkpoints), because they point to the included paper-reproduction assets. The framework code and CLI are dataset-agnostic: new datasets are introduced through YAML configs and split TSVs rather than hardcoded logic.

Architecture

The core model is BioDVN (Biologically-informed Disentangling Variational Network): a CNN + dual-encoder VAE with Mixture Density Network (MDN) output heads.

Inputs
  TSS signals  (2000 bp × 9 channels)  ─┐
  TSS nucleotides (2000 bp × 4)         ├─→ SignalProcessingBlock (grouped Conv1D + Conv2D)
                                         ┘         │
                               Dual-dilation ReductionBlocks + AvgPool
                                                   │
                                       Signal Encoder (conv → 64-d)
                                                   │
                               concat with TSS features (11) + GB features (11)
                               + reference scalars (3)
                                                   │
                           ┌── Tumor VAE Encoder ──→ z_tumor ──┐
                           └── Background VAE Encoder ──→ z_bg ─┤
                                                                │
                               TFX Discriminator (GRL) ← z_tumor (adversarial)
                               Weight Predictor → α (TFX-conditioned mixing)
                               MergeLatents(z_tumor, z_bg, α) → Decoder
                                                                │
                           ┌── MDN Head (tumor) ──→ {π, β_gamma, μ_normal, σ_normal}
                           └── MDN Head (background) ──→ {π, β_gamma, μ_normal, σ_normal}

Each MDN head outputs a 3-component mixture distribution:

  1. Delta-zero — point mass at 0 for unexpressed genes
  2. Gamma(k=0.75, β) — right-skewed component for low expression
  3. Normal(μ, σ²) — symmetric component for moderate/high expression

The model is trained to minimize CRPS (Continuous Ranked Probability Score) rather than MSE, producing calibrated uncertainty estimates alongside point predictions.

Input Data

Proteus consumes per-gene features generated by Triton:

Input Shape Description
TSS signals (2000, 9) Coverage, fragment-end coverage/asymmetry, P/N signal, FL sub-nuc ratio, FL entropy, FL Gini-Simpson, P/N peaks, NaN mask
TSS nucleotides (2000, 4) A/C/G/T one-hot encoding of the reference sequence
TSS features (11,) Summary statistics: fragment length moments, nucleosome metrics, depth
GB features (11,) Gene-body summary statistics (identical feature set to TSS)
Reference scalars (3,) Gene-level reference annotations

Raw Triton outputs are compiled into per-sample Zarr stores via --process_data.

Preparing Inputs with Triton

Proteus requires per-sample outputs from Triton, run in window mode for promoter regions (TSS) and region mode for gene bodies (GB). Each run produces signal profiles (.npz) and region-level features (.tsv) per sample.

GC Bias Correction

Triton applies fragment-level GC bias correction to all analyses (coverage, fragment length distributions, and derived metrics). This requires a per-sample .GC_bias file generated by Griffin or an equivalent tool. GC correction is critical for accurate downstream predictions — uncorrected profiles introduce systematic biases that propagate through Proteus.

Running Triton

# TSS (promoter) profiles — window mode, ±1000 bp around each TSS
python3 Triton/Triton.py \
    --sample_name SAMPLE_ID \
    --input /path/to/sample.bam \
    --bias /path/to/sample.GC_bias \
    --annotation reference/MANE.GRCh38.v1.3_TSS.bed \
    --reference_genome /path/to/genome.fa \
    --results_dir triton_output/TSS/results \
    --run_mode window

# Gene-body profiles — region mode, full gene bodies
python3 Triton/Triton.py \
    --sample_name SAMPLE_ID \
    --input /path/to/sample.bam \
    --bias /path/to/sample.GC_bias \
    --annotation /path/to/MANE.GRCh38.v1.3_TranscriptBodies.bed \
    --reference_genome /path/to/genome.fa \
    --results_dir triton_output/GB/results \
    --run_mode region

The TSS annotation BED is bundled at reference/MANE.GRCh38.v1.3_TSS.bed; supply a matching MANE transcript-bodies BED for the gene-body run.

For large cohorts, use Triton's Snakemake workflow for parallelized execution (see the Triton README for details).

Once Triton outputs are available, point your dataset YAML config at the results directories and run --process_data to compile them into Zarr stores.

Quick Start

Environment Setup

Proteus uses a micromamba environment with PyTorch + CUDA 12.1 bundled. The canonical reproducible environment spec is proteus.env:

micromamba create -f proteus.env
micromamba activate proteus

For a lighter pip-based install of the core train/run framework, first install a compatible PyTorch 2.5+ build for your platform and CUDA stack, then install the remaining Proteus dependencies:

pip install <your-compatible-pytorch-build>
pip install -r requirements.txt

Analysis and interpretation extras are in analysis/requirements-analysis.txt:

pip install -r requirements.txt -r analysis/requirements-analysis.txt

No separate CUDA/cuDNN module loads are required when using proteus.env — the environment bundles the CUDA 12.1 runtime. Only the host NVIDIA driver (≥ 530) is needed.

For the paper-reproduction analysis workflow, see Manuscript Reproduction below.

Proteus defaults to repository-local runtime paths so a fresh checkout has a coherent baseline layout:

  • data/zarr for compiled Zarr stores
  • data/raw_triton for Triton outputs
  • labels/ for label TSVs
  • reference/MANE.GRCh38.v1.3.UniversalReference.tsv for the reference scalars TSV

Override them with PROTEUS_ZARR_BASE, PROTEUS_RAW_DATA_DIR, CLI flags, or a local config/paths.yaml. That file is gitignored so machine-specific paths are never committed; copy the tracked config/paths.yaml.example to config/paths.yaml and edit it for your site.

Data Preparation

# Compile Triton outputs → Zarr stores
python Proteus.py --process_data --use_set PC-PDX

# Verify Zarr stores
python Proteus.py --verify_data --use_set PC-PDX

Training

# Cross-validation (all folds)
python Proteus.py --run_mode train --experiment config/experiments/tds_cv.yaml

# Single fold (for HPC parallelization)
python Proteus.py --run_mode train --experiment config/experiments/tds_cv.yaml --test_fold 1

# Full-train (production model, all data)
python Proteus.py --run_mode full-train --experiment config/experiments/tds_final-training.yaml

# Fine-tune from an existing checkpoint
python Proteus.py --run_mode full-train --experiment config/experiments/tds_final-training.yaml --model_name BioDVN --base_weights trained_models/proteus_tds-model/full_train/final_model.pt

Hyperparameter Tuning

# Sequential CV tuning (single process)
python Proteus.py --run_mode tune --experiment config/experiments/TDS_tuning/biodvn_tune-tds-v2_finalize.yaml --n_trials 50

# Fold-parallel tuning worker
python Proteus.py --run_mode tune --experiment config/experiments/TDS_tuning/biodvn_tune-tds-v2_finalize.yaml --test_fold 1

Inference

python Proteus.py --run_mode run --model_name BioDVN --use_set PHS
python Proteus.py --run_mode run --model_name BioDVN_NoSeq --use_set CRPC-WCDT
python Proteus.py --run_mode run --model_name BioDVN_OnlySeq --use_set SCLC-PDX

--model_name BioDVN (the default) loads the bundled production checkpoint trained_models/proteus_tds-model/full_train/final_model.pt; the _NoSeq / _OnlySeq variants load their corresponding proteus_tds-model_no-seq / proteus_tds-model_only-seq checkpoints.

Outputs are written under results_holdout/<MODEL>/<DATASET>/.

CLI Reference

Argument Description
--process_data Convert raw Triton outputs → per-sample Zarr stores
--verify_data Validate integrity of existing Zarr stores
--use_set Dataset name (e.g., PC-PDX, SCLC-PDX)
--run_mode train · full-train · tune · run
--experiment Path to experiment YAML (required for train/tune)
--test_fold Run a single fold (for HPC parallelism)
--n_trials Number of Optuna trials (sequential mode)
--optuna_storage Optuna DB URL (default: SQLite in output dir)
--study_name Override Optuna study name
--sampler_seed Random seed for Optuna sampler
--base_weights Path to pretrained weights (transfer learning)
--zarr_output_dir Override the Zarr base directory
--raw_data_dir Override the raw Triton base directory
--subsample Gene subsample fraction for fast sanity checks
--overwrite Overwrite existing Zarr stores

Project Structure

Proteus/
├── Proteus.py                    # CLI entry point: data prep, train, tune, inference
├── proteus_workflows/            # Extracted workflow layer for data, train, and inference flows
├── models/
│   ├── models.py                 # BioDVN architecture + BioDVNConfig (channel-mode parameterized)
│   └── model_utils.py            # MDN heads, CRPS loss, β-TCVAE losses, custom layers
├── proteus_utils/
│   ├── proteus_utils.py          # Datasets, DataLoaders, gene-weight computation
│   ├── compile_sample_data.py    # Triton → Zarr compilation pipeline
│   ├── trainer.py                # Training loop: AMP, cosine LR, EMA, early stopping
│   ├── evaluation.py             # Fold-level prediction accumulation, metrics, scatter plots
│   ├── data_helpers.py           # Shared helpers: Zarr paths, PHT parsing, source mapping
│   ├── metrics.py                # Statistical functions: Pearson/Spearman r, GVW-r, coverage
│   └── logging_config.py         # Centralized logging setup
├── config/
│   ├── dataset_config.py         # Dataset YAML loading + DatasetConfig dataclass
│   ├── experiment_spec.py        # Experiment schema (ExperimentSpec, TuningSpec, ParamSpec)
│   ├── paths.yaml.example        # Template for a local, gitignored config/paths.yaml
│   ├── runtime_paths.py          # Repository-local path resolution helpers
│   ├── datasets/                 # Per-dataset YAML configs (Triton paths, label files)
│   └── experiments/              # Experiment YAML configs (HP search spaces, training specs)
├── tuning/
│   ├── optuna_tuner.py           # Optuna CV/fold-parallel tuning entry points
│   ├── param_resolution.py       # Trial HP suggestion, config resolution, replay
│   ├── metrics.py                # Fold-metric collection, CV objective computation
│   ├── promotion.py              # Cross-fold top-config promotion
│   └── reporting.py              # Study reports, fold stability, search space narrowing
├── analysis/                     # Downstream analysis (gene-set scoring, patient-level metrics)
│   ├── enrichment_utils.py       # Shared GSEA/ssGSEA primitives extracted from the main runner
│   ├── analysis_utils.py         # Shared analysis loaders, metrics, survival, PAM50 helpers
│   ├── plot_utils.py             # Analysis plotting helpers
│   └── run_full_analysis.py      # Main analysis orchestrator
├── interpretation/               # Interpretability (Captum attribution, kernel visualization)
├── runs/                         # Generic launcher templates + study-specific HPC scripts
├── labels/                       # Expression matrices + TFX/subtype labels
├── data/                         # Training split TSVs + fold index files
└── trained_models/               # Saved model weights

Configuration

Dataset Configs (config/datasets/*.yaml)

name: PC-PDX
sources:
  triton_tss: "PC-PDX_data/TritonV2_TSS/results"
  triton_gb: "PC-PDX_data/TritonV2_GB/results"
  tfx: "PC-PDX_TFX_Subtype.tsv"
labels:
  tumor_exp: "PC-PDX_Log2CPMplus1.tsv"
  background_exp: null

Experiment Configs (config/experiments/*.yaml)

Experiment YAMLs define three HP groups — each parameter can be a fixed value or an Optuna search specification:

Group Parameters
Structural beta_background, beta_kl, beta_contrastive, beta_reconstruction, beta_tfx, beta_srl_max, beta_dynamic_pair_max, srl_delta, srl_start, srl_ramp, beta_pht_consistency, beta_pht_uncertainty, cl_margin, internal_weight
Training max_lr, min_lr_ratio, warmup_start_lr, weight_decay, max_grad_norm, warmup_frac, schedule_frac, epochs, patience, use_amp, grad_accum_steps
Scale encoder_start, latent_size, decoder_start, mdn_hidden, mdn_final, signal_filters, signal_ksize, interaction_ksize, initial_reduction_channels, n_reductions, funnel_reduction_factor, reduction_dilation, dropout_rate

Zarr Store Schema

Each per-sample Zarr store contains:

sample.zarr/
├── gene_names           (n_genes,)       string
├── attrs: {sample_name, n_genes, tfx}
└── flat/
    ├── TSS_signals      (n_genes, 2000, 9)   float32
    ├── TSS_nucleotides  (n_genes, 2000, 4)   uint8
    ├── TSS_features     (n_genes, 11)        float32
    ├── GB_features      (n_genes, 11)        float32
    ├── ref_scalars      (n_genes, 3)         float32
    ├── TFX_label        (n_genes,)           float32
    ├── tumor_exp        (n_genes,)           float32
    ├── background_exp   (n_genes,)           float32
    └── gene_weight      (n_genes,)           float32

Compression: Blosc (zstd, clevel=3). Chunks along gene axis only (256 for signal arrays, 1024 for feature vectors).

Output Format

Training Predictions

Per-fold TSVs with columns: truth, prediction_mean, ci_q5, ci_q95, pi_delta, pi_gamma, gamma_beta, pi_normal, normal_mean, normal_stdev, sample

Metrics

Primary selection metric: Gene-Variance-Weighted CRPS (tumor_gvw_crps) — genes weighted by their expression variance so that biologically informative genes (bimodal on/off) contribute more than near-constant housekeeping genes.

Additional metrics per fold: GVW-R², gene-level R² (mean/median distribution), sample-level R², MAE, RMSE.

HPC Execution

The runs/ directory includes generic launcher templates for the main workflows:

  • runs/launch_train_cv.sh
  • runs/launch_full_train.sh
  • runs/launch_inference.sh
  • runs/launch_tune_worker.sh

They are driven by environment variables such as EXPERIMENT, MODEL_NAME, PARTITION, GPU, and ACCOUNT so the same scripts can be reused across datasets and clusters. Older dataset-specific launchers remain in runs/ as project examples for existing study configurations.

Requirements

Python 3.10 with PyTorch 2.5+ (CUDA 12.1).

Core train/run dependencies live in requirements.txt. Analysis and interpretation extras live in analysis/requirements-analysis.txt.

Core packages:

Package Version Purpose
torch ≥ 2.5 Core framework (install a compatible build first)
numpy ≥ 2.0 Array operations
zarr ≥ 2.18 Per-sample data stores
pandas ≥ 2.0 DataFrames for labels + metrics
optuna ≥ 3.6 Hyperparameter optimization
scipy ≥ 1.11 Scientific computing (CRPS, statistics)
scikit-learn ≥ 1.3 Metrics utilities
matplotlib ≥ 3.8 Visualization
rich ≥ 13.0 Progress bars
pyyaml ≥ 6.0 Config parsing

Optional extras:

  • Analysis: seaborn, lifelines, gseapy, rpy2
  • Interpretation: captum, logomaker, shap, umap-learn

Canonical micromamba environment spec: see proteus.env.

GPU: NVIDIA GPU with ≥ 11 GB VRAM. Tested on RTX 2080 Ti (11 GB) and L40S (48 GB). Host NVIDIA driver ≥ 530 required. Training and inference are GPU-only (no CPU fallback).

Operating system: developed and tested on Linux (x86-64). The environment is delivered through micromamba/conda, so any Linux distribution with a compatible NVIDIA driver should work. macOS/Windows are not supported for GPU training.

Expected Runtimes

Approximate wall-clock on the tested GPUs. Times scale with the number of genes per sample (~18k in the shipped study), the number of samples, and the epoch budget; treat training figures as order-of-magnitude and confirm on your hardware.

Task Hardware Approx. time
Inference, one sample RTX 2080 Ti / L40S < 1 minute
Inference, one cohort (dozens of samples) L40S a few minutes
CV training, one fold (100 epochs) L40S ~2–6 hours
Full-train (all data, 100 epochs) L40S ~2–6 hours
Hyperparameter tuning (per trial, one fold) L40S ~2–6 hours

Cross-validation and tuning are embarrassingly parallel across folds/trials — the runs/ launchers submit each fold as an independent single-GPU job.

Manuscript Reproduction

This repository doubles as a versioned reproducibility record for the manuscript. The bundled proteus_tds-model* checkpoints, experiment YAMLs, split TSVs, and reference assets are exactly those used to produce the paper's results.

What is and isn't provided

  • Provided: model code, the three production checkpoints (trained_models/proteus_tds-model{,_no-seq,_only-seq}/full_train), experiment YAMLs (config/experiments/tds_*), the cross-validation split (data/TDS_sample-splits.tsv), and all reference/label assets under reference/ and labels/.
  • Not provided: the raw Triton signal profiles. These are far too large to host on GitHub and must be regenerated per sample from BAM/CRAM files using Triton (see Preparing Inputs with Triton above), then compiled to Zarr with --process_data. Every other input needed to reproduce the analysis is included.

How the production models were built

The three shipped BioDVN variants (BioDVN, BioDVN_NoSeq, BioDVN_OnlySeq) were each produced with the same four-stage pipeline:

# 1. Hyperparameter tuning — coordinated fold-parallel Optuna search
python Proteus.py --run_mode tune \
    --experiment config/experiments/TDS_tuning/biodvn_tune-tds-v2_finalize.yaml \
    --test_fold 1              # one job per fold; 5 folds share one study/storage

# 2. Cross-validation with the finalized hyperparameters (per-fold on HPC)
python Proteus.py --run_mode train --experiment config/experiments/tds_cv.yaml --test_fold 1
#   ... folds 2–5 ...

# 3. Full training on all data → the shipped production checkpoint
python Proteus.py --run_mode full-train --experiment config/experiments/tds_final-training.yaml

# 4. Inference on held-out / discovery cohorts for downstream analysis
python Proteus.py --run_mode run --model_name BioDVN --use_set <dataset>

The _no-seq and _only-seq variants use the corresponding tds-no-seq_* / tds-only-seq_* experiment YAMLs and --model_name BioDVN_NoSeq / BioDVN_OnlySeq. The exact HPC launchers used for the study are in runs/ (e.g. launch_tds_cv.sh, launch_tds_final-training.sh, launch_tds_finalize.sh).

Reproducing the paper analyses

The CV out-of-fold predictions and holdout/discovery inference outputs feed the downstream analysis pipeline in analysis/run_full_analysis.py, which regenerates the manuscript's benchmarking, validation, calibration, and discovery figures (gene-variance-weighted benchmarking, uncertainty/abstention analysis, ssGSEA and PAM50 phenotyping, limma differential expression, and survival modeling). The pipeline reads only from results_training/ and results_holdout/, and writes figures and tables under analysis/results/:

# Install the analysis/interpretation extras first (see Environment Setup)
pip install -r requirements.txt -r analysis/requirements-analysis.txt

# Regenerate the manuscript analyses from the prediction TSVs
python analysis/run_full_analysis.py

Generated analysis/results/ outputs are not shipped in the repository (they are large and regenerable); only the code required to reproduce them is included. Statistical methods, gene sets, and thresholds follow the manuscript Methods.

Contact

Questions, feedback, or collaboration inquiries:

Robert D. Patton — rpatton@fredhutch.org

Acknowledgments

Proteus is developed and maintained by Robert D. Patton in the Gavin Ha Lab, Fred Hutchinson Cancer Center.

License

Modified MIT License — see LICENSE.

About

Proteus is a deep learning framework which utilizes information contained in the cell-free DNA (cfDNA) coverage profiles of individual genes to accurately and directly predict underlying mRNA abundance, providing a wholistic, liquid-biopsy-based analog to traditional RNA-seq assays using standard WGS.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages