Mercurial > repos > testtool > survival
changeset 0:6cc0c5eb71b2 draft
Uploaded
author | testtool |
---|---|
date | Fri, 29 Sep 2017 18:11:27 -0400 |
parents | |
children | 5b70a33bf327 |
files | survival/._.DS_Store survival/._survival.xml survival/survival.R survival/survival.xml survival/test-data/._.DS_Store survival/test-data/fit.png survival/test-data/input.csv survival/test-data/survfit.csv |
diffstat | 8 files changed, 76 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/survival/survival.R Fri Sep 29 18:11:27 2017 -0400 @@ -0,0 +1,18 @@ +args <- commandArgs(trailingOnly = TRUE) + +input =args[1] +fit = args[2] +png = args[3] + +#fit a Kaplan-Meier and plot it +input<-("test-data/input.csv") +fit <- survfit(Surv(obsT, status) ~ X1, type="kaplan-meier", conf.type="log", data=read.csv(input)) + +res <- summary(fit,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, file = "survfit.csv") + +png("fit.png") +plot(fit) +dev.off() +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/survival/survival.xml Fri Sep 29 18:11:27 2017 -0400 @@ -0,0 +1,35 @@ +<tool id="survival" name="survival" version="1.0.0"> + <description>core survival analysis</description> + <requirements> + <requirement type="package" version="2.40_1">r-survival</requirement> + </requirements> + <command detect_errors="aggressive"> + Rscript '$__tool_directory__/survival.R' '$input' '$fit' '$png' + </command> +<inputs> + <param format="csv" type="data" name="input" value="" label="survival data" help="e.g. ''"/> + </inputs> + <outputs> + <data format="csv" name="fit" label="survfit.csv" /> + <data format="png" name="png" label="survfit.png" /> + </outputs> + <tests> + <test> + <param name="test"> + <element name="test-data"> + <collection type="data"> + <element format="csv" name="input" label="test-data/input.csv"/> + </collection> + </element> + </param> + <output format="csv" name="fit" label="test-data/survfit.csv"/> + <output fformat="png" name="png" label="test-data/survfit.png"/> + </test> + </tests> + <help> +**Contains the core survival analysis routines, including definition of Surv objects, Kaplan-Meier** +</help> +<citations> + <citation>https://CRAN.R-project.org/package=survival</citation> +</citations> +</tool>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/survival/test-data/input.csv Fri Sep 29 18:11:27 2017 -0400 @@ -0,0 +1,16 @@ +"","obsT","status","X1","X2" +"17",1815,FALSE,"2","HOXA1" +"18",145,TRUE,"1","HOXA1" +"19",2506,FALSE,"1","HOXA1" +"20",1382,TRUE,"1","HOXA1" +"21",2561,FALSE,"2","HOXA1" +"22",740,TRUE,"1","HOXA1" +"23",322,TRUE,"1","HOXA1" +"24",8,TRUE,"1","HOXA1" +"25",235,TRUE,"2","HOXA1" +"26",1430,FALSE,"1","HOXA1" +"27",22,TRUE,"1","HOXA1" +"28",214,TRUE,"1","HOXA1" +"30",277,TRUE,"1","HOXA1" +"31",1740,FALSE,"1","HOXA1" +"32",478,TRUE,"1","HOXA1"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/survival/test-data/survfit.csv Fri Sep 29 18:11:27 2017 -0400 @@ -0,0 +1,7 @@ +"","strata","time","n.risk","n.event","surv","std.err","lower","upper" +"1","X1=1",1,12,0,1,0,1,1 +"2","X1=1",2,12,0,1,0,1,1 +"3","X1=1",3,12,0,1,0,1,1 +"4","X1=2",1,3,0,1,0,1,1 +"5","X1=2",2,3,0,1,0,1,1 +"6","X1=2",3,3,0,1,0,1,1