Data Preview
Train
Validation
Test
Data File
Group Mapping
1. Data Structure Requirements
Your CSV file must contain:
- Time column: Numeric survival/follow-up time (e.g., days, months, years)
- Status column: Event indicator: 1 = event (death, relapse), 0 = censored. Other codings (Dead/Alive, 1/2) are auto-converted.
- At least one predictor variable (numeric or categorical)
- Optional: an ID column (will be auto-removed)
2. Import Methods & Example Data
Three data input formats are supported. Prepare your files according to the examples below:
Method A - Separate Train/Validation/Test Files
Upload three independent CSV files. Each file must have the same column names.
train.csv (example, 5 rows):
| patient_id | age | gender | tumor_size | grade | os_time | os_status |
|---|---|---|---|---|---|---|
| P001 | 62 | Male | 2.5 | High | 365 | 1 |
| P002 | 55 | Female | 1.8 | Low | 1095 | 0 |
| P003 | 70 | Male | 3.2 | High | 180 | 1 |
| P004 | 48 | Female | 1.2 | Low | 730 | 0 |
| P005 | 58 | Male | 2.0 | Low | 540 | 1 |
Note: Column names must be identical across all three files. Factor levels are automatically unified. The time and status columns should be the same in all files.
Method B - Single File + Group Mapping (B')
Upload one data file plus a two-column mapping file (ID, Group). The group labels are standardized automatically (train/val/test).
data.csv (example, 5 rows):
| patient_id | age | gender | tumor_size | grade | os_time | os_status |
|---|---|---|---|---|---|---|
| P001 | 62 | Male | 2.5 | High | 365 | 1 |
| P002 | 55 | Female | 1.8 | Low | 1095 | 0 |
| P003 | 70 | Male | 3.2 | High | 180 | 1 |
| P004 | 48 | Female | 1.2 | Low | 730 | 0 |
| P005 | 58 | Male | 2.0 | Low | 540 | 1 |
group_map.csv (2 columns):
| patient_id | group |
|---|---|
| P001 | train |
| P002 | train |
| P003 | validation |
| P004 | test |
| P005 | train |
Accepted group labels: train / training / tr / learn / fit -> train; val / validation / valid / dev / development -> val; test / testing / te / eval / evaluation / holdout -> test. Rows with IDs not found in the mapping are automatically assigned to train.
Method C - Single File with Auto-Split
Upload one CSV file. The app will randomly split it into train/validation/test by the ratios you specify (default 60:20:20).
data.csv (example, 5 rows):
| patient_id | age | gender | tumor_size | grade | os_time | os_status |
|---|---|---|---|---|---|---|
| P001 | 62 | Male | 2.5 | High | 365 | 1 |
| P002 | 55 | Female | 1.8 | Low | 1095 | 0 |
| P003 | 70 | Male | 3.2 | High | 180 | 1 |
| P004 | 48 | Female | 1.2 | Low | 730 | 0 |
| P005 | 58 | Male | 2.0 | Low | 540 | 1 |
Parameters: Train ratio, Validation ratio, Test ratio (must sum to <=1). Random seed is user-configurable (default 42) for reproducibility.
3. Workflow Steps
- Data Import: Load and split your data using one of the three methods above. Select time and status columns.
- Baseline Table: Descriptive statistics (continuous: mean+/-SD / median(IQR); categorical: n(%)) with P values for group differences.
- Univariate Cox: Single-factor Cox regression for each predictor. Outputs HR (95% CI) and p-value. Significant variables (P < threshold) are candidates for multivariate modeling.
- Multivariate Cox: Multivariable Cox regression with backward elimination (AIC). Outputs HR, C-index, and proportional hazards (PH) assumption test via Schoenfeld residuals.
- Nomogram: Visualize the prediction model using rms::cph(). Points are assigned to each variable level; total points are converted to survival probability at user-specified time points.
- KM Curve: Kaplan-Meier survival curves with log-rank test for group comparison. Includes risk table and optional 95% CI.
- Time ROC: Time-dependent ROC curves (timeROC package) at user-specified time points. AUC is computed for train/validation/test at each time point.
- DCA: Decision Curve Analysis at a specified survival time point. Evaluates net benefit across threshold probabilities.
- Calibration: Bootstrap calibration plot (rms::calibrate on cph object) and binned calibration for all datasets at a specified time point.
- Report: Generate a comprehensive HTML report with all results and methodology.
4. Variable Selection in Multivariate
By default, variables with P < threshold in univariate analysis are used. You can:
- Keep the default (auto-selected)
- Remove unwanted variables by unchecking them
- Add back non-significant variables by checking them
- Use 'Force Include' to ensure specific variables are always in the model
5. Time Points
SurvivalFlow uses time-dependent analyses (Time ROC, DCA, Calibration, Nomogram). You need to specify time points at which these analyses are evaluated. The time points should be in the same unit as your time column (e.g., if time is in days, use 365 for 1 year, 1095 for 3 years, 1825 for 5 years).
After data import, the app displays the range and median of your time variable to help you choose appropriate time points.
6. Tips
- Each step can be skipped by unchecking 'Execute this step'
- Results are saved in memory until you refresh the page
- Use 'Download All Results' to save everything as a ZIP file
- If a step fails, check the error message and adjust parameters
- Nomogram and Calibration use train set; Time ROC, DCA use all available datasets
- KM Curve only requires data import (independent of multivariate model)
- Categorical variables are auto-detected (character/factor or numeric with <=10 unique values)
- Status column: 1 = event (death/relapse), 0 = censored. Other codings are auto-converted.
7. Factor Variable Handling
When using separate files (Method A) or Group Mapping (Method B), factor levels are automatically unified across train/validation/test sets. This ensures consistent model predictions across all datasets.
8. References & Bibliography
The following references describe the statistical methods used in this application:
- Cox DR. Regression models and life-tables. J R Stat Soc Ser B. 1972;34(2):187-220. doi:10.1111/j.2517-6161.1972.tb00899.x
- Therneau TM, Grambsch PM. Modeling Survival Data: Extending the Cox Model. New York: Springer; 2000. doi:10.1007/978-1-4757-3294-8
- Harrell FE Jr. rms: Regression Modeling Strategies. R package version 6.7-1. 2024. https://CRAN.R-project.org/package=rms
- Harrell FE Jr, Lee KL, Mark DB. Multivariable prognostic models: issues in developing models, evaluating assumptions and adequacy, and measuring and reducing errors. Stat Med. 1996;15(4):361-387. doi:10.1002/(SICI)1097-0258(19960229)15:4<361::AID-SIM168>3.0.CO;2-4
- Grambsch PM, Therneau TM. Proportional hazards tests and diagnostics based on weighted residuals. Biometrika. 1994;81(3):515-526. doi:10.1093/biomet/81.3.515
- Kaplan EL, Meier P. Nonparametric estimation from incomplete observations. J Am Stat Assoc. 1958;53(282):457-481. doi:10.2307/2281868
- Mantel N. Evaluation of survival data and two new rank order statistics arising in its consideration. Cancer Chemother Rep. 1966;50(3):163-170.
- Blanche P, Dartigues JF, Jacqmin-Gadda H. Estimating and comparing time-dependent areas under receiver operating characteristic curves for censored event times with competing risks. Stat Med. 2013;32(30):5381-5397. doi:10.1002/sim.5956
- Iasonos A, Schrag D, Raj GV, Panageas KS. How to build and interpret a nomogram for cancer prognosis. J Clin Oncol. 2008;26(8):1364-1370. doi:10.1200/JCO.2007.12.9791
- Vickers AJ, Elkin EB. Decision curve analysis: a novel method for evaluating prediction models. Med Decis Making. 2006;26(6):565-574. doi:10.1177/0272989X06295361
- Vickers AJ, van Calster B, Steyerberg EW. A simple, step-by-step guide to interpreting decision curve analysis. Diagn Progn Res. 2019;3:18. doi:10.1186/s41512-019-0064-7
- Steyerberg EW, Vickers AJ, Cook NR, et al. Assessing the performance of prediction models: a framework for traditional and novel measures. Epidemiology. 2010;21(1):128-138. doi:10.1097/EDE.0b013e3181c30fb2
Version: 1.0.0 | Author: math81.com