-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKinobeads_Plotting.R
340 lines (267 loc) · 14.7 KB
/
Kinobeads_Plotting.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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# To run this code, please download the files "03_Kinobeads_curves_forplotting.txt" and "03_Kinobeads_proteingroups_forplotting.txt" from Zenodo (see README).
# These files should be imported as dataframes called "curves" and "proteingroups", respectively.
# Before staring the script, run the following lines:
LL.4.function <- function(B, x){
(B[2]-B[3])/(1+(x/B[1])^B[4])+B[3]
}
xlim <- c(0.4, 40000)
ylim <- c(0, 1.5)
ylabels <- seq(0,1.6, by = 0.2)
many.x.values <- c(seq(0.5, 1, by = 0.05), seq(1, 10, by = 0.1),seq(10, 100, by = 1), seq(100, 1000, by = 2),seq(1000, 35000, by = 100))
doses.withoutDMSO = c( 1, 3, 10, 30, 100, 300, 1000, 3000, 30000)
doses.toplot = c(0, 1, 3, 10, 30, 100, 300, 1000, 3000, 10000, 30000)
############################################################
# Fig. 3b (heatmap)
############################################################
# Select relevant columns, filter for Targets, arrange genes by alphabet
curves_targets <- curves %>% dplyr::select(Target, Genes, pKdapp, Experiment) %>% dplyr::filter(Target ==T & Kinase == T)
curves_targets$Gene.names <- factor(curves_targets$Genes, levels = sort(unique(curves_targets$Genes)))
# Arrange data
curves_targets$Experiment <- factor(curves_targets$Experiment, levels = rev(c('Gartisertib','Berzosertib','Ceralasertib','Elimusertib')))
# vertical heatmap
ggplot(curves_targets, aes(Experiment, factor(Genes, sort(unique(Genes), decreasing = T)))) +
geom_tile(aes(fill = pKdapp), colour = "white") +
theme_classic()+
scale_fill_viridis_c(option = "magma", na.value = 'white',limits=c(5.5,10.5),direction=-1,oob = scales::squish)+ #oob=squish
theme(axis.text.x = element_text(angle = 35, vjust = 1, hjust=1, size =10), panel.border = element_rect(colour = "black", fill=NA, size=1),
axis.line = element_line(colour = "black"), axis.title = element_blank(),
axis.text = element_text(size =10, colour = "black"), legend.text= element_text(size = 12), legend.title = element_text(size = 12, face = "bold"))
############################################################
# Fig. 3c (curve plots)
############################################################
colors = c("#54309c", "#E08766")
dev.off()
par(tck = -.02, mgp = c(1.5, 0.5, 0), mar = c(6,5,3.5,3.5))
plot(x = 'n', y = 'n',
log = 'x',
xlab = "", ylab = "",
xlim = xlim, ylim = ylim,
axes = F)
param <- curves %>% dplyr::filter(Experiment =="Elimusertib" & Target == T & Kinase == T)
for (i in 1:nrow(param)){
parameters <- param[i,] %>% dplyr::select(c('Curve.R2','EC50','Curve.Front', 'Curve.Back', 'Curve.Slope', 'Kdapp', 'Curve.Fold.Change')) # EC50 (in nM), top, bottom, slope
if(!is.na(parameters$Curve.R2)){
Gene_ID <- as.character(param$Genes[i])
cols <- colors[i]
y.response <- param %>% dplyr::filter(Genes == Gene_ID) %>% dplyr::select(starts_with("Ratio")) # subset row by row
colnames(y.response)[-1] <- doses.withoutDMSO
colnames(y.response)[1] <- 0.3
points(x = c(0.3, doses.withoutDMSO), y = c(1, t(y.response)[2:ncol(y.response)]),
log = 'x',
legend = F,
cex = 1.2,
cex.main = 1.6,
bg = cols,
lty =1,
pch = 16,
xlab = "", ylab = "",
xlim = xlim, ylim = ylim,
col = cols,
axes = F)
four.parameters <-t(parameters)[2:5]
y.fitted.curve <- LL.4.function(four.parameters, many.x.values)
lines(many.x.values, y.fitted.curve, type = "l", log = "x", lwd = 3, col= cols)
}
add=T
}
title(ylab = "Residual Binding", cex.lab = 1.2, line = 2)
title(xlab = "Concentration [nM]", cex.lab = 1.2, line = 3.6)
axis(1, at =c(0.3, doses.toplot), labels=c(0, doses.toplot), lwd = 0, lwd.ticks = 1, las =2)
axis(2, at =seq(0, 1.4, 0.2), labels =format(seq(0, 1.4, 0.2),digits=2), lwd = 0, lwd.ticks = 1, las = 2)
abline(h = 1, lty = 'dotted', lwd=1)
legendtext <- param$Genes
lgd <- legend('topright', legendtext, plot = F)
legend('topright',box.lty=0, bty="n",
legend = legendtext, cex =0.8, pch = 19, lwd=3, col = colors[1:i],
plot = T)
box(bty="L")
############################################################
# Supplementary Fig. 2a (curve plots)
############################################################
colors = list(c("#005293", "#999999"), c("grey30", "#64a0c8"))
pchs = c(16,16)
Experiment_sets <- list(c("Elimusertib", "Ceralasertib"), c("Gartisertib", "Berzosertib"))
for(n in 1:length(Experiment_sets)){
par(tck = -.02, mgp = c(1.5, 0.5, 0), mar = c(6,5,3.5,3.5))
plot(x = 'n', y = 'n',
log = 'x',
xlab = "", ylab = "", # Labels
xlim = xlim, ylim = ylim, # Limits
axes = F)
param <- curves %>% dplyr::filter(Experiment %in% Experiment_sets[[n]] & Genes == "ATR") #%>% arrange(EC50, desc(r2))
for (i in 1:2){
parameters <- param[i,] %>% dplyr::select(c('Curve.R2','EC50','Curve.Front', 'Curve.Back', 'Curve.Slope', 'Kdapp', 'Curve.Fold.Change')) # EC50 (in nM), top, bottom, slope
cols <- colors[[n]][i]
y.response <- param %>% dplyr::filter(Experiment == param[i,]$Experiment & Genes == "ATR") %>% dplyr::select(starts_with("Ratio")) # subset row by row
colnames(y.response)[-1] <- doses.withoutDMSO
colnames(y.response)[1] <- 0.3
points(x = c(0.3, doses.withoutDMSO), y = c(1, t(y.response)[2:ncol(y.response)]),
log = 'x',
legend = F,
cex = 1.5,
cex.main = 1.6,
bg = cols,
lty =1,
pch = pchs[i],
xlab = "", ylab = "",
xlim = xlim, ylim = ylim,
col = cols,
axes = F)
box(bty="L")
four.parameters <-t(parameters)[2:5]
y.fitted.curve <- LL.4.function(four.parameters, many.x.values)
lines(many.x.values, y.fitted.curve, type = "l", log = "x", lwd = 2, col= cols)
}
title(ylab = "Residual Binding", cex.lab = 1.2, line = 2)
title(xlab = "Concentration (nM)", cex.lab = 1.2, line = 3.6)
title("ATR", line =0.2, cex.main = 1.5)
axis(1, at =c(0.3, doses.toplot), labels=c(0, doses.toplot), lwd = 0, lwd.ticks = 1, las =2)
axis(2, at =seq(0, 1.4, 0.2), labels =format(seq(0, 1.4, 0.2),digits=2), lwd = 0, lwd.ticks = 1, las = 2)
abline(h = 1, lty = 'dotted', lwd=1)
legendtext <- as.character(param$Experiment)
lgd <- legend('topright', legendtext, plot = F)
legend('topright',box.lty=0, bty="n",
legend = legendtext, pt.cex =1.5, cex =1, pch = pchs, lwd=2, col = colors[[n]],
plot = T)
}
############################################################
# Supplementary Fig. 2b (barplots)
############################################################
dev.off()
y.response <- proteingroups %>% dplyr::filter(Genes == "ATR") %>% dplyr::select(starts_with("MS.MS.count."), Experiment) %>%
pivot_longer(starts_with("MS.MS"), names_to = "dose1", values_to = "count" ) %>% mutate(readout = "MSMScounts")
y.response$dose1 <- gsub("MS.MS.count.", "", y.response$dose1)
y.response2 <- proteingroups %>% dplyr::filter(Genes == "ATR") %>% dplyr::select(starts_with("Unique.peptides."), Experiment) %>%
pivot_longer(starts_with("Unique"), names_to = "dose1", values_to = "count" ) %>% mutate(readout = "uniquepeptides")
y.response2$dose1 <- gsub("Unique.peptides.", "", y.response2$dose1)
y.response <- rbind(y.response, y.response2) %>% dplyr::filter(dose1 != "PDPD")
y.response$dose1 <- gsub("DMSO", "0", y.response$dose1)
y.response$dose1 <- factor(y.response$dose1, levels = sort(unique(as.numeric(y.response$dose1))))
y.response$Experiment <- factor(y.response$Experiment, levels = c("Elimusertib", "Ceralasertib", "Berzosertib", "Gartisertib"))
ggplot(y.response, aes(fill=readout, y=count, x=dose1)) +
geom_bar(position="dodge", stat="identity")+
theme_classic()+
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1), axis.text = element_text(colour = "black"),
axis.ticks = element_line(color = "black"))+
scale_fill_manual(values = c("grey40","grey70")) +
scale_y_continuous(breaks= pretty_breaks(),expand = c(0, NA))+
facet_wrap(~Experiment, scales = "free")+
theme(strip.background = element_blank(),
strip.placement = "outside")
############################################################
# Supplementary Plots (Here: Curve plots of all targets per experiment)
############################################################
experiments <- as.character(unique(curves$Experiment))
dev.off()
for(n in 1:length(experiments)){
df_plots <- curves %>% dplyr::filter(Experiment == experiments[n] & Target ==T & Kinase == T)
nf <- layout(matrix(c(1:15), ncol = 3, nrow = 5, byrow=TRUE),
widths=c(1.5,0.5,1.5), heights =c(1,1,1,1,1))
for (i in 1:nrow(df_plots)){
parameters <- df_plots[i,] %>% dplyr::select(c('Curve.R2','EC50','Curve.Front', 'Curve.Back', 'Curve.Slope', 'Kdapp', 'Curve.Fold.Change')) # R2, EC50 (in nM), top, bottom, slope, Kdapp, log2FC
if(!is.na(parameters$Curve.R2)){
Gene_ID <- as.character(df_plots$Genes[i])
cols <- "black"
par(tck = -.03, mgp = c(1.5, 0.5, 0), mar = c(5,4,3.5,3.5))
y.response <- curves %>% dplyr::filter(Experiment == experiments[n] & Genes == df_plots$Genes[i]) %>% dplyr::select(starts_with("Ratio")) # subset row by row
colnames(y.response)[-1] <- doses.withoutDMSO
colnames(y.response)[1] <- 0.3
plot(x = c(doses.withoutDMSO), y = c(t(y.response)[2:ncol(y.response)]),
log = 'x',
legend = F,
cex = 1,
cex.main = 1.6,
bg = cols,
lty =1,
pch = 19,
xlab = "", ylab = "",
xlim = xlim, ylim = ylim,
col = cols,
axes = F)
box(bty="L")
title(ylab = "Residual Binding", cex.lab = 1.2, line = 2)
title(xlab = "Concentration (nM)", cex.lab = 1.2, line = 3.6)
title(Gene_ID, line =0.2, cex.main = 1.5)
axis(1, at =c(doses.toplot)[-1], labels=c(doses.toplot)[-1], lwd = 0, lwd.ticks = 1, las =2)
axis(2, at =seq(0, 1.4, 0.2), labels =format(seq(0, 1.4, 0.2),digits=2), lwd = 0, lwd.ticks = 1, las = 2)
four.parameters <-t(parameters)[2:5] # Make numeric vector out of it. Leave out R2
y.fitted.curve <- LL.4.function(four.parameters, many.x.values)
lines(many.x.values, y.fitted.curve, type = "l", log = "x", lwd = 1.5)
# Add legend
parameters <- round(parameters,2)
legendtext <- c(paste("R2: ", parameters[1], sep=''),
paste("EC50: ", parameters[2], ' nM', sep=''),
paste("KDapp: ", parameters[6], ' nM', sep=''),
paste("Log2 FC: ", parameters[7], sep=''))
lgd <- legend('bottomleft', legendtext, plot = F)
legend('bottomleft',box.lty=0, text.width = strwidth(legendtext)[1]*1.5, bty="n",
legend = legendtext, cex =0.7, pch = c(20), col = "transparent",
plot = T)
# 2. density plots
par(tck = -.03, mgp = c(2, 0.5, 0),mar = c(4.5,0.6,3.5,2.5))
df <- proteingroups %>% dplyr::filter(Experiment == experiments[n])
colnames(df) <- gsub("Raw 0", "LFQ.intensity.0", colnames(df))
df <- df %>% filter(LFQ.intensity.0 != 0)
d <- log2(df$LFQ.intensity.0)
density.d <- density(d)
plot(density.d$y,density.d$x, main = "", yaxt = 'n', xaxt='n', xlim=rev(range(density.d$y)), type='l',
ylab= '', xlab = "", cex.main=1.2, )
axis(4)
mtext("Log2 Intensity (Ctrl)", side=2, line=0.7, cex = 0.8)
polygon(density.d$y,density.d$x, col="grey", border="grey")
abline(h = log2(df[which(df$Genes == Gene_ID),'LFQ.intensity.0']),
col= 'grey30', lwd=3)
# 3. unique peptides and ms ms scans
proteingroups_temp <- proteingroups %>% dplyr::filter(Experiment == experiments[n])
unique.peptides.df <- dplyr::select(proteingroups_temp, Genes | starts_with("Unique.peptides.") & -contains("PD"))
colnames(unique.peptides.df) <- gsub(".0", ".0.3", colnames(unique.peptides.df), fixed = T)
colnames(unique.peptides.df) <- gsub("Unique.peptides.", "", colnames(unique.peptides.df))
colnames(unique.peptides.df) <- gsub("nM", "", colnames(unique.peptides.df))
unique.peptides.df.melt <- melt(unique.peptides.df, id.vars = "Genes")
b <- unique.peptides.df.melt[which(unique.peptides.df.melt$Genes==Gene_ID),]
par(tck = -.03, mgp = c(2, 0.5, 0),mar = c(4.5,4,3.5,4.5))
plot(as.numeric(levels(b$variable))[b$variable], b$value,
log="x",
cex = 1,
cex.main = 1.6,
bg = "black",
xlab = "", ylab = "",
lty =1,
pch = 19,
xlim = xlim,
ylim = c(0, max(b$value)),
col = "black",
axes= F)
title(ylab = "Unique peptides", cex.lab = 1.2, line = 1.5)
axis(2, at = 0:max(b$value), labels= 0:max(b$value), las =1, col.ticks = "black")
# Get MS MS counts for protein from filtered proteingroups.txt
MSMScounts.df <- dplyr::select(proteingroups_temp, Genes | starts_with("MS.MS.Count.") & -contains("PD"))
colnames(unique.peptides.df) <- gsub(".0", ".0.3", colnames(unique.peptides.df), fixed = T)
colnames(MSMScounts.df) <- gsub("Unique.peptides.", "", colnames(unique.peptides.df))
colnames(MSMScounts.df) <- gsub("nM", "", colnames(unique.peptides.df))
MSMScounts.df.melt <- melt(MSMScounts.df, id.vars = "Genes")
b <- MSMScounts.df.melt[which(MSMScounts.df.melt$Genes==Gene_ID),]
par(new=TRUE)
plot(as.numeric(levels(b$variable))[b$variable], b$value, main ="", log="x",
cex = 1,
cex.main = 1.4,
bg = 'red',
xlab = "", ylab = "",
lty =1,
pch = 19,
xlim = xlim,
ylim = c(0, max(b$value)),
col = "red",
axes= F)
box(bty = 'L')
title(ylab = "MS/MS counts", cex.lab = 1.2, line = 2.5, col.lab = 'red')
axis(4, at = 0:max(b$value), labels= 0:max(b$value),las =1, col.ticks = 'red' , col.axis = 'red', col = 'red')
title(xlab = "Concentration [nM]", cex.lab = 1.2, line = 3.6)
title(Gene_ID, line =0.2, cex.main = 1.5)
axis(1, at =c(0.3, doses.toplot[-1]), labels=c(doses.toplot), lwd = 0, lwd.ticks = 1, las =2)
}
if(i %in% seq(1,200,5)){
mtext(paste0("Target of ", experiments[n]), outer=TRUE, line=-2)
}
}
}