|
a |
|
b/vignettes/src/part02.Rmd |
|
|
1 |
--- |
|
|
2 |
title: "Part 2" |
|
|
3 |
output: |
|
|
4 |
BiocStyle::html_document |
|
|
5 |
--- |
|
|
6 |
|
|
|
7 |
```{r, message=FALSE, include=!exists(".standalone"), eval=!exists(".standalone")} |
|
|
8 |
library("BloodCancerMultiOmics2017") |
|
|
9 |
library("reshape2") # melt |
|
|
10 |
library("Biobase") |
|
|
11 |
library("dplyr") |
|
|
12 |
library("RColorBrewer") |
|
|
13 |
library("ggplot2") |
|
|
14 |
library("ggdendro") |
|
|
15 |
library("gtable") |
|
|
16 |
library("grid") |
|
|
17 |
library("Rtsne") |
|
|
18 |
library("ggbeeswarm") |
|
|
19 |
``` |
|
|
20 |
|
|
|
21 |
```{r echo=FALSE} |
|
|
22 |
plotDir = ifelse(exists(".standalone"), "", "part02/") |
|
|
23 |
if(plotDir!="") if(!file.exists(plotDir)) dir.create(plotDir) |
|
|
24 |
``` |
|
|
25 |
|
|
|
26 |
```{r} |
|
|
27 |
options(stringsAsFactors=FALSE) |
|
|
28 |
``` |
|
|
29 |
|
|
|
30 |
# Drug-induced effects on cell viability |
|
|
31 |
|
|
|
32 |
Loading the data. |
|
|
33 |
```{r} |
|
|
34 |
data("lpdAll") |
|
|
35 |
``` |
|
|
36 |
|
|
|
37 |
Here we show a relative cell viability (as compared to negative control) under treatment with 64 drugs at 5 concentrations steps each. |
|
|
38 |
|
|
|
39 |
Prepare data. |
|
|
40 |
```{r} |
|
|
41 |
#select drug screening data on patient samples |
|
|
42 |
lpd <- lpdAll[fData(lpdAll)$type == "viab", pData(lpdAll)$Diagnosis != "hMNC"] |
|
|
43 |
viabTab <- Biobase::exprs(lpd) |
|
|
44 |
viabTab <- viabTab[,complete.cases(t(viabTab))] |
|
|
45 |
viabTab <- reshape2::melt(viabTab) |
|
|
46 |
viabTab$Concentration <- fData(lpd)[viabTab$Var1,"subtype"] |
|
|
47 |
viabTab <- viabTab[viabTab$Concentration %in% c("1","2","3","4","5"),] |
|
|
48 |
viabTab$drugName <- fData(lpd)[viabTab$Var1,"name"] |
|
|
49 |
viabTab <- viabTab[order(viabTab$Concentration),] |
|
|
50 |
|
|
|
51 |
#order drug by mean viablitity |
|
|
52 |
drugOrder <- group_by(viabTab, drugName) %>% |
|
|
53 |
summarise(meanViab = mean(value)) %>% |
|
|
54 |
arrange(meanViab) |
|
|
55 |
viabTab$drugName <- factor(viabTab$drugName, levels = drugOrder$drugName) |
|
|
56 |
``` |
|
|
57 |
|
|
|
58 |
Scatter plot for viabilities and using colors for concentrations. |
|
|
59 |
```{r ViabilityScatter_main, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), fig.width=10, fig.height=5, warning=FALSE, out.width=560, out.height=280} |
|
|
60 |
#FIG# S1 |
|
|
61 |
|
|
|
62 |
#Color for each concentration |
|
|
63 |
colorCode <- rev(brewer.pal(7,"Blues")[3:7]) |
|
|
64 |
names(colorCode) <- unique(viabTab$Concentration) |
|
|
65 |
|
|
|
66 |
ggplot(viabTab, aes(x=drugName,y=value, color=Concentration)) + |
|
|
67 |
geom_jitter(size=1, na.rm = TRUE, alpha=0.8, shape =16) + |
|
|
68 |
scale_color_manual(values = colorCode) + |
|
|
69 |
ylab("Viability") + ylim(c(0,1.2)) + xlab("") + |
|
|
70 |
guides(color = guide_legend(override.aes = list(size=3,alpha=1), |
|
|
71 |
title = "concentration index")) + |
|
|
72 |
theme_bw() + |
|
|
73 |
theme(legend.position = "bottom", |
|
|
74 |
axis.text.x = element_text(angle = 90, hjust = 1, vjust=0.5), |
|
|
75 |
legend.key = element_blank()) |
|
|
76 |
``` |
|
|
77 |
|
|
|
78 |
The plot shows high variability of effects between different drugs, from mostly lethal |
|
|
79 |
(left) to mostly neutral (right), concentration dependence of effects and high variability of effects of the same drug/concentration across patients. |
|
|
80 |
|
|
|
81 |
# Drug-drug correlation |
|
|
82 |
|
|
|
83 |
We compared response patterns produced by drugs using phenotype clustering within diseases (CLL, T-PLL and MCL) using Pearson correlation analysis. The results imply that the drug assays probe tumor cells’ specific dependencies on survival pathways. |
|
|
84 |
|
|
|
85 |
Loading the data. |
|
|
86 |
```{r} |
|
|
87 |
data("drpar", "patmeta", "drugs") |
|
|
88 |
``` |
|
|
89 |
|
|
|
90 |
## Additional processing functions and parameters |
|
|
91 |
|
|
|
92 |
Function that return the subset of samples for a given diagnosis (or all samples if diag=NA). |
|
|
93 |
```{r} |
|
|
94 |
givePatientID4Diag = function(pts, diag=NA) { |
|
|
95 |
pts = if(is.na(diag)) { |
|
|
96 |
names(pts) |
|
|
97 |
} else { |
|
|
98 |
names(pts[patmeta[pts,"Diagnosis"]==diag]) |
|
|
99 |
} |
|
|
100 |
pts |
|
|
101 |
} |
|
|
102 |
``` |
|
|
103 |
|
|
|
104 |
Function that returns the viability matrix for given screen (for a given channel) for patients with given diagnosis. |
|
|
105 |
```{r} |
|
|
106 |
giveViabMatrix = function(diag, screen, chnnl) { |
|
|
107 |
data = if(screen=="main") drpar |
|
|
108 |
else print("Incorrect screen name.") |
|
|
109 |
pid = colnames(data) |
|
|
110 |
if(!is.na(diag)) |
|
|
111 |
pid = pid[patmeta[pid,"Diagnosis"]==diag] |
|
|
112 |
|
|
|
113 |
return(assayData(data)[[chnnl]][,pid]) |
|
|
114 |
} |
|
|
115 |
``` |
|
|
116 |
|
|
|
117 |
Color scales for the heat maps. |
|
|
118 |
```{r} |
|
|
119 |
palette.cor1 = c(rev(brewer.pal(9, "Blues"))[1:8], |
|
|
120 |
"white","white","white","white",brewer.pal(7, "Reds")) |
|
|
121 |
palette.cor2 = c(rev(brewer.pal(9, "Blues"))[1:8], |
|
|
122 |
"white","white","white","white",brewer.pal(7, "YlOrRd")) |
|
|
123 |
``` |
|
|
124 |
|
|
|
125 |
## CLL/T-PLL |
|
|
126 |
|
|
|
127 |
Pearson correlation coefficients were calculated based on the mean drug response for the two lowest concentration steps in the main screen and across CLL and T-PLL samples separately. Square correlation matrices were plotted together, with CLL in lower triangle and T-PLL in upper triangle. The drugs in a heat map are ordered by hierarchical clustering applied to drug responses of CLL samples. |
|
|
128 |
|
|
|
129 |
```{r} |
|
|
130 |
main.cll.tpll = BloodCancerMultiOmics2017:::makeCorrHeatmap( |
|
|
131 |
mt=giveViabMatrix(diag="CLL", screen="main", chnnl="viaraw.4_5"), |
|
|
132 |
mt2=giveViabMatrix(diag="T-PLL", screen="main", chnnl="viaraw.4_5"), |
|
|
133 |
colsc=palette.cor2, concNo="one") |
|
|
134 |
``` |
|
|
135 |
|
|
|
136 |
```{r main.CLL.T-PLL, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), fig.width=main.cll.tpll[["figure"]][["width"]], fig.height=main.cll.tpll[["figure"]][["height"]]} |
|
|
137 |
#FIG# 2A |
|
|
138 |
grid.draw(main.cll.tpll[["figure"]][["plot"]]) |
|
|
139 |
``` |
|
|
140 |
|
|
|
141 |
```{r main.cll.tpll.legend, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), fig.width=main.cll.tpll[["legend"]][["width"]], fig.height=main.cll.tpll[["legend"]][["height"]], out.width=300, out.height=150} |
|
|
142 |
#FIG# 2A |
|
|
143 |
grid.draw(main.cll.tpll[["legend"]][["plot"]]) |
|
|
144 |
``` |
|
|
145 |
|
|
|
146 |
The major clusters in CLL include: kinase inhibitors targeting the B cell receptor, including idelalisib (PI3K), ibrutinib (BTK), duvelisib (PI3K), PRT062607 (SYK); inhibitors of redox signalling / reactive oxygen species (MIS−43, SD07, SD51); and BH3-mimetics (navitoclax, venetoclax). |
|
|
147 |
|
|
|
148 |
### Effect of drugs with similar target |
|
|
149 |
|
|
|
150 |
Here we compare the effect of drugs designed to target components of the same signalling pathway. |
|
|
151 |
|
|
|
152 |
```{r} |
|
|
153 |
# select the data |
|
|
154 |
mtcll = as.data.frame(t(giveViabMatrix(diag="CLL", |
|
|
155 |
screen="main", |
|
|
156 |
chnnl="viaraw.4_5"))) |
|
|
157 |
colnames(mtcll) = drugs[colnames(mtcll),"name"] |
|
|
158 |
|
|
|
159 |
# function which plots the scatter plot |
|
|
160 |
scatdr = function(drug1, drug2, coldot, mtNEW, min){ |
|
|
161 |
|
|
|
162 |
dataNEW = mtNEW[,c(drug1, drug2)] |
|
|
163 |
colnames(dataNEW) = c("A", "B") |
|
|
164 |
|
|
|
165 |
p = ggplot(data=dataNEW, aes(A, B)) + geom_point(size=3, col=coldot, alpha=0.8) + |
|
|
166 |
labs(x = drug1, y = drug2) + ylim(c(min, 1.35)) + xlim(c(min, 1.35)) + |
|
|
167 |
theme(panel.background = element_blank(), |
|
|
168 |
axis.text = element_text(size = 15), |
|
|
169 |
axis.title = element_text(size = rel(1.5)), |
|
|
170 |
axis.line.x = element_line(colour = "black", size = 0.5), |
|
|
171 |
axis.line.y = element_line(colour = "black", size = 0.5), |
|
|
172 |
panel.grid.major = element_blank(), |
|
|
173 |
panel.grid.minor = element_blank()) + |
|
|
174 |
geom_smooth(method=lm) + |
|
|
175 |
geom_text(x=1, y=min+0.1, |
|
|
176 |
label=paste0("Pearson-R = ", |
|
|
177 |
round(cor(dataNEW$A, dataNEW$B ), 2)), |
|
|
178 |
size = 5) |
|
|
179 |
|
|
|
180 |
return(p) |
|
|
181 |
} |
|
|
182 |
``` |
|
|
183 |
|
|
|
184 |
|
|
|
185 |
```{r cor_scatter, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), , fig.width=6, fig.height=4, warning=FALSE, out.width=420, out.height=280} |
|
|
186 |
#FIG# 2A |
|
|
187 |
scatdr("ibrutinib", "spebrutinib", coldot="deeppink1", mtNEW=mtcll, min=0.4) |
|
|
188 |
scatdr("ibrutinib", "PRT062607 HCl", coldot="deeppink1", mtNEW=mtcll, min=0.4) |
|
|
189 |
scatdr("ibrutinib", "idelalisib", coldot="deeppink1", mtNEW=mtcll, min=0.4) |
|
|
190 |
scatdr("venetoclax", "navitoclax", coldot="goldenrod2", mtNEW=mtcll, min=0.2) |
|
|
191 |
scatdr("SD51", "MIS-43", coldot="dodgerblue3", mtNEW=mtcll, min=0.2) |
|
|
192 |
``` |
|
|
193 |
|
|
|
194 |
|
|
|
195 |
## T-PLL |
|
|
196 |
|
|
|
197 |
Pearson correlation coefficients were calculated based on the mean drug response for the two lowest concentration steps in the main screen across T-PLL samples. |
|
|
198 |
|
|
|
199 |
```{r} |
|
|
200 |
main.tpll = BloodCancerMultiOmics2017:::makeCorrHeatmap( |
|
|
201 |
mt=giveViabMatrix(diag="T-PLL", screen="main", chnnl="viaraw.4_5"), |
|
|
202 |
colsc=palette.cor1, concNo="one") |
|
|
203 |
``` |
|
|
204 |
|
|
|
205 |
```{r main.T-PLL, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), fig.width=main.tpll[["figure"]][["width"]], fig.height=main.tpll[["figure"]][["height"]]} |
|
|
206 |
#FIG# S6 B |
|
|
207 |
grid.draw(main.tpll[["figure"]][["plot"]]) |
|
|
208 |
``` |
|
|
209 |
|
|
|
210 |
```{r main.tpll.legend, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), fig.width=main.tpll[["legend"]][["width"]], fig.height=main.tpll[["legend"]][["height"]], out.width=300, out.height=150} |
|
|
211 |
#FIG# S6 B |
|
|
212 |
grid.draw(main.tpll[["legend"]][["plot"]]) |
|
|
213 |
``` |
|
|
214 |
|
|
|
215 |
Clusters of drugs with high correlation and anti-correlation are shown by red and blue squares, respectively. |
|
|
216 |
|
|
|
217 |
Inhibitors of redox signaling / reactive oxygen species (MIS-43, SD07, SD51) are clustering together. Otherwise, in T-PLL samples correlations are not well pronounced. |
|
|
218 |
|
|
|
219 |
## MCL |
|
|
220 |
|
|
|
221 |
Pearson correlation coefficients were calculated based on the mean drug response for the two lowest concentration steps in the main screen across MCL samples. |
|
|
222 |
|
|
|
223 |
```{r} |
|
|
224 |
main.mcl = BloodCancerMultiOmics2017:::makeCorrHeatmap( |
|
|
225 |
mt=giveViabMatrix(diag="MCL", screen="main", chnnl="viaraw.4_5"), |
|
|
226 |
colsc=palette.cor1, concNo="one") |
|
|
227 |
``` |
|
|
228 |
|
|
|
229 |
```{r main.MCL, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), fig.width=main.mcl[["figure"]][["width"]], fig.height=main.mcl[["figure"]][["height"]]} |
|
|
230 |
#FIG# S6 A |
|
|
231 |
grid.draw(main.mcl[["figure"]][["plot"]]) |
|
|
232 |
``` |
|
|
233 |
|
|
|
234 |
```{r main.mcl.legend, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), fig.width=main.mcl[["legend"]][["width"]], fig.height=main.mcl[["legend"]][["height"]], out.width=300, out.height=150} |
|
|
235 |
#FIG# S6 A |
|
|
236 |
grid.draw(main.mcl[["legend"]][["plot"]]) |
|
|
237 |
``` |
|
|
238 |
|
|
|
239 |
Clusters of drugs with high correlation and anti-correlation are shown by red and blue squares, respectively. |
|
|
240 |
|
|
|
241 |
The major clusters include: kinase inhibitors of the B cell receptor, incl. idelalisib (PI3K), ibrutinib (BTK), duvelisib (PI3K), PRT062607 (SYK); inhibitors of redox signaling / reactive oxygen species (MIS-43, SD07, SD51) and BH3 mimetics (navitoclax, venetoclax). |
|
|
242 |
|
|
|
243 |
|
|
|
244 |
# Disease-specific drug response phenotypes |
|
|
245 |
|
|
|
246 |
Loading the data. |
|
|
247 |
```{r} |
|
|
248 |
data(list=c("lpdAll", "conctab", "patmeta")) |
|
|
249 |
``` |
|
|
250 |
|
|
|
251 |
Preprocessing of drug screen data. |
|
|
252 |
```{r} |
|
|
253 |
#Select rows contain drug response data |
|
|
254 |
lpdSub <- lpdAll[fData(lpdAll)$type == "viab",] |
|
|
255 |
|
|
|
256 |
#Only use samples with complete values |
|
|
257 |
lpdSub <- lpdSub[,complete.cases(t(Biobase::exprs(lpdSub)))] |
|
|
258 |
|
|
|
259 |
#Transformation of the values |
|
|
260 |
Biobase::exprs(lpdSub) <- log(Biobase::exprs(lpdSub)) |
|
|
261 |
Biobase::exprs(lpdSub) <- t(scale(t(Biobase::exprs(lpdSub)))) |
|
|
262 |
|
|
|
263 |
#annotation for drug ID |
|
|
264 |
anno <- sprintf("%s(%s)",fData(lpdSub)$name,fData(lpdSub)$subtype) |
|
|
265 |
names(anno) <- rownames(lpdSub) |
|
|
266 |
``` |
|
|
267 |
|
|
|
268 |
Function to run t-SNE. |
|
|
269 |
```{r} |
|
|
270 |
tsneRun <- function(distMat,perplexity=10,theta=0,max_iter=5000, seed = 1000) { |
|
|
271 |
set.seed(seed) |
|
|
272 |
tsneRes <- Rtsne(distMat, perplexity = perplexity, theta = theta, |
|
|
273 |
max_iter = max_iter, is_distance = TRUE, dims =2) |
|
|
274 |
tsneRes <- tsneRes$Y |
|
|
275 |
rownames(tsneRes) <- labels(distMat) |
|
|
276 |
colnames(tsneRes) <- c("x","y") |
|
|
277 |
tsneRes |
|
|
278 |
} |
|
|
279 |
``` |
|
|
280 |
|
|
|
281 |
Setting color scheme for the plot. |
|
|
282 |
```{r} |
|
|
283 |
colDiagFill = c(`CLL` = "grey80", |
|
|
284 |
`U-CLL` = "grey80", |
|
|
285 |
`B-PLL`="grey80", |
|
|
286 |
`T-PLL`="#cc5352", |
|
|
287 |
`Sezary`="#cc5352", |
|
|
288 |
`PTCL-NOS`="#cc5352", |
|
|
289 |
`HCL`="#b29441", |
|
|
290 |
`HCL-V`="mediumaquamarine", |
|
|
291 |
`AML`="#addbaf", |
|
|
292 |
`MCL`="#8e65ca", |
|
|
293 |
`MZL`="#c95e9e", |
|
|
294 |
`FL`="darkorchid4", |
|
|
295 |
`LPL`="#6295cd", |
|
|
296 |
`hMNC`="pink") |
|
|
297 |
|
|
|
298 |
colDiagBorder <- colDiagFill |
|
|
299 |
colDiagBorder["U-CLL"] <- "black" |
|
|
300 |
``` |
|
|
301 |
|
|
|
302 |
Sample annotation. |
|
|
303 |
```{r} |
|
|
304 |
annoDiagNew <- function(patList, lpdObj = lpdSub) { |
|
|
305 |
Diagnosis <- pData(lpdObj)[patList,c("Diagnosis","IGHV Uppsala U/M")] |
|
|
306 |
DiagNew <- c() |
|
|
307 |
|
|
|
308 |
for (i in seq(1:nrow(Diagnosis))) { |
|
|
309 |
if (Diagnosis[i,1] == "CLL") { |
|
|
310 |
if (is.na(Diagnosis[i,2])) { |
|
|
311 |
DiagNew <- c(DiagNew,"CLL") |
|
|
312 |
} else if (Diagnosis[i,2] == "U") { |
|
|
313 |
DiagNew <- c(DiagNew,sprintf("%s-%s",Diagnosis[i,2],Diagnosis[i,1])) |
|
|
314 |
} else if (Diagnosis[i,2] == "M") { |
|
|
315 |
DiagNew <- c(DiagNew,"CLL") |
|
|
316 |
} |
|
|
317 |
} else DiagNew <- c(DiagNew,Diagnosis[i,1]) |
|
|
318 |
} |
|
|
319 |
DiagNew |
|
|
320 |
} |
|
|
321 |
``` |
|
|
322 |
|
|
|
323 |
Calculate t-SNE and prepare data for plotting the result. |
|
|
324 |
```{r} |
|
|
325 |
#prepare distance matrix |
|
|
326 |
distLpd <- dist(t(Biobase::exprs(lpdSub))) |
|
|
327 |
|
|
|
328 |
#run t-SNE |
|
|
329 |
plotTab <- data.frame(tsneRun(distLpd,perplexity=25, max_iter=5000, seed=338)) |
|
|
330 |
|
|
|
331 |
#annotated patient sample |
|
|
332 |
plotTab$Diagnosis <- pData(lpdSub[,rownames(plotTab)])$Diagnosis |
|
|
333 |
plotTab$Diagnosis <- annoDiagNew(rownames(plotTab,lpdSub)) #consider IGHV status |
|
|
334 |
plotTab$Diagnosis <- factor(plotTab$Diagnosis,levels = names(colDiagFill)) |
|
|
335 |
``` |
|
|
336 |
|
|
|
337 |
```{r tSNE, echo=FALSE, fig.path=plotDir, dev=c("png", "pdf"), fig.width=10, fig.height=8, warning=FALSE, out.width=600, out.height=480} |
|
|
338 |
#FIG# 2 C |
|
|
339 |
p <- (ggplot(plotTab, aes(x=x,y=y)) + |
|
|
340 |
geom_point(size=3, shape= 21, aes(col = Diagnosis, fill = Diagnosis)) + |
|
|
341 |
theme_classic() + |
|
|
342 |
theme(axis.ticks=element_line(color="black",size=0.5), |
|
|
343 |
text=element_text(size=20), |
|
|
344 |
axis.line.x = element_line(color="black",size=0.5), |
|
|
345 |
axis.line.y = element_line(color="black",size=0.5), |
|
|
346 |
legend.position="right") + |
|
|
347 |
scale_fill_manual(values = colDiagFill) + |
|
|
348 |
scale_color_manual(values = colDiagBorder) + |
|
|
349 |
xlab("Component 1") + ylab("Component 2")) + |
|
|
350 |
coord_cartesian(xlim = c(-20,20),ylim=c(-20,20)) |
|
|
351 |
|
|
|
352 |
print(p) |
|
|
353 |
``` |
|
|
354 |
|
|
|
355 |
## Example: dose-response curves |
|
|
356 |
|
|
|
357 |
Here we show dose-response curve for selected drugs and patients. |
|
|
358 |
|
|
|
359 |
First, change concentration index into real concentrations according to `conctab`. |
|
|
360 |
```{r} |
|
|
361 |
lpdPlot <- lpdAll[fData(lpdAll)$type == "viab",] |
|
|
362 |
concList <- c() |
|
|
363 |
for (drugID in rownames(fData(lpdPlot))) { |
|
|
364 |
concIndex <- as.character(fData(lpdPlot)[drugID,"subtype"]) |
|
|
365 |
concSplit <- unlist(strsplit(as.character(concIndex),":")) |
|
|
366 |
ID <- substr(drugID,1,5) |
|
|
367 |
if (length(concSplit) == 1) { |
|
|
368 |
realConc <- conctab[ID,as.integer(concSplit)] |
|
|
369 |
concList <- c(concList,realConc) |
|
|
370 |
} else { |
|
|
371 |
realConc <- sprintf("%s:%s", |
|
|
372 |
conctab[ID,as.integer(concSplit[1])], |
|
|
373 |
conctab[ID,as.integer(concSplit[2])]) |
|
|
374 |
concList <- c(concList,realConc) |
|
|
375 |
} |
|
|
376 |
} |
|
|
377 |
|
|
|
378 |
fData(lpdPlot)$concValue <- concList |
|
|
379 |
lpdPlot <- lpdPlot[,complete.cases(t(Biobase::exprs(lpdPlot)))] |
|
|
380 |
``` |
|
|
381 |
|
|
|
382 |
Select drugs and samples. |
|
|
383 |
```{r} |
|
|
384 |
patDiag <- c("CLL","T-PLL","HCL","MCL") |
|
|
385 |
drugID <- c("D_012_5","D_017_4","D_039_3","D_040_5","D_081_4","D_083_5") |
|
|
386 |
|
|
|
387 |
lpdBee <- lpdPlot[drugID,pData(lpdPlot)$Diagnosis %in% patDiag] |
|
|
388 |
``` |
|
|
389 |
|
|
|
390 |
Prepare the data for plot |
|
|
391 |
```{r} |
|
|
392 |
lpdCurve <- |
|
|
393 |
lpdPlot[fData(lpdPlot)$name %in% fData(lpdBee)$name, |
|
|
394 |
pData(lpdPlot)$Diagnosis %in% patDiag] |
|
|
395 |
lpdCurve <- lpdCurve[fData(lpdCurve)$subtype %in% seq(1,5),] |
|
|
396 |
dataCurve <- data.frame(Biobase::exprs(lpdCurve)) |
|
|
397 |
dataCurve <- cbind(dataCurve,fData(lpdCurve)[,c("name","concValue")]) |
|
|
398 |
tabCurve <- melt(dataCurve, |
|
|
399 |
id.vars = c("name","concValue"), variable.name = "patID") |
|
|
400 |
tabCurve$Diagnosis <- factor(pData(lpdCurve[,tabCurve$patID])$Diagnosis, |
|
|
401 |
levels = patDiag) |
|
|
402 |
tabCurve$value <- tabCurve$value |
|
|
403 |
tabCurve$concValue <- as.numeric(tabCurve$concValue) |
|
|
404 |
|
|
|
405 |
# set order |
|
|
406 |
tabCurve$name <- factor(tabCurve$name, levels = fData(lpdBee)$name) |
|
|
407 |
|
|
|
408 |
#calculate the mean and mse for each drug+cencentration in different disease |
|
|
409 |
tabGroup <- group_by(tabCurve,name,concValue,Diagnosis) |
|
|
410 |
tabSum <- summarise(tabGroup,meanViab = mean(value)) |
|
|
411 |
``` |
|
|
412 |
|
|
|
413 |
|
|
|
414 |
Finally, plot dose-response curve for each selected drug. |
|
|
415 |
```{r viabilityCurve, fig.path=plotDir, dev=c("png", "pdf"), fig.width=4, fig.height=3} |
|
|
416 |
#FIG# 2 C |
|
|
417 |
tconc = expression("Concentration [" * mu * "M]") |
|
|
418 |
fmt_dcimals <- function(decimals=0){ |
|
|
419 |
# return a function responpsible for formatting the |
|
|
420 |
# axis labels with a given number of decimals |
|
|
421 |
function(x) as.character(round(x,decimals)) |
|
|
422 |
} |
|
|
423 |
|
|
|
424 |
for (drugName in unique(tabSum$name)) { |
|
|
425 |
tabDrug <- filter(tabSum, name == drugName) |
|
|
426 |
p <- (ggplot(data=tabDrug, aes(x=concValue,y=meanViab, col=Diagnosis)) + |
|
|
427 |
geom_line() + geom_point(pch=16, size=4) + |
|
|
428 |
scale_color_manual(values = colDiagFill[patDiag]) |
|
|
429 |
+ theme_classic() + |
|
|
430 |
theme(panel.border=element_blank(), |
|
|
431 |
axis.line.x=element_line(size=0.5, |
|
|
432 |
linetype="solid", colour="black"), |
|
|
433 |
axis.line.y = element_line(size = 0.5, |
|
|
434 |
linetype="solid", colour="black"), |
|
|
435 |
legend.position="none", |
|
|
436 |
plot.title = element_text(hjust = 0.5, size=20), |
|
|
437 |
axis.text = element_text(size=15), |
|
|
438 |
axis.title = element_text(size=20)) + |
|
|
439 |
ylab("Viability") + xlab(tconc) + ggtitle(drugName) + |
|
|
440 |
scale_x_log10(labels=fmt_dcimals(2)) + |
|
|
441 |
scale_y_continuous(limits = c(0,1.3), breaks = seq(0,1.3,0.2))) |
|
|
442 |
plot(p) |
|
|
443 |
} |
|
|
444 |
``` |
|
|
445 |
|
|
|
446 |
## Example: drug effects as bee swarms |
|
|
447 |
|
|
|
448 |
```{r viabilityBee, fig.path=plotDir, dev=c("png", "pdf"), fig.width=5, fig.height=10, warning=FALSE} |
|
|
449 |
#FIG# 2 D |
|
|
450 |
lpdDiag <- lpdAll[,pData(lpdAll)$Diagnosis %in% c("CLL", "MCL", "HCL", "T-PLL")] |
|
|
451 |
dr <- c("D_012_5", "D_083_5", "D_081_3", "D_040_4", "D_039_3") |
|
|
452 |
|
|
|
453 |
m <- data.frame(t(Biobase::exprs(lpdDiag)[dr, ]), diag=pData(lpdDiag)$Diagnosis) |
|
|
454 |
m <- melt(m) |
|
|
455 |
m$lable <- 1 |
|
|
456 |
for (i in 1:nrow(m )) { |
|
|
457 |
m[i, "lable"] <- giveDrugLabel(as.character(m[i, "variable"]), conctab, drugs) |
|
|
458 |
} |
|
|
459 |
|
|
|
460 |
|
|
|
461 |
ggplot( m, aes(diag, value, color=factor(diag) ) ) + |
|
|
462 |
ylim(0,1.3) + ylab("Viability") + |
|
|
463 |
xlab("") + |
|
|
464 |
geom_boxplot(outlier.shape = NA) + |
|
|
465 |
geom_beeswarm(cex=1.4, size=1.4,alpha=0.5, color="grey80") + |
|
|
466 |
scale_color_manual("diagnosis", values=c(colDiagFill["CLL"], colDiagFill["MCL"], |
|
|
467 |
colDiagFill["HCL"], colDiagFill["T-PLL"])) + |
|
|
468 |
theme_bw() + |
|
|
469 |
theme(legend.position="right") + |
|
|
470 |
theme( |
|
|
471 |
panel.background = element_blank(), |
|
|
472 |
panel.grid.minor.x = element_blank(), |
|
|
473 |
axis.text = element_text(size=15), |
|
|
474 |
axis.title = element_text(size=15), |
|
|
475 |
strip.text = element_text(size=15) |
|
|
476 |
) + |
|
|
477 |
facet_wrap(~ lable, ncol=1) |
|
|
478 |
``` |
|
|
479 |
|
|
|
480 |
|
|
|
481 |
```{r, include=!exists(".standalone"), eval=!exists(".standalone")} |
|
|
482 |
sessionInfo() |
|
|
483 |
``` |
|
|
484 |
|
|
|
485 |
```{r, message=FALSE, warning=FALSE, include=FALSE} |
|
|
486 |
rm(list=ls()) |
|
|
487 |
``` |