Mercurial > repos > testtool > survival
comparison survival/survival.R @ 4:744cf0f4d1b1 draft
Uploaded
author | testtool |
---|---|
date | Mon, 02 Oct 2017 07:54:25 -0400 |
parents | ce6df2bd21cd |
children | b4d7a110dd32 |
comparison
equal
deleted
inserted
replaced
3:e31c47bf46a4 | 4:744cf0f4d1b1 |
---|---|
1 require(survival, quietly = TRUE) | 1 require(survival, quietly = TRUE) |
2 args <- commandArgs(trailingOnly = TRUE) | 2 args <- commandArgs(trailingOnly = TRUE) |
3 | 3 |
4 input =args[1] | 4 input = args[1] |
5 fit = args[2] | 5 type = args[2] |
6 png = args[3] | 6 error = args[3] |
7 conf.type = args[4] | |
8 conf.lower = args[5] | |
9 fit = args[6] | |
10 png = args[7] | |
7 | 11 |
8 tofit <- survival::survfit(Surv(obsT, status) ~ X1, type="kaplan-meier", conf.type="log", data=read.csv(input)) | 12 tofit <- survival::survfit(Surv(obsT, status) ~ X1, type = type, error = error, conf.type = conf.type , conf.lower = conf.lower, data = read.csv(input)) |
9 | 13 |
10 res <- summary(tofit,times=c(1,2,3)) | 14 res <- summary(tofit,times=c(1,2,3)) |
11 save.df <- as.data.frame(res[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")]) | 15 save.df <- as.data.frame(res[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")]) |
12 write.csv(save.df, fit) | 16 write.csv(save.df, fit) |
13 | 17 |
14 png(png) | 18 png(png) |
15 plot(tofit) | 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")) | |
16 dev.off() | 22 dev.off() |
17 | 23 |