secmalasct/survival.R
Jens Sauer 439810a544 survival: Replace manual plotting with sma_plot_file
Replace the manual plotting definitions with the new function to reduce
repitition.
2020-10-22 18:46:30 +02:00

66 lines
1.7 KiB
R

# secMalASCT survival calculation
#
# License: GPL version 3
# Jens Mathis Sauer (c) 2020
library(survival)
source("utils.R")
secmal <- read.csv2("current.csv", header=TRUE)
# Setup survival object
surv_dx <- Surv(time = secmal$event_time_dx, event = secmal$event_status)
surv_asct <- Surv(time = secmal$event_time_asct, event = secmal$event_status)
# plot survival after diagnosis
# scaled to years
sma_plot_file("survival_dx.png", png,
list(main = "Kaplan-Meier estimate for\nsecMalASCT study",
sub = "Survival after diagnosis"),
NULL,
plot, survfit(surv_dx ~ 1),
mark.time = TRUE,
xscale = 365.25,
xlab = "Years",
ylab = "Survival")
# One graph per sex
sma_plot_file("survival_dx_sex.png", png,
list(main = "Kaplan-Meier estimate for\nsecMalASCT study",
sub = "Survival after diagnosis"),
list(100, .9, c("Female", "Male"), lty = 2:3),
plot, survfit(surv_dx ~ sex, data = secmal),
mark.time = TRUE,
xscale = 365.25,
xlab = "Years",
ylab = "Survival",
lty = 2:3)
# plot survival after diagnosis
# scaled to years
sma_plot_file("survival_asct.png", png,
list(main = "Kaplan-Meier estimate for\nsecMalASCT study",
sub = "Survival after transplantation"),
NULL,
plot, survfit(surv_asct ~ 1),
mark.time = TRUE,
xscale = 365.25,
xlab = "Years",
ylab = "Survival")
# One graph per sex
sma_plot_file("survival_asct_sex.png", png,
list(main = "Kaplan-Meier estimate for\nsecMalASCT study",
sub = "Survival after transplantation"),
list(100, .9, c("Female", "Male"), lty = 2:3),
plot, survfit(surv_asct ~ sex, data = secmal),
mark.time = TRUE,
xscale = 365.25,
xlab = "Years",
ylab = "Survival",
lty = 2:3)