Skip to contents

Introduction

This vignette demonstrates survival analysis capabilities of the jSurvival module using real oncology datasets from the OncoDataSets package. We’ll cover Kaplan-Meier analysis, Cox regression, competing risks, and advanced survival modeling.

Example 1: Melanoma Survival Analysis

The Melanoma dataset contains survival times and prognostic factors for melanoma patients.

data("Melanoma_df")

# Dataset overview
str(Melanoma_df)

# Create meaningful labels
Melanoma_df$status_label <- factor(Melanoma_df$status,
                                   levels = c(1, 2, 3),
                                   labels = c("Died from melanoma", 
                                             "Alive", 
                                             "Died from other causes"))

Melanoma_df$sex_label <- factor(Melanoma_df$sex,
                               levels = c(0, 1),
                               labels = c("Female", "Male"))

Melanoma_df$ulcer_label <- factor(Melanoma_df$ulcer,
                                 levels = c(0, 1),
                                 labels = c("No", "Yes"))

# Summary of survival times
summary(Melanoma_df$time)
table(Melanoma_df$status_label)

Kaplan-Meier Analysis by Sex

# In jamovi:
# 1. Select Analyses → jSurvival → Survival Analysis
# 2. Set 'time' as survival time
# 3. Set 'status' as event (with 1 = died from melanoma)
# 4. Add 'sex_label' as grouping factor
# 5. Enable confidence intervals
# 6. Request median survival times
# 7. Add risk table

Cox Proportional Hazards Model

Analyze multiple prognostic factors simultaneously:

# In jamovi:
# 1. Select Analyses → jSurvival → Survival Analysis
# 2. Set up time and status as before
# 3. Add covariates: age, sex, thickness, ulcer
# 4. Enable Cox regression
# 5. Request hazard ratios with 95% CI
# 6. Check proportional hazards assumption

Competing Risks Analysis

Since patients can die from other causes:

# In jamovi:
# 1. Select Analyses → jSurvival → Competing Risks
# 2. Set 'time' as survival time
# 3. Set 'status' with:
#    - 0 = censored
#    - 1 = died from melanoma
#    - 3 = died from other causes
# 4. Analyze by ulceration status
# 5. Request cumulative incidence plots

Example 2: Leukemia Treatment Comparison

data("LeukemiaSurvival_df")

# Dataset structure
str(LeukemiaSurvival_df)

# Create treatment labels
LeukemiaSurvival_df$treatment <- factor(LeukemiaSurvival_df$rx,
                                        levels = c(0, 1),
                                        labels = c("Control", "Treatment"))

# Summary by treatment
table(LeukemiaSurvival_df$treatment, LeukemiaSurvival_df$status)

Treatment Effect Analysis

# In jamovi:
# 1. Select Analyses → jSurvival → Survival Analysis
# 2. Time variable: 'time'
# 3. Event variable: 'status'
# 4. Group by: 'treatment'
# 5. Enable log-rank test
# 6. Add stratification by 'sex' if needed
# 7. Request survival probability table at key timepoints

Continuous Covariate Analysis

Analyze the effect of white blood cell count:

# In jamovi:
# 1. Use Survival (Continuous) analysis
# 2. Add 'logWBC' as continuous predictor
# 3. Enable spline fitting for non-linear effects
# 4. Request partial effects plot
# 5. Test for interactions with treatment

Example 3: Prostate Cancer with Multiple Factors

data("ProstateSurvival_df")

# Large dataset overview
dim(ProstateSurvival_df)
table(ProstateSurvival_df$grade, ProstateSurvival_df$stage)

# Survival overview
summary(ProstateSurvival_df$survTime)
table(ProstateSurvival_df$status)

Stratified Analysis

# In jamovi:
# 1. Select Analyses → jSurvival → Survival Analysis
# 2. Basic setup with survTime and status
# 3. Compare by 'grade' (moderate vs poor)
# 4. Stratify by 'stage' and 'ageGroup'
# 5. Enable subset analysis for specific age groups
# 6. Request 1, 3, and 5-year survival rates

Multivariate Cox Model

# In jamovi:
# 1. Cox regression with multiple predictors
# 2. Include: grade, stage, ageGroup
# 3. Test all two-way interactions
# 4. Use stepwise selection if needed
# 5. Generate forest plot of hazard ratios

Example 4: Lung Cancer NCCTG Trial

data("NCCTGLungCancer_df")

# Dataset with missing values
str(NCCTGLungCancer_df)

# Performance status distribution
table(NCCTGLungCancer_df$ph.ecog, useNA = "ifany")

Handling Missing Data

# In jamovi:
# 1. Use Survival Analysis with missing data options
# 2. Choose complete case analysis or imputation
# 3. Compare results with and without missing values
# 4. Document missing data patterns

Time-Dependent Effects

# In jamovi:
# 1. Select Cox Diagnostics
# 2. Test for time-dependent effects
# 3. Plot Schoenfeld residuals
# 4. Consider time-varying coefficients if needed

Example 5: Ovarian Cancer Trial

data("OvarianCancer_df")

# Small dataset suitable for detailed analysis
str(OvarianCancer_df)

# Treatment groups
table(OvarianCancer_df$rx)

Sample Size and Power

# In jamovi:
# 1. Select Analyses → jSurvival → Survival Power
# 2. Input observed effect size from pilot data
# 3. Calculate power for different sample sizes
# 4. Plan for future trials

Advanced Features

Survival Curves Comparison

# Multiple methods available:
# 1. Log-rank test (equal weights)
# 2. Wilcoxon test (early differences)
# 3. Tarone-Ware (compromise)
# 4. Peto-Peto (another compromise)
# 5. Fleming-Harrington (flexible weighting)

Reporting Guidelines

  1. CONSORT Diagram: Track patient flow and censoring
  2. Median Follow-up: Report using reverse Kaplan-Meier
  3. Assumptions: Always check and report
  4. Missing Data: Document handling methods
  5. Effect Sizes: Report HRs with confidence intervals

Practical Workflow Example

# Complete survival analysis workflow:

# 1. Data Preparation
#    - Import data
#    - Create survival time and event variables
#    - Handle competing events

# 2. Descriptive Analysis
#    - Summary of follow-up times
#    - Event rates by group
#    - Missing data patterns

# 3. Kaplan-Meier Analysis
#    - Overall survival curves
#    - Stratified analyses
#    - Median survival times

# 4. Cox Regression
#    - Univariate screening
#    - Multivariate model
#    - Assumption checking

# 5. Advanced Analyses
#    - Competing risks if applicable
#    - Time-dependent covariates
#    - Sensitivity analyses

# 6. Reporting
#    - Generate publication figures
#    - Create summary tables
#    - Export results

Integration with Clinical Research

Example: Prognostic Model Development

# Using melanoma data:
# 1. Split data into training/validation
# 2. Develop Cox model on training set
# 3. Calculate risk scores
# 4. Validate on test set
# 5. Create risk groups (low/medium/high)
# 6. Generate clinical nomogram

Best Practices

  1. Define Events Clearly: Specify primary endpoint
  2. Handle Censoring: Document reasons for censoring
  3. Check Assumptions: Test proportional hazards
  4. Report Fully: Follow STROBE guidelines
  5. Consider Competing Risks: Especially in elderly populations

Conclusion

The jSurvival module provides comprehensive tools for analyzing time-to-event data in oncology research. Combined with the OncoDataSets package, researchers can:

  • Perform standard and advanced survival analyses
  • Handle complex scenarios like competing risks
  • Generate publication-quality figures
  • Develop and validate prognostic models

References