Repository navigation
Expand file tree
/
Copy pathsurvivalforestscript.R
More file actions
executable file
·195 lines (134 loc) · 17.4 KB
/
Copy pathsurvivalforestscript.R
File metadata and controls
executable file
·195 lines (134 loc) · 17.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Usage: Rscript survivalforestscript.R
# Usage: source("survivalforestscript.R")
#
# Rattle is Copyright (c) 2006-2015 Togaware Pty Ltd.
#============================================================
# Rattle timestamp: 2017-08-23 11:12:38 x86_64-pc-linux-gnu
# Rattle version 4.1.0 user 'fuentes'
# This log file captures all Rattle interactions as R commands.
#Export this log to a file using the Export button or the Tools
# menu to save a log of all your activity. This facilitates repeatability. For example, exporting
# to a file called 'myrf01.R' will allow you to type in the R Console
# the command source('myrf01.R') and so repeat all actions automatically.
# Generally, you will want to edit the file to suit your needs. You can also directly
# edit this current log in place to record additional information before exporting.
# Saving and loading projects also retains this log.
# We begin by loading the required libraries.
library(rattle) # To access the weather dataset and utility commands.
#library(magrittr) # For the %>% and %<>% operators.
# This log generally records the process of building a model. However, with very
# little effort the log can be used to score a new dataset. The logical variable
# 'building' is used to toggle between generating transformations, as when building
# a model, and simply using the transformations, as when scoring a dataset.
building <- TRUE
scoring <- ! building
# A pre-defined value is used to reset the random seed so that results are repeatable.
crv$seed <- 42
#============================================================
# Rattle timestamp: 2017-08-23 11:13:00 x86_64-pc-linux-gnu
# Load the data.
crs$dataset <- read.csv("file:///rsrch1/ip/dtfuentes/github/RandomForestHCCResponse/datalocation/gmmdatamatrixfixed22Aug2017_Greg_edited.csv", na.strings=c(".", "NA", "", "?"), strip.white=TRUE, encoding="UTF-8")
print(nrow(crs$dataset))
# subset on baseline only
crs$dataset <- subset(crs$dataset,liver_TimeID=="baseline")
print(nrow(crs$dataset))
#============================================================
# Rattle timestamp: 2017-08-23 11:49:29 x86_64-pc-linux-gnu
# Note the user selections.
# Build the training/validate/test datasets.
set.seed(crv$seed)
crs$nobs <- nrow(crs$dataset) # 211 observations
crs$sample <- crs$train <- sample(nrow(crs$dataset), 0.8*crs$nobs) # 168 observations
crs$validate <- NULL
crs$test <- setdiff(setdiff(seq_len(nrow(crs$dataset)), crs$train), crs$validate) # 43 observations
# The following variable selections have been noted.
crs$input <- c("liver_gender", "liver_smoking", "liver_AFP", "liver_BCLC",
"liver_Volume", "liver_Pre_DENOISE", "liver_Art_DENOISE", "liver_Ven_DENOISE",
"liver_Del_DENOISE", "liver_Pre_GRADIENT", "liver_Art_GRADIENT", "liver_Ven_GRADIENT",
"liver_Del_GRADIENT", "liver_Pre_MEAN_RADIUS_1", "liver_Art_MEAN_RADIUS_1", "liver_Ven_MEAN_RADIUS_1",
"liver_Del_MEAN_RADIUS_1", "liver_Pre_SIGMA_RADIUS_1", "liver_Art_SIGMA_RADIUS_1", "liver_Ven_SIGMA_RADIUS_1",
"liver_Del_SIGMA_RADIUS_1", "necrosis_Volume", "necrosis_Pre_DENOISE", "necrosis_Art_DENOISE",
"necrosis_Ven_DENOISE", "necrosis_Del_DENOISE", "necrosis_Pre_GRADIENT", "necrosis_Art_GRADIENT",
"necrosis_Ven_GRADIENT", "necrosis_Del_GRADIENT", "necrosis_Pre_MEAN_RADIUS_1", "necrosis_Art_MEAN_RADIUS_1",
"necrosis_Ven_MEAN_RADIUS_1", "necrosis_Del_MEAN_RADIUS_1", "necrosis_Pre_SIGMA_RADIUS_1", "necrosis_Art_SIGMA_RADIUS_1",
"necrosis_Ven_SIGMA_RADIUS_1", "necrosis_Del_SIGMA_RADIUS_1", "viable_Volume", "viable_Pre_DENOISE",
"viable_Art_DENOISE", "viable_Ven_DENOISE", "viable_Del_DENOISE", "viable_Pre_GRADIENT",
"viable_Art_GRADIENT", "viable_Ven_GRADIENT", "viable_Del_GRADIENT", "viable_Pre_MEAN_RADIUS_1",
"viable_Art_MEAN_RADIUS_1", "viable_Ven_MEAN_RADIUS_1", "viable_Del_MEAN_RADIUS_1", "viable_Pre_SIGMA_RADIUS_1",
"viable_Art_SIGMA_RADIUS_1", "viable_Ven_SIGMA_RADIUS_1", "viable_Del_SIGMA_RADIUS_1")
crs$numeric <- c("liver_AFP", "liver_Volume", "liver_Pre_DENOISE", "liver_Art_DENOISE",
"liver_Ven_DENOISE", "liver_Del_DENOISE", "liver_Pre_GRADIENT", "liver_Art_GRADIENT",
"liver_Ven_GRADIENT", "liver_Del_GRADIENT", "liver_Pre_MEAN_RADIUS_1", "liver_Art_MEAN_RADIUS_1",
"liver_Ven_MEAN_RADIUS_1", "liver_Del_MEAN_RADIUS_1", "liver_Pre_SIGMA_RADIUS_1", "liver_Art_SIGMA_RADIUS_1",
"liver_Ven_SIGMA_RADIUS_1", "liver_Del_SIGMA_RADIUS_1", "necrosis_Volume", "necrosis_Pre_DENOISE",
"necrosis_Art_DENOISE", "necrosis_Ven_DENOISE", "necrosis_Del_DENOISE", "necrosis_Pre_GRADIENT",
"necrosis_Art_GRADIENT", "necrosis_Ven_GRADIENT", "necrosis_Del_GRADIENT", "necrosis_Pre_MEAN_RADIUS_1",
"necrosis_Art_MEAN_RADIUS_1", "necrosis_Ven_MEAN_RADIUS_1", "necrosis_Del_MEAN_RADIUS_1", "necrosis_Pre_SIGMA_RADIUS_1",
"necrosis_Art_SIGMA_RADIUS_1", "necrosis_Ven_SIGMA_RADIUS_1", "necrosis_Del_SIGMA_RADIUS_1", "viable_Volume",
"viable_Pre_DENOISE", "viable_Art_DENOISE", "viable_Ven_DENOISE", "viable_Del_DENOISE",
"viable_Pre_GRADIENT", "viable_Art_GRADIENT", "viable_Ven_GRADIENT", "viable_Del_GRADIENT",
"viable_Pre_MEAN_RADIUS_1", "viable_Art_MEAN_RADIUS_1", "viable_Ven_MEAN_RADIUS_1", "viable_Del_MEAN_RADIUS_1",
"viable_Pre_SIGMA_RADIUS_1", "viable_Art_SIGMA_RADIUS_1", "viable_Ven_SIGMA_RADIUS_1", "viable_Del_SIGMA_RADIUS_1")
crs$categoric <- c("liver_gender", "liver_smoking", "liver_BCLC")
crs$target <- "liver_TTP"
crs$risk <- "liver_CensorModality"
crs$ident <- NULL
crs$ignore <- c("studyUID.liver_dataID", "liver_LesionNumber", "liver_LobeLocation", "liver_SegmentLocation", "liver_ChemoUsed", "liver_WeeksBetweenBLandTACE", "liver_TreatmentDose", "liver_hepatitis", "liver_age", "liver_alcohol", "liver_Cirrhosis", "liver_Pathology", "liver_Vascular", "liver_Metastasis", "liver_Lymphnodes", "liver_Thrombosis", "liver_FirstLineTherapy", "liver_MVIStatus", "liver_PNPLA3", "liver_PNPLA73", "liver_pnpl2", "liver_TTPTraining", "liver_Survival", "liver_LabelTraining", "liver_AFPGroup", "liver_CLIPScore", "liver_CLIP", "liver_Okuda", "liver_TNM", "liver_CensorStatus", "liver_FirstTACESession", "liver_StatusShift", "liver_StatusDate", "liver_deathdate", "liver_CensorDead", "liver_DxDateBiopsy", "liver_NoInfection", "liver_HBValone0", "liver_HCValone0", "liver_age60", "liver_SexM1F0", "liver_Smoking_status", "liver_Alcohol_status", "liver_fhx_can", "liver_fhx_livc", "liver_Diabetes_status", "liver_Personal_Hx", "liver_Evidence_of_cirrhosis", "liver_Poorly_differentiated", "liver_tumor_nodul", "liver_Vascular_invasion", "liver_Mets", "liver_LNs", "liver_PV_Thrombosis", "liver_T_involvment50", "liver_AFP_group400", "liver_CLIP_02_2_36_1", "liver_OKUDA1_23", "liver_TNM12_34", "liver_BCLC_AB2_CD1", "liver_TimeID", "liver_MorshidQA", "liver_Status", "liver_StudyUID", "liver_labellocation", "liver_Pre_RAWIMAGE", "liver_Art_RAWIMAGE", "liver_Ven_RAWIMAGE", "liver_Del_RAWIMAGE", "liver_Pre_ATROPOS_GMM_POSTERIORS1", "liver_Art_ATROPOS_GMM_POSTERIORS1", "liver_Ven_ATROPOS_GMM_POSTERIORS1", "liver_Del_ATROPOS_GMM_POSTERIORS1", "liver_Pre_ATROPOS_GMM_POSTERIORS2", "liver_Art_ATROPOS_GMM_POSTERIORS2", "liver_Ven_ATROPOS_GMM_POSTERIORS2", "liver_Del_ATROPOS_GMM_POSTERIORS2", "liver_Pre_ATROPOS_GMM_POSTERIORS3", "liver_Art_ATROPOS_GMM_POSTERIORS3", "liver_Ven_ATROPOS_GMM_POSTERIORS3", "liver_Del_ATROPOS_GMM_POSTERIORS3", "liver_Pre_ATROPOS_GMM_LABEL1_DISTANCE", "liver_Art_ATROPOS_GMM_LABEL1_DISTANCE", "liver_Ven_ATROPOS_GMM_LABEL1_DISTANCE", "liver_Del_ATROPOS_GMM_LABEL1_DISTANCE", "liver_Pre_MEAN_RADIUS_3", "liver_Art_MEAN_RADIUS_3", "liver_Ven_MEAN_RADIUS_3", "liver_Del_MEAN_RADIUS_3", "liver_Pre_MEAN_RADIUS_5", "liver_Art_MEAN_RADIUS_5", "liver_Ven_MEAN_RADIUS_5", "liver_Del_MEAN_RADIUS_5", "liver_Pre_SIGMA_RADIUS_3", "liver_Art_SIGMA_RADIUS_3", "liver_Ven_SIGMA_RADIUS_3", "liver_Del_SIGMA_RADIUS_3", "liver_Pre_SIGMA_RADIUS_5", "liver_Art_SIGMA_RADIUS_5", "liver_Ven_SIGMA_RADIUS_5", "liver_Del_SIGMA_RADIUS_5", "liver_Pre_SKEWNESS_RADIUS_1", "liver_Art_SKEWNESS_RADIUS_1", "liver_Ven_SKEWNESS_RADIUS_1", "liver_Del_SKEWNESS_RADIUS_1", "liver_Pre_SKEWNESS_RADIUS_3", "liver_Art_SKEWNESS_RADIUS_3", "liver_Ven_SKEWNESS_RADIUS_3", "liver_Del_SKEWNESS_RADIUS_3", "liver_Pre_SKEWNESS_RADIUS_5", "liver_Art_SKEWNESS_RADIUS_5", "liver_Ven_SKEWNESS_RADIUS_5", "liver_Del_SKEWNESS_RADIUS_5", "necrosis_Pre_RAWIMAGE", "necrosis_Art_RAWIMAGE", "necrosis_Ven_RAWIMAGE", "necrosis_Del_RAWIMAGE", "necrosis_Pre_ATROPOS_GMM_POSTERIORS1", "necrosis_Art_ATROPOS_GMM_POSTERIORS1", "necrosis_Ven_ATROPOS_GMM_POSTERIORS1", "necrosis_Del_ATROPOS_GMM_POSTERIORS1", "necrosis_Pre_ATROPOS_GMM_POSTERIORS2", "necrosis_Art_ATROPOS_GMM_POSTERIORS2", "necrosis_Ven_ATROPOS_GMM_POSTERIORS2", "necrosis_Del_ATROPOS_GMM_POSTERIORS2", "necrosis_Pre_ATROPOS_GMM_POSTERIORS3", "necrosis_Art_ATROPOS_GMM_POSTERIORS3", "necrosis_Ven_ATROPOS_GMM_POSTERIORS3", "necrosis_Del_ATROPOS_GMM_POSTERIORS3", "necrosis_Pre_ATROPOS_GMM_LABEL1_DISTANCE", "necrosis_Art_ATROPOS_GMM_LABEL1_DISTANCE", "necrosis_Ven_ATROPOS_GMM_LABEL1_DISTANCE", "necrosis_Del_ATROPOS_GMM_LABEL1_DISTANCE", "necrosis_Pre_MEAN_RADIUS_3", "necrosis_Art_MEAN_RADIUS_3", "necrosis_Ven_MEAN_RADIUS_3", "necrosis_Del_MEAN_RADIUS_3", "necrosis_Pre_MEAN_RADIUS_5", "necrosis_Art_MEAN_RADIUS_5", "necrosis_Ven_MEAN_RADIUS_5", "necrosis_Del_MEAN_RADIUS_5", "necrosis_Pre_SIGMA_RADIUS_3", "necrosis_Art_SIGMA_RADIUS_3", "necrosis_Ven_SIGMA_RADIUS_3", "necrosis_Del_SIGMA_RADIUS_3", "necrosis_Pre_SIGMA_RADIUS_5", "necrosis_Art_SIGMA_RADIUS_5", "necrosis_Ven_SIGMA_RADIUS_5", "necrosis_Del_SIGMA_RADIUS_5", "necrosis_Pre_SKEWNESS_RADIUS_1", "necrosis_Art_SKEWNESS_RADIUS_1", "necrosis_Ven_SKEWNESS_RADIUS_1", "necrosis_Del_SKEWNESS_RADIUS_1", "necrosis_Pre_SKEWNESS_RADIUS_3", "necrosis_Art_SKEWNESS_RADIUS_3", "necrosis_Ven_SKEWNESS_RADIUS_3", "necrosis_Del_SKEWNESS_RADIUS_3", "necrosis_Pre_SKEWNESS_RADIUS_5", "necrosis_Art_SKEWNESS_RADIUS_5", "necrosis_Ven_SKEWNESS_RADIUS_5", "necrosis_Del_SKEWNESS_RADIUS_5", "viable_Pre_RAWIMAGE", "viable_Art_RAWIMAGE", "viable_Ven_RAWIMAGE", "viable_Del_RAWIMAGE", "viable_Pre_ATROPOS_GMM_POSTERIORS1", "viable_Art_ATROPOS_GMM_POSTERIORS1", "viable_Ven_ATROPOS_GMM_POSTERIORS1", "viable_Del_ATROPOS_GMM_POSTERIORS1", "viable_Pre_ATROPOS_GMM_POSTERIORS2", "viable_Art_ATROPOS_GMM_POSTERIORS2", "viable_Ven_ATROPOS_GMM_POSTERIORS2", "viable_Del_ATROPOS_GMM_POSTERIORS2", "viable_Pre_ATROPOS_GMM_POSTERIORS3", "viable_Art_ATROPOS_GMM_POSTERIORS3", "viable_Ven_ATROPOS_GMM_POSTERIORS3", "viable_Del_ATROPOS_GMM_POSTERIORS3", "viable_Pre_ATROPOS_GMM_LABEL1_DISTANCE", "viable_Art_ATROPOS_GMM_LABEL1_DISTANCE", "viable_Ven_ATROPOS_GMM_LABEL1_DISTANCE", "viable_Del_ATROPOS_GMM_LABEL1_DISTANCE", "viable_Pre_MEAN_RADIUS_3", "viable_Art_MEAN_RADIUS_3", "viable_Ven_MEAN_RADIUS_3", "viable_Del_MEAN_RADIUS_3", "viable_Pre_MEAN_RADIUS_5", "viable_Art_MEAN_RADIUS_5", "viable_Ven_MEAN_RADIUS_5", "viable_Del_MEAN_RADIUS_5", "viable_Pre_SIGMA_RADIUS_3", "viable_Art_SIGMA_RADIUS_3", "viable_Ven_SIGMA_RADIUS_3", "viable_Del_SIGMA_RADIUS_3", "viable_Pre_SIGMA_RADIUS_5", "viable_Art_SIGMA_RADIUS_5", "viable_Ven_SIGMA_RADIUS_5", "viable_Del_SIGMA_RADIUS_5", "viable_Pre_SKEWNESS_RADIUS_1", "viable_Art_SKEWNESS_RADIUS_1", "viable_Ven_SKEWNESS_RADIUS_1", "viable_Del_SKEWNESS_RADIUS_1", "viable_Pre_SKEWNESS_RADIUS_3", "viable_Art_SKEWNESS_RADIUS_3", "viable_Ven_SKEWNESS_RADIUS_3", "viable_Del_SKEWNESS_RADIUS_3", "viable_Pre_SKEWNESS_RADIUS_5", "viable_Art_SKEWNESS_RADIUS_5", "viable_Ven_SKEWNESS_RADIUS_5", "viable_Del_SKEWNESS_RADIUS_5", "viable_LEFTLUNGDISTANCE", "viable_RIGHTLUNGDISTANCE", "viable_LANDMARKDISTANCE0", "viable_LANDMARKDISTANCE1", "viable_LANDMARKDISTANCE2", "viable_HESSOBJ", "viable_NORMALIZEDDISTANCE")
crs$weights <- NULL
#============================================================
# Rattle timestamp: 2017-08-23 11:50:27 x86_64-pc-linux-gnu
# Survival Model
# Require the survival package.
library(survival, quietly=TRUE)
# untar(download.packages(pkgs = "survival", destdir = "./survivalsrc", type = "source",repos='http://cran.us.r-project.org')[,2])
# Build the Survival model.
crs$survival <- coxph(Surv(liver_TTP, liver_CensorModality) ~ liver_gender + liver_smoking + liver_AFP + liver_BCLC + liver_Volume + liver_Pre_DENOISE + liver_Art_DENOISE + liver_Ven_DENOISE + liver_Del_DENOISE + liver_Pre_GRADIENT + liver_Art_GRADIENT + liver_Ven_GRADIENT + liver_Del_GRADIENT + liver_Pre_MEAN_RADIUS_1 + liver_Art_MEAN_RADIUS_1 + liver_Ven_MEAN_RADIUS_1 + liver_Del_MEAN_RADIUS_1 + liver_Pre_SIGMA_RADIUS_1 + liver_Art_SIGMA_RADIUS_1 + liver_Ven_SIGMA_RADIUS_1 + liver_Del_SIGMA_RADIUS_1 + necrosis_Volume + necrosis_Pre_DENOISE + necrosis_Art_DENOISE + necrosis_Ven_DENOISE + necrosis_Del_DENOISE + necrosis_Pre_GRADIENT + necrosis_Art_GRADIENT + necrosis_Ven_GRADIENT + necrosis_Del_GRADIENT + necrosis_Pre_MEAN_RADIUS_1 + necrosis_Art_MEAN_RADIUS_1 + necrosis_Ven_MEAN_RADIUS_1 + necrosis_Del_MEAN_RADIUS_1 + necrosis_Pre_SIGMA_RADIUS_1 + necrosis_Art_SIGMA_RADIUS_1 + necrosis_Ven_SIGMA_RADIUS_1 + necrosis_Del_SIGMA_RADIUS_1 + viable_Volume + viable_Pre_DENOISE + viable_Art_DENOISE + viable_Ven_DENOISE + viable_Del_DENOISE + viable_Pre_GRADIENT + viable_Art_GRADIENT + viable_Ven_GRADIENT + viable_Del_GRADIENT + viable_Pre_MEAN_RADIUS_1 + viable_Art_MEAN_RADIUS_1 + viable_Ven_MEAN_RADIUS_1 + viable_Del_MEAN_RADIUS_1 + viable_Pre_SIGMA_RADIUS_1 + viable_Art_SIGMA_RADIUS_1 + viable_Ven_SIGMA_RADIUS_1 + viable_Del_SIGMA_RADIUS_1,
data=crs$dataset[crs$train,c(crs$input, crs$risk, crs$target)])
library(randomForestSRC, quietly=TRUE)
# install.packages("randomForestSRC",repos='http://cran.us.r-project.org')
rfsrc_pbc <- rfsrc(Surv(liver_TTP, liver_CensorModality) ~ liver_gender + liver_smoking + liver_AFP + liver_BCLC + liver_Volume + liver_Pre_DENOISE + liver_Art_DENOISE + liver_Ven_DENOISE + liver_Del_DENOISE + liver_Pre_GRADIENT + liver_Art_GRADIENT + liver_Ven_GRADIENT + liver_Del_GRADIENT + liver_Pre_MEAN_RADIUS_1 + liver_Art_MEAN_RADIUS_1 + liver_Ven_MEAN_RADIUS_1 + liver_Del_MEAN_RADIUS_1 + liver_Pre_SIGMA_RADIUS_1 + liver_Art_SIGMA_RADIUS_1 + liver_Ven_SIGMA_RADIUS_1 + liver_Del_SIGMA_RADIUS_1 + necrosis_Volume + necrosis_Pre_DENOISE + necrosis_Art_DENOISE + necrosis_Ven_DENOISE + necrosis_Del_DENOISE + necrosis_Pre_GRADIENT + necrosis_Art_GRADIENT + necrosis_Ven_GRADIENT + necrosis_Del_GRADIENT + necrosis_Pre_MEAN_RADIUS_1 + necrosis_Art_MEAN_RADIUS_1 + necrosis_Ven_MEAN_RADIUS_1 + necrosis_Del_MEAN_RADIUS_1 + necrosis_Pre_SIGMA_RADIUS_1 + necrosis_Art_SIGMA_RADIUS_1 + necrosis_Ven_SIGMA_RADIUS_1 + necrosis_Del_SIGMA_RADIUS_1 + viable_Volume + viable_Pre_DENOISE + viable_Art_DENOISE + viable_Ven_DENOISE + viable_Del_DENOISE + viable_Pre_GRADIENT + viable_Art_GRADIENT + viable_Ven_GRADIENT + viable_Del_GRADIENT + viable_Pre_MEAN_RADIUS_1 + viable_Art_MEAN_RADIUS_1 + viable_Ven_MEAN_RADIUS_1 + viable_Del_MEAN_RADIUS_1 + viable_Pre_SIGMA_RADIUS_1 + viable_Art_SIGMA_RADIUS_1 + viable_Ven_SIGMA_RADIUS_1 + viable_Del_SIGMA_RADIUS_1,
data=crs$dataset[crs$train,c(crs$input, crs$risk, crs$target)],
nsplit = 10, na.action = "na.impute",
tree.err = TRUE,importance = TRUE)
# Print the results of the modelling.
summary(crs$survival)
# Time taken: 0.04 secs
#============================================================
# Rattle timestamp: 2017-08-23 11:22:50 x86_64-pc-linux-gnu
# Score a dataset.
# Obtain class for the Survival model on gmmdatamatrixfixed22Aug2017_Greg_edited.csv [test].
crs$pr <- survival:::survmean(survfit(crs$survival, na.omit(crs$dataset[crs$test, c(crs$input)])), scale=1, rmean="none")[[1]][,5]
# Extract the relevant variables from the dataset.
sdata <- subset(crs$dataset[crs$test,], select=c("liver_TTP"))
# Output the combined data.
write.csv(cbind(sdata, crs$pr), file="./test_score_idents.csv", row.names=FALSE)
#============================================================
# Rattle timestamp: 2017-08-23 11:24:51 x86_64-pc-linux-gnu
# Score a dataset.
# Obtain class for the Survival model on gmmdatamatrixfixed22Aug2017_Greg_edited.csv [test].
crs$pr <- survival:::survmean(survfit(crs$survival, na.omit(crs$dataset[crs$test, c(crs$input)])), scale=1, rmean="none")[[1]][,5]
# Extract the relevant variables from the dataset.
sdata <- crs$dataset[crs$test,]
# Output the combined data.
write.csv(cbind(sdata, crs$pr), file="./test_score_all.csv", row.names=FALSE)
#options(na.action=na.exclude)
#fit <- coxph(Surv(time, status) ~ ph.ecog + age + sex, lung)
#survConcordance(Surv(time, status) ~predict(fit), lung)
options(na.action=na.exclude)
testdata = crs$dataset[crs$test, c(crs$input, crs$target, crs$risk) ]
print(survConcordance(Surv(liver_TTP, liver_CensorModality) ~predict(crs$survival,testdata ),testdata ))
# compare C-index error rate
srcrfpred <- predict(rfsrc_pbc ,testdata )
rsf.err <- randomForestSRC:::cindex(testdata$liver_TTP, testdata$liver_CensorModality, srcrfpred$predicted)
# FIXME - @gpauloski - getting conflicting values how does your compare ?
print(survConcordance(Surv(liver_TTP, liver_CensorModality) ~srcrfpred$predicted,testdata ))
cat("RSF :", rsf.err, "\n")
# Greg's C-index
source("cindex.R")
# install.packages("compareC",repos='http://cran.us.r-project.org')
# cindex(actual values, predicted values)
# FIXME - @gpauloski -does your cindex function cause namespace problems with the randomForestSRC:::cindex function ?
# @fuentesdt - I don't think so. It looks like the rfSRC cindex is not exported with the package's namespace effectively
# making it a private function. Maybe put a print flag in my cindex function then run the script to see if it works?
c_ind <- cindex(crs$dataset[crs$test,crs$target], predict(crs$survival, testdata))
cat("C-index =", c_ind, "\n")