This repository trains and evaluates the PaGOA pipeline in 3 stages:
- Stage 1: train multimodal image+EHR encoders (Cox survival objective).
- Stage 2: export frozen embeddings and build fold-aware kNN graphs.
- Stage 3: train graph survival model (GraphSAGE + discrete-time survival head).
train/train_multicohort_image_ehr_surv.py(Stage 1)train/export_multicohort_embeddings.py(Stage 2a)graph/build_knn_graph.py(Stage 2b)train/train_graph_patient_surv_no_concepts.py(Stage 3)
Useful run scripts already included:
run_parallel.sh(Stage 1, all folds)single_gpu_stage1_melanoma.sh(Stage 1, Melanoma only)run_graphs.sh(Stage 3 batch runner)run_coxph.sh,run_deepsurv.sh,run_deephit.sh(baselines)
pre_processing/data/all_cohorts_manifest_clean.csvpre_processing/data/all_cohorts_ehr_unified.csv
Set base variables once:
cd /home/azureuser/PITL
export PYTHONPATH=/home/azureuser/PITL
OUT_BASE=/home/azureuser/PITL/outputs/multicohort_img_ehr_no_concepts_unified_index_resolved
MANIFEST=/home/azureuser/PITL/pre_processing/data/all_cohorts_manifest_clean.csv
EHR=/home/azureuser/PITL/pre_processing/data/all_cohorts_ehr_unified.csvOption A (recommended launcher):
bash run_parallel.shOption B (single cohort example):
bash single_gpu_stage1_melanoma.shExpected Stage-1 artifacts:
${OUT_BASE}/folds.json${OUT_BASE}/fold_<k>/best_multicohort_img_ehr_surv.pt
Run per fold and cohort (all, TCGA, Melanoma, NSCLC depending on your experiments).
Example for FOLD=0, COHORT=Melanoma:
FOLD=0
COHORT=Melanoma
python train/export_multicohort_embeddings.py \
--manifest-csv "${MANIFEST}" \
--ehr-csv "${EHR}" \
--stage1-out-dir "${OUT_BASE}" \
--ckpt-name best \
--folds-json "${OUT_BASE}/folds.json" \
--fold "${FOLD}" \
--spatial-size 128 128 192 \
--batch-size 2 \
--device cuda:0 \
--cohort-filter "${COHORT}" \
--out-pt "${OUT_BASE}/fold_${FOLD}/exported_embeddings/${COHORT}/best/fold${FOLD}_embeddings.pt"python graph/build_knn_graph.py \
--embeddings-pt "${OUT_BASE}/fold_${FOLD}/exported_embeddings/${COHORT}/best/fold${FOLD}_embeddings.pt" \
--folds-json "${OUT_BASE}/folds.json" \
--fold "${FOLD}" \
--k 10 \
--emb-key z_img_z_ehr \
--within-dataset \
--manifest-csv "${MANIFEST}" \
--out-json "${OUT_BASE}/fold_${FOLD}/graph_result/${COHORT}/best/knn_k10_within_dataset.json"Batch launcher (expects Stage-2 embeddings and kNN json already prepared):
bash run_graphs.shOr single run example:
python train/train_graph_patient_surv_no_concepts.py \
--embeddings-pt "${OUT_BASE}/fold_0/exported_embeddings/Melanoma/best/fold0_embeddings.pt" \
--knn-json "${OUT_BASE}/fold_0/graph_result/Melanoma/best/knn_k10_within_dataset.json" \
--manifest-csv "${MANIFEST}" \
--folds-json "${OUT_BASE}/folds.json" \
--fold 0 \
--n-time-bins 12 \
--epochs 200 \
--rank-loss-weight 0.8 \
--weight-decay 1e-4 \
--knn-k-eval 10 \
--eval-edge-policy rewire_available \
--num-graph-layers 2 \
--device cuda:0 \
--out-dir "${OUT_BASE}/fold_0/graph_result/Melanoma/best/rk08wd1e4_rewire_available"Expected Stage-3 artifacts (per run directory):
best.pt,last.pttrain_metrics.csveval_summary.csv- optional
patient_predictions.csv(if--save-patient-predictions)
All baseline scripts consume the same exported embeddings:
bash run_coxph.shbash run_deepsurv.shbash run_deephit.sh
Each script writes to outputs/baselines/... and logs progress per dataset/fold.
run_graphs.shdoes not build kNN graphs; generate them first in Stage 2.- Most scripts hardcode
/home/azureuser/PITL; update these paths if needed.