-
Notifications
You must be signed in to change notification settings - Fork 0
/
YTHDC_full_58352.R
168 lines (134 loc) · 5.8 KB
/
YTHDC_full_58352.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
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
library(BSgenome.Hsapiens.UCSC.hg19)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(GenomicRanges)
library(ROCR)
library(pROC)
library(kernlab)
library(caret)
# library(doParallel)
# cl <- makePSOCKcluster(5)
# registerDoParallel(cl)
set.seed(2123)
# positive_Full
FullYTHDC1_Pos <- readRDS("/home/kunqi/m6A reader/YTHDC1/Full/postive.rds")
# testing_sample
index<- grep(1,FullYTHDC1_Pos$GSE58352)
testT_testing <- as.character(DNAStringSet(Views(Hsapiens,FullYTHDC1_Pos[index]+20)))
testT_testing_genome <- FullYTHDC1_Pos[index]
# positive sample (all)
testT<-as.character(DNAStringSet(Views(Hsapiens,FullYTHDC1_Pos[-index]+20)))
testT_genome <- FullYTHDC1_Pos[-index]
# adding the sources
source("/home/kunqi/m7G/method/class1.R")
source("/home/kunqi/m7G/method/class2.R")
source("/home/kunqi/m7G/method/class3.R")
source("/home/kunqi/m7G/method/class4.R")
source("/home/kunqi/m7G/method/class5.R")
source("/home/kunqi/m7G/method/class6.R")
storeNegMatrix <- matrix(NA, nrow=10, ncol = 1)
aucMatrix <- matrix(NA, nrow = 10, ncol = 1)
aucMatrix2 <- matrix(NA, nrow = 10, ncol = 1)
rocMatrix <- matrix(NA, nrow = 10, ncol = 1)
# create a matrix to store the value
# rename the matrix's column and row
FullYTHDC1_StoreMatrix <- matrix(NA, nrow=9, ncol=2)
rownames(FullYTHDC1_StoreMatrix) <- c("genome_chemiPro","CONPOSITION","Chemiprop_SeqFeature","EIIP","AutoCo_PseKNC","AutoCo","PSNP","genome","onehot")
colnames(FullYTHDC1_StoreMatrix) <- c("crossValid","indepTest")
#encoding method as a list
encodingMethod <- c("genome_chemiPro","CONPOSITION","Chemiprop_SeqFeature","EIIP","AutoCo_PseKNC","AutoCo","PSNP","genome","onehot")
genomeMethod <- c("CONPOSITION","Chemiprop_SeqFeature","EIIP","AutoCo_PseKNC","AutoCo","PSNP","onehot")
tst1 <- c("CONPOSITION","Chemiprop_SeqFeature")
tst2 <- c("EIIP","AutoCo_PseKNC")
tst3 <- c("AutoCo","PSNP","onehot")
tst_all <- c(tst1,tst2,tst3)
tst4 <- c("AutoCo","AutoCo_PseKNC")
format=""
for (method in tst4){
for (i in 1:10){
# get the negative sample
storeNegMatrix[i,] <- paste("/home/kunqi/m6A reader/YTHDC1/Full/negative",i,".rds",sep = "")
testN_read <- readRDS(storeNegMatrix[i,])
#negative training sample
testN <- testN_read[-index]
testN_genome <- testN-2
#prepare the sample used in other encoding method as a character
testN <- as.character(DNAStringSet(Views(Hsapiens,testN+18)))
testN_testing_genome<- testN_read[index]-2
testN_testing <- as.character(DNAStringSet(Views(Hsapiens,testN_read[index]+18)))
testAll <-c(testN,testT)
testAll_testing <- c(testN_testing,testT_testing)
if (method=="genome_chemiPro"){
source("/home/yuxuan.wu/m6A reader/encoding_method/genome_chemiPro.R")
}
if (method=="CONPOSITION"){
source("/home/yuxuan.wu/m6A reader/encoding_method/CONPOSITION.R")
}
if (method =="Chemiprop_SeqFeature"){
source("/home/yuxuan.wu/m6A reader/encoding_method/Chemiprop_SeqFeature.R")
}
if (method == "EIIP"){
source("/home/yuxuan.wu/m6A reader/encoding_method/EIIP.R")
}
if (method =="AutoCo"){
source("/home/yuxuan.wu/m6A reader/encoding_method/AutoCo.R")
}
if (method == "AutoCo_PseKNC"){
source("/home/yuxuan.wu/m6A reader/encoding_method/AutoCo_PseKNC.R")
}
if (method=="PSNP"){
source("/home/yuxuan.wu/m6A reader/encoding_method/PSNP.R")
}
if (method=="genome"){
source("/home/yuxuan.wu/m6A reader/encoding_method/genome.R")
}
if (method=="onehot"){
source("/home/yuxuan.wu/m6A reader/encoding_method/onehot.R")
}
#convert it to the dataframe format
dataframeR<-as.data.frame(matrixResults)
testing <- as.data.frame(testingResults)
# label the data
label_train <- c(rep("Neg",(length(testN))), rep("Pos",(length(testT))))
label_train <- factor(label_train , labels = c("Neg","Pos") )
label_testing <- c(rep("Neg",(length(testN_testing))), rep("Pos",(length(testT_testing))))
label_testing <- factor(label_testing , labels = c("Neg","Pos") )
# add the label to the dataframe
dataframeR$class<-label_train
testing$class <- label_testing
# import the independent testing sample
training <- dataframeR
fitControl <- trainControl(method = "cv",
number = 5,
classProbs = TRUE,
summaryFunction = twoClassSummary)
#svm prediction
Cmotifvsnon_pred <- train(class ~ ., data = training,
method = 'svmRadial',
preProc = c("center", "scale"),
trControl = fitControl,
metric = "ROC")
testing$pred_class <- NA
BIOmotifvsnon_testppred <- NA
BIOmotifvsnon_testpppred_auc <- NA
try(testing$pred_class <- predict(Cmotifvsnon_pred, testing))
try(BIOmotifvsnon_testppred <- prediction(as.numeric(testing$pred_class),testing$class))
try(BIOmotifvsnon_testpppred_auc <- performance(BIOmotifvsnon_testppred,"auc"))
try(aucMatrix[i,]<-attr(BIOmotifvsnon_testpppred_auc,"y.values")[[1]][1])
try(rocMatrix[i,] <- max(Cmotifvsnon_pred$results$ROC))
} #end the 10 loops
#store the matrix as names
setwd("~/testing")
aucName <- paste("aucMatrix",method,"-tstallFull58352.rds",sep = "")
saveRDS(aucMatrix,aucName)
#caculate the average AUC after 10 times
avgAUC <- apply(aucMatrix,MARGIN = 2, FUN = mean,na.rm=T)
avgAUC
#caculate the max ROC of the prediction model
avgROC <- apply(rocMatrix,MARGIN = 2, FUN = mean,na.rm=T)
avgROC
# generate the results
results <- c(avgROC,avgAUC)
FullYTHDC1_StoreMatrix[method,] <- results
}
setwd("/home/yuxuan.wu/m6A reader/storeMatrix")
saveRDS(FullYTHDC1_StoreMatrix,"storeMatrix_FullYTHDC1_tstall58352.rds")