annotate survival/survival.R @ 31:ef13fa666e0e draft default tip

Uploaded
author testtool
date Tue, 03 Oct 2017 09:40:44 -0400
parents b4d7a110dd32
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
5b70a33bf327 Uploaded
testtool
parents: 0
diff changeset
1 require(survival, quietly = TRUE)
0
6cc0c5eb71b2 Uploaded
testtool
parents:
diff changeset
2 args <- commandArgs(trailingOnly = TRUE)
6cc0c5eb71b2 Uploaded
testtool
parents:
diff changeset
3
4
744cf0f4d1b1 Uploaded
testtool
parents: 2
diff changeset
4 input = args[1]
744cf0f4d1b1 Uploaded
testtool
parents: 2
diff changeset
5 type = args[2]
744cf0f4d1b1 Uploaded
testtool
parents: 2
diff changeset
6 error = args[3]
20
b4d7a110dd32 Uploaded
testtool
parents: 4
diff changeset
7 conf_type = args[4]
b4d7a110dd32 Uploaded
testtool
parents: 4
diff changeset
8 conf_lower = args[5]
4
744cf0f4d1b1 Uploaded
testtool
parents: 2
diff changeset
9 fit = args[6]
744cf0f4d1b1 Uploaded
testtool
parents: 2
diff changeset
10 png = args[7]
0
6cc0c5eb71b2 Uploaded
testtool
parents:
diff changeset
11
20
b4d7a110dd32 Uploaded
testtool
parents: 4
diff changeset
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
6cc0c5eb71b2 Uploaded
testtool
parents:
diff changeset
13
2
ce6df2bd21cd Uploaded
testtool
parents: 1
diff changeset
14 res <- summary(tofit,times=c(1,2,3))
0
6cc0c5eb71b2 Uploaded
testtool
parents:
diff changeset
15 save.df <- as.data.frame(res[c("strata", "time", "n.risk", "n.event", "surv", "std.err", "lower", "upper")])
2
ce6df2bd21cd Uploaded
testtool
parents: 1
diff changeset
16 write.csv(save.df, fit)
0
6cc0c5eb71b2 Uploaded
testtool
parents:
diff changeset
17
2
ce6df2bd21cd Uploaded
testtool
parents: 1
diff changeset
18 png(png)
31
ef13fa666e0e Uploaded
testtool
parents: 20
diff changeset
19 plot(tofit,xlab="Time", ylab="Survival", lwd=2,xlim=c(0,1900),ylim=c(0.3,1),col=c("red","blue"))
4
744cf0f4d1b1 Uploaded
testtool
parents: 2
diff changeset
20 legend("topright",legend=c("low","high"),lty=c(1,1),
744cf0f4d1b1 Uploaded
testtool
parents: 2
diff changeset
21 lwd=c(2.5,2.5),col=c("red","blue"))
0
6cc0c5eb71b2 Uploaded
testtool
parents:
diff changeset
22 dev.off()
6cc0c5eb71b2 Uploaded
testtool
parents:
diff changeset
23