view survival/survival.R @ 19:d95c8e3b24e7 draft

Uploaded
author testtool
date Mon, 02 Oct 2017 08:44:25 -0400
parents 744cf0f4d1b1
children b4d7a110dd32
line wrap: on
line source

require(survival, quietly = TRUE)
args <- commandArgs(trailingOnly = TRUE)

input = args[1]
type = args[2]
error = args[3]
conf.type = args[4]
conf.lower = args[5]
fit = args[6]
png = args[7]

tofit <- survival::survfit(Surv(obsT, status) ~ X1, type = type, error = error, conf.type = conf.type , conf.lower = conf.lower, data = read.csv(input))

res <- summary(tofit,times=c(1,2,3))
save.df <- as.data.frame(res[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")])
write.csv(save.df, fit)

png(png)
plot(tofit,xlab="Survival (days)", ylab="Survival", lwd=2,xlim=c(0,1900),ylim=c(0.3,1),col=c("red","blue"))
legend("topright",legend=c("low","high"),lty=c(1,1), 
       lwd=c(2.5,2.5),col=c("red","blue"))
dev.off()