secmalasct/survival.R
Jens Sauer 388e20673c survival: Add SM survival plot
Plot survival after SM diagnosis.
2021-01-17 15:27:15 +01:00

98 lines
3.0 KiB
R

# secMalASCT survival calculation
#
# License: GPL version 3
# Jens Mathis Sauer (c) 2020
source("utils.R")
sma_init()
# 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
sma_plot_surv_dx <- function() {
ggsurvplot(survfit(surv_dx ~ 1), data = secmal, xscale = "d_y",
title = "Survival after diagnosis",
break.time.by = sma_break.time.by,
surv.median.line = "hv",
risk.table = "abs_pct",
ggtheme = theme_bw())
}
# plot survival after diagnosis per sex
sma_plot_surv_dx_sex <- function() {
ggsurvplot(survfit(surv_dx ~ sex, data = secmal), data = secmal,
xscale = "d_y", title = "Survival after diagnosis",
legend.labs = c("Female", "Male"),
break.time.by = sma_break.time.by,
surv.median.line = "hv",
risk.table = "abs_pct",
ggtheme = theme_bw(),
pval = TRUE)
}
# plot survival after transplantation
sma_plot_surv_asct <- function() {
ggsurvplot(survfit(surv_asct ~ 1), data = secmal, xscale = "d_y",
break.time.by = sma_break.time.by,
surv.median.line = "hv",
risk.table = "abs_pct",
legend = "none",
xlab = "Years",
ggtheme = theme_bw())
}
# plot survival after transplantation per sex
sma_plot_surv_asct_sex <- function() {
ggsurvplot(survfit(surv_asct ~ sex, data = secmal), data = secmal,
xscale = "d_y", title = "Survival after transplantation",
legend.labs = c("Female", "Male"),
break.time.by = sma_break.time.by,
surv.median.line = "hv",
risk.table = "abs_pct",
ggtheme = theme_bw(),
pval = TRUE)
}
# plot survival after diagnosis per diagnosis
sma_plot_surv_dx_dx <- function() {
ggsurvplot(survfit(surv_dx ~ diagnosis, data = secmal), data = secmal,
xscale = "d_y", title = "Survival after diagnosis",
break.time.by = sma_break.time.by,
risk.table = "abs_pct",
ggtheme = theme_bw())
}
# plot survival after diagnosis per diagnosis
sma_plot_surv_asct_dx <- function() {
ggsurvplot(survfit(surv_asct ~ diagnosis, data = secmal), data = secmal,
xscale = "d_y", title = "Survival after transplantation",
break.time.by = sma_break.time.by,
risk.table = "abs_pct",
ggtheme = theme_bw())
}
# plot survival after SM diagnosis
sma_plot_surv_sm <- function() {
ggsurvplot(survfit(Surv(event_time_sm, event_status) ~ 1, secmal),
data = secmal, xscale = "d_y",
break.time.by = 365.25,
legend = "none",
xlab = "Years",
ggtheme = theme_bw())
}
#
# Write survival plots to files
#
sma_plot_file_surv <- function() {
sma_plot_file("survival_dx.png", png, sma_plot_surv_dx)
sma_plot_file("survival_dx_sex.png", png, sma_plot_surv_dx_sex)
sma_plot_file("survival_asct.png", png, sma_plot_surv_asct)
sma_plot_file("survival_asct_sex.png", png, sma_plot_surv_asct_sex)
sma_plot_file("survival_dx_dx.png", png, sma_plot_surv_dx_dx)
sma_plot_file("survival_asct_dx.png", png, sma_plot_surv_asct_dx)
sma_plot_file("survival_sm.png", png, sma_plot_surv_sm)
}