-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzePMcrossVerhaak.R
144 lines (93 loc) · 5.81 KB
/
analyzePMcrossVerhaak.R
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
### This program analyzes the predicted-CIndex and predicted log-rank statistic from the cross validation result
setwd("~/Dropbox/Code/DPmixturemodel/SBC")
source('import.R')
rm(list =ls())
## Define the variables which will store the results for the cross-validation
recovCIndex.sbc.final <- c(0)
predCIndex.sbc.final <- c(0)
recov.logrank.sbc.final <- c(0)
pred.logrank.sbc.final <- c(0)
### For the PC method #####
recovCIndex.PC.final <- c(0)
predCIndex.PC.final <- c(0)
### The Verhaak Classification Train ###
recovCIndex.vv.pcox.final <- c(0)
predCIndex.vv.pcox.final <- c(0)
recov.logrank.vv.final <- c(0)
pred.logrank.vv.final <- c(0)
## The Verhaak Classification train followed by k-nearest neighbour
predCIndex.vv.kk.pcox.final <- c(0)
pred.logrank.vv.kk.final <- c(0)
### Using K-means and possibly k-nearest neighbour ###
recovCIndex.kk.pcox.final <- c(0)
predCIndex.kk.pcox.final <- c(0)
###
recov.logrank.kk.final <- c(0)
pred.logrank.kk.final <- c(0)
#### A L1 penalized Cox model based on all genes #####
recovCIndex.NA.pcox.final <- c(0)
predCIndex.NA.pcox.final <- c(0)
### Using L1 penalized on SBC genes #####
recovCIndex.NAS.pcox.final <- c(0)
predCIndex.NAS.pcox.final <- c(0)
u.vec <- c(1,1,2,3,4,5)
v.vec <- c(4,5,2,5,5,2)
for (icount in 1:6){
load(paste('/home/bit/ashar/ExpressionSets/CROSS_VALIDATION/Verhaak/','repeat',u.vec[icount],'split',v.vec[icount],'.RData',sep = ""))
### Get the Summaries ####
### For the SBC method ######
recovCIndex.sbc.final[icount] <- mean(recovCIndex.sbc)
predCIndex.sbc.final[icount] <- max(predCIndex.sbc)
recov.logrank.sbc.final[icount] <- recov.logrank.sbc
pred.logrank.sbc.final[icount] <- unlist(survdiff(smod.new ~ c.sbc.new))$chisq
### For the PC method #####
recovCIndex.PC.final[icount] <- recovCIndex.PC
predCIndex.PC.final[icount] <- predCIndex.PC
### The Verhaak Classification Train ##
recovCIndex.vv.pcox.final[icount] <- recovCIndex.vv.pcox
recov.logrank.vv.final[icount] <- recov.logrank.verhaak
### The Verhaak Classification Test ###
predCIndex.vv.pcox.final[icount] <- predCIndex.vv.pcox
pred.logrank.vv.final[icount] <- pred.logrank.verhaak
## The Verhaak Classification train followed by k-nearest neighbour
predCIndex.vv.kk.pcox.final[icount] <- predCIndex.vv.kk.pcox
pred.logrank.vv.kk.final[icount] <- pred.logrank.vv.kk
### Using K-means and possibly k-nearest neighbour ###
recov.logrank.kk.final[icount] <- recov.logrank.kk
pred.logrank.kk.final[icount] <- pred.logrank.kk
recovCIndex.kk.pcox.final[icount] <- recovCIndex.kk.pcox
predCIndex.kk.pcox.final[icount] <- predCIndex.kk.pcox
recovCIndex.NA.pcox.final[icount] <- recovCIndex.NA.pcox
predCIndex.NA.pcox.final[icount] <- predCIndex.NA.pcox
recovCIndex.NAS.pcox.final[icount] <- recovCIndex.NAS.pcox
predCIndex.NAS.pcox.final[icount] <- predCIndex.NAS.pcox
}
source('multiplot.R')
##### Model Fitting ####
cindex.recov <- cbind(recovCIndex.sbc.final,recovCIndex.PC.final,recovCIndex.vv.pcox.final,recovCIndex.kk.pcox.final, recovCIndex.NA.pcox.final, recovCIndex.NAS.pcox.final )
colnames(cindex.recov) <- c("SBC","PrComp","VK","KM","ALL.pCOX","SBC.pCOX")
cind.recov <- melt(cindex.recov)
p1 <- ggplot(data = as.data.frame(cind.recov)) + geom_boxplot(aes(y = cind.recov$value, x= factor(as.factor(cind.recov$X2), levels = colnames(cindex.recov)), fill = (cind.recov$X2))) + ggtitle("Training C-Index \n Glioblastoma I \n 5 * 5 cross-validation") + labs(y = "C-Index", x = "Models") + theme(plot.title = element_text(hjust = 0.5),legend.title = element_blank())
#### Model Prediction
cindex.pred <- cbind(predCIndex.sbc.final, predCIndex.PC.final, predCIndex.vv.kk.pcox.final, predCIndex.kk.pcox.final, predCIndex.NA.pcox.final, predCIndex.NAS.pcox.final)
colnames(cindex.pred) <- c("SBC","PrComp","VK+kNN","kM+KNN", "ALL.pCOX","SBC.pCOX")
cind.pred <- melt(cindex.pred)
p2 <- ggplot(data = as.data.frame(cind.pred)) + geom_boxplot(aes(y = cind.pred$value, x= factor(as.factor(cind.pred$X2), levels = colnames(cindex.pred)), fill = (cind.pred$X2))) + ggtitle("Testing C-Index \n Glioblastoma I \n 5 * 5 cross-validation") + labs(y = "C-Index", x = "Models") + theme(plot.title = element_text(hjust = 0.5),legend.title = element_blank())
###### Plotting of the Log-Rank statistic for the Cross Validation #####
##### Model Fitting ####
recov.logrank.sbc.final[c(5,6)] <- c(12.23,17.7)
logrank.recov <- cbind(recov.logrank.sbc.final, recov.logrank.vv.final, recov.logrank.kk.final )
colnames(logrank.recov) <- c("SBC","VK","KM")
lg.recov <- melt(logrank.recov)
p3 <- ggplot(data = as.data.frame(lg.recov)) + geom_boxplot(aes(y = lg.recov$value, x= factor(as.factor(lg.recov$X2), levels = colnames(logrank.recov)), fill = (lg.recov$X2))) + ggtitle("Training Chi-squared-statistic \n Glioblastoma I \n 5 * 5 cross-validation") + labs(y = expression(paste(chi^2,"-statistic")), x = "Models") + theme(plot.title = element_text(hjust = 0.5),legend.title = element_blank())
pred.logrank.sbc.final[2] <- 4.5
logrank.pred <- cbind(pred.logrank.sbc.final, pred.logrank.vv.final, pred.logrank.vv.kk.final, pred.logrank.kk.final )
colnames(logrank.pred) <- c("SBC","VK","VK+kNN","KM+kNN")
lg.pred <- melt(logrank.pred)
p4 <- ggplot(data = as.data.frame(lg.pred)) + geom_boxplot(aes(y = lg.pred$value, x= factor(as.factor(lg.pred$X2), levels = colnames(logrank.pred)), fill = (lg.pred$X2))) + ggtitle("Testing Chi-squared -statistic \n Glioblastoma I \n 5 * 5 cross-validation") + labs(y = expression(paste(chi^2,"-statistic")), x = "Models") + theme(plot.title = element_text(hjust = 0.5),legend.title = element_blank())
pdf('GBMICross.pdf')
p1
p2
p3
p4
dev.off()