From e4cead5e99c5a4fd4e4877b0b34d63ca6ff52436 Mon Sep 17 00:00:00 2001 From: Jens Sauer Date: Thu, 3 Sep 2020 16:39:44 +0200 Subject: [PATCH] First version of survival calculation This adds a R script which calculates the survival starting at diagnosis and autologous stem cell therapy. --- survival.R | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 survival.R diff --git a/survival.R b/survival.R new file mode 100644 index 0000000..e5ab0aa --- /dev/null +++ b/survival.R @@ -0,0 +1,39 @@ +# secMalASCT survival calculation +# +# License: GPL version 3 +# Jens Mathis Sauer (c) 2020 + +library(survival) +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 +png(filename = "survival_dx.png", width = 3000, height = 3000, res = 300) +plot(survfit(surv_dx ~ 1), mark.time = TRUE, xscale = 12, xlab = "Years", ylab = "Survival") +title("Kaplan-Meier estimate for\nsecMalASCT study", "Survival after diagnosis") +dev.off() + +# One graph per sex +png(filename = "survival_dx_sex.png", width = 3000, height = 3000, res = 300) +plot(survfit(surv_dx ~ sex, data = secmal), mark.time = TRUE, xscale = 12, xlab = "Years", ylab = "Survival", lty = 2:3) +title("Kaplan-Meier estimate for\nsecMalASCT study", "Survival after diagnosis") +legend(100, .9, c("Female", "Male"), lty = 2:3) +dev.off() + +# plot survival after diagnosis +# scaled to years +png(file = "survival_asct.png", width = 3000, height = 3000, res = 300) +plot(survfit(surv_asct ~ 1), mark.time = TRUE, xscale = 12, xlab = "Years", ylab = "Survival") +title("Kaplan-Meier estimate for\nsecMalASCT study", "Survival after transplantation") +dev.off() + +# One graph per sex +png(filename = "survival_asct_sex.png", width = 3000, height = 3000, res = 300) +plot(survfit(surv_asct ~ sex, data = secmal), mark.time = TRUE, xscale = 12, xlab = "Years", ylab = "Survival", lty = 2:3) +title("Kaplan-Meier estimate for\nsecMalASCT study", "Survival after transplantation") +legend(100, .9, c("Female", "Male"), lty = 2:3) +dev.off()