-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdrug_ranges.r
41 lines (32 loc) · 1.13 KB
/
drug_ranges.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
library(dplyr)
library(ggplot2)
library(reshape2)
b = import('base')
ar = import('array')
gdsc = import('data/gdsc')
OUTFILE = commandArgs(TRUE)[1] %or% 'drug_ranges.pdf'
tissues = gdsc$tissues()
Ys = gdsc$drug_response('IC50s')
ar$intersect(tissues, Ys, along=1)
min_conc = gdsc$drug$conc('min', colnames(Ys))
max_conc = gdsc$drug$conc('max', colnames(Ys))
pdf(OUTFILE, width=26, height=20)
for (drug in sort(colnames(Ys))) {
df = data.frame(tissue=tissues, drug=Ys[,drug])
med = function(x) median(x, na.rm=TRUE)
minc = log10(min_conc[drug])
maxc = log10(max_conc[drug])
rect = data.frame(xmin=-Inf, xmax=Inf, ymin=minc, ymax=maxc)
box = ggplot(df, aes(x=reorder(tissue, drug, FUN=med), y=drug)) +
geom_boxplot() +
xlab("Cancer type") +
ylab("- log IC50") +
theme_bw() +
geom_abline(intercept=minc, slope=0, linetype="dotted") +
geom_abline(intercept=maxc, slope=0, linetype="dotted") +
geom_rect(data=rect, aes(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax),
fill="plum2", alpha=0.1, inherit.aes=FALSE) +
ggtitle(drug)
print(box)
}
dev.off()