-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathInterval_Plot.Rmd
207 lines (158 loc) · 5.43 KB
/
Interval_Plot.Rmd
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
196
197
198
199
200
201
202
203
204
205
206
207
---
title: "Plot Interval Graph (Prediction Vs Observed inhibitory activities)"
author: Saw Simeon, Nuttapat Anuwongcharoen, Watshara Shoombuatong, Aijaz Ahmad Malik,
Virapong Prachayasittikul, Jarl E. S. Wikberg and Chanin Nantasenamat
date: "June 16, 2016"
output: pdf_document
---
# Create a predicted and IC50 plot
```{r}
file <- function(x) {
library(randomForest)
library(caret)
library(ranger)
library(cowplot)
set.seed(10)
para <- dplyr::sample_n(x, size = 2570, replace = TRUE)
set.seed(3)
in_train_para <- sample(nrow(para),
size = as.integer(nrow(para) * 0.8),
replace = FALSE)
set.seed(4)
Train <- para[in_train_para, ]
Test <- para[-in_train_para, ]
model <- ranger::ranger(pIC50~., data = Train, write.forest = TRUE, save.memory = TRUE)
#actual <- train$Activity
prediction <- predict(model, Train)
prediction_Internal <- prediction$predictions
value <- data.frame(obs = Train$pIC50, pred = prediction_Internal)
labeling <- c("obs", "pred")
colnames(value) <- labeling
value$Label <- c("Internal")
prediction_External <- predict(model, Test)
prediction_External <- prediction_External$predictions
value_external <- data.frame(obs = Test$pIC50, pred = prediction_External)
colnames(value_external) <- labeling
value_external$Label <- c("External")
results <- rbind(value, value_external)
return(results)
}
get_interval <- function(x) {
file <- file(x)
x <- file[, 1]
y <- file[, 2]
label <- file[3]
fit <- lm(y~x)
pred.int <- predict(fit, interval = "prediction")
pred.lower = pred.int[,2]
pred.upper = pred.int[,3]
df <- cbind(x, y, label, pred.lower, pred.upper)
return(df)
}
plot_graph_interval <- function(x) {
library(ggplot2)
ok <- get_interval(x)
good <- ggplot(ok, aes(x = x)) +
geom_point(size = 7, colour = "black", pch = 21, alpha= 0.4,
aes(y = y, fill = factor(Label))) +
geom_line(aes(y = pred.lower), size = 1.5, colour = "grey", linetype = 2) +
geom_line(aes(y = pred.upper), size = 1.5, colour = "grey", linetype = 2) +
xlab(expression(paste('Predicted ', pIC[50]))) + ylab(expression(paste('Experimental ', pIC[50]))) +
#geom_abline(intercept = ok$pred.lower[[1]], linetype = 2, size = 1.5, colour = "grey") +
#geom_abline(intercept = ok$pred.upper[[1]], linetype = 2, size = 1.5, colour = "grey") +
theme(
panel.border = element_rect(linetype = "solid", colour = "black",
fill = NA, size = 1),
axis.text.y = element_text(size = 20, colour = "black"),
axis.text.x = element_text(size = 20, colour = "black"),
axis.title.x = element_text(size = 30, color = "black", face = "bold"),
axis.title.y = element_text(size = 30, color = "black", face = "bold"),
legend.position = ("none")) +
coord_cartesian(ylim = c(-6, 12), xlim = c(-6, 12))
return(good)
}
```
\pagebreak
# CDK fingerprint
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$FingerPrinter
plot_graph_interval(df)
```
\pagebreak
# CDK extended fingerprint
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$Extended_finterPrinter
plot_graph_interval(df)
```
\pagebreak
# CDK graph only fingerprint
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$GraphOnly_FingerPrinter
plot_graph_interval(df)
```
\pagebreak
# E-state fingerprint
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$Extended_finterPrinter
plot_graph_interval(df)
```
\pagebreak
# MACCS fingerprint
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$MACCS_FingerPrinter
plot_graph_interval(df)
```
\pagebreak
# PubChem fingerprint
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$Pubchem_FingerPrinter
plot_graph_interval(df)
```
\pagebreak
# Substructure fingerprint
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$Substructure_fingerPrinter
plot_graph_interval(df)
```
\pagebreak
# Substructure count
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$Substructure_fingerPrintCount
plot_graph_interval(df)
```
\pagebreak
# Klekota-Roth fingerprint
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$KlekotaRoth_FingerPrinter
plot_graph_interval(df)
```
\pagebreak
# Klekota-Roth count
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$KlekotaRoth_FingerprintCount
plot_graph_interval(df)
```
\pagebreak
# 2D atom pairs
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$AtomPairs2D_fingerPrinter
plot_graph_interval(df)
```
\pagebreak
# 2D atom pairs count
```{r, fig.width = 10, fig.height = 10, error = FALSE, message = FALSE, warning= FALSE}
input <- readRDS("data.Rds")
df <- input$AtomPairs2D_fingerPrintCount
plot_graph_interval(df)
```