1
|
1 require(survival, quietly = TRUE)
|
0
|
2 args <- commandArgs(trailingOnly = TRUE)
|
|
3
|
4
|
4 input = args[1]
|
|
5 type = args[2]
|
|
6 error = args[3]
|
20
|
7 conf_type = args[4]
|
|
8 conf_lower = args[5]
|
4
|
9 fit = args[6]
|
|
10 png = args[7]
|
0
|
11
|
20
|
12 tofit <- survival::survfit(Surv(obsT, status) ~ X1, type = type, error = error, conf.type = conf_type , conf.lower = conf_lower, data = read.csv(input))
|
0
|
13
|
2
|
14 res <- summary(tofit,times=c(1,2,3))
|
0
|
15 save.df <- as.data.frame(res[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")])
|
2
|
16 write.csv(save.df, fit)
|
0
|
17
|
2
|
18 png(png)
|
4
|
19 plot(tofit,xlab="Survival (days)", ylab="Survival", lwd=2,xlim=c(0,1900),ylim=c(0.3,1),col=c("red","blue"))
|
|
20 legend("topright",legend=c("low","high"),lty=c(1,1),
|
|
21 lwd=c(2.5,2.5),col=c("red","blue"))
|
0
|
22 dev.off()
|
|
23
|