-
Notifications
You must be signed in to change notification settings - Fork 0
/
B110-styleguide.Rmd
256 lines (206 loc) · 8.68 KB
/
B110-styleguide.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
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
---
title: "B110-styleguide_v0.1"
output:
html_document: default
pdf_document: default
word_document: default
editor_options:
chunk_output_type: console
---
```{r setup, include=FALSE}
library(tidyverse)
library(ggpubr)
library(patchwork)
library(ggrepel)
```
## B110 Theme
```{r theme, include=FALSE}
theme_b110<-function(){
theme_classic() +
theme(
axis.text=element_text(size = 16),
axis.title=element_text(size = 16),
plot.title = element_text(size = 22,hjust = 0.5,face="bold"),
legend.title = element_text(size = 22),
legend.text = element_text(size =16),
legend.position = "bottom"
)
}
```
## B110 Colors
```{r colors}
sgi_blue = '#5087C8'
sgi_yellow1 = '#F2EE35'
sgi_yellow2 = '#FED98E'
b110_grey = '#808080'
b110_grey_light = '#909090'
b110_transparent_black = alpha('#000000',0.5)
```
## Quality control Scatter plot
```{r QCscatter, echo=FALSE}
QC_df<-read_delim("~/Desktop/GitHub/Supplemental-Material/Boutroslab_Rstyle_guide/QCscatter_data.txt",delim = "\t")
QC_df %>%
ggplot(aes(x=replicate1,y=replicate2)) +
geom_abline(slope = 1,lty=2) +
geom_vline(xintercept = 0,lty=2) +
geom_hline(yintercept = 0,lty=2) +
geom_point(pch=19,col=b110_transparent_black) +
geom_smooth(col=b110_grey,method="lm") +
stat_cor() +
ylab("replicate 2") +
xlab("replicate 1") +
ggtitle("QC scatterplot") +
theme_b110()
```
## GI Scatter plot (single vs. double mutant)
```{r GIscatter, echo=FALSE}
GI_df<-read_delim("~/Desktop/GitHub/Supplemental-Material/Boutroslab_Rstyle_guide/GI_data_scatter.txt",delim = "\t")
GI_df %>% ggplot() +
geom_point(data=subset(GI_df,significant=="non-significant"), aes(x=singlemut,y=doublemut,col=significant),pch=19,size=5) +
geom_point(data=subset(GI_df,significant!="non-significant"), aes(x=singlemut,y=doublemut,col=significant),pch=19,size=5)+
geom_smooth(method = "lm",data=GI_df, aes(x=singlemut,y=doublemut),inherit.aes = F,se = F,na.rm=T,col="black")+
scale_color_manual(values = c("negative"=sgi_blue,"non-significant"=b110_grey,"positive"=sgi_yellow1)) +
geom_label_repel(data=subset(GI_df,significant!="non-significant"), aes(x=singlemut,y=doublemut,label=gene1),col="black")+
ylab("double knockdown phenotype") +
xlab("single knockdown phenotype") +
ggtitle(paste0("single vs. double mutant (target gene = ",GI_df$gene2,")")) +
theme_b110()
```
## GI Volcano plot (pi-score vs. -log10 FDR)
```{r GI volcano, echo=FALSE}
GI_df<-read_delim("~/Desktop/GitHub/Supplemental-Material/Boutroslab_Rstyle_guide/GI_data_volcano.txt",delim = "\t")
GI_df %>% ggplot() +
geom_vline(xintercept = 0,lty=2) +
geom_hline(yintercept = 1,lty=2) +
geom_point(data=subset(GI_df,significant=="non-significant"), aes(x=piscore,y=-log10(fdr),col=significant),pch=19,size=5) +
geom_point(data=subset(GI_df,significant!="non-significant"), aes(x=piscore,y=-log10(fdr),col=significant),pch=19,size=5)+
scale_color_manual(values = c("negative"=sgi_blue,"non-significant"=b110_grey,"positive"=sgi_yellow1)) +
geom_label_repel(data=subset(GI_df,significant!="non-significant"), aes(x=piscore,y=-log10(fdr),label=gene1),col="black")+
ylab("-log10 FDR") +
xlab("interaction score [pi]") +
ggtitle(paste0("GI vocalno (query gene = ",GI_df$gene2,")")) +
theme_b110()
```
## GI bar plot (buffering vs synthetic lethal)
```{r GIbarplot, echo=FALSE, fig.height=10}
GI_df<-read_delim("~/Desktop/GitHub/Supplemental-Material/Boutroslab_Rstyle_guide/GI_data_barplot.txt",delim = "\t")
a <- GI_df %>%
filter(query=="Dronc") %>%
mutate(category=factor(category,levels = c("targetmain","querymain","expected","double","piscore"))) %>%
group_by(category) %>%
mutate(m=mean(value,na.rm=T)) %>%
ggplot(aes(x=category,y=m,fill=category)) +
geom_bar(stat = "identity",position = "dodge") +
geom_point(aes(y=value),pch=19,size=5,col=b110_grey) +
geom_hline(yintercept = 0,lty=2) +
ylab("interaction score [pi]") +
xlab("measurement") +
ggtitle(paste0("GI barplot (buffering)")) +
scale_fill_manual(values = c("targetmain"=b110_grey_light,"querymain"=b110_grey_light,"expected"=b110_grey_light,"double"=b110_grey_light,"piscore"=sgi_yellow1)) +
theme_b110()
b<- GI_df %>%
filter(query=="raptor") %>%
mutate(category=factor(category,levels = c("targetmain","querymain","expected","double","piscore"))) %>%
group_by(category) %>%
mutate(m=mean(value,na.rm=T)) %>%
ggplot(aes(x=category,y=m,fill=category)) +
geom_bar(stat = "identity",position = "dodge") +
geom_point(aes(y=value),pch=19,size=5,col=b110_grey) +
geom_hline(yintercept = 0,lty=2) +
ylab("interaction score [pi]") +
xlab("measurement") +
ggtitle(paste0("GI barplot (buffering)")) +
scale_fill_manual(values = c("targetmain"=b110_grey_light,"querymain"=b110_grey_light,"expected"=b110_grey_light,"double"=b110_grey_light,"piscore"=sgi_blue)) +
theme_b110()
a+b + plot_layout(ncol = 1,nrow=2,heights = 10)
```
## Multi feature GI histograms
```{r}
GI_histograms_sampled<-read_delim("~/Desktop/GitHub/Supplemental-Material/Boutroslab_Rstyle_guide/GI_data_histograms.txt",delim = "\t")
GI_histograms_sampled %>% ggplot(aes(score,fill=grouping)) +
geom_histogram(aes(y=..density..),bins=100)+
facet_wrap(~feature,scales="free") +
xlim(-15,15) +
theme_b110() +
scale_fill_manual(values=c(b110_grey, sgi_blue, sgi_yellow1))
```
## Single feature GI profile heatmap
```{r}
heat_dat <- read_delim("~/Desktop/GitHub/Supplemental-Material/Boutroslab_Rstyle_guide/GI_data_profiles.txt",delim = "\t")
ordx<-heat_dat %>% arrange(gene_symbol) %>% spread(gene_symbol,mpi,fill = 0) %>% arrange(query_name) %>% dplyr::select(-query_name) %>% dist(method = "euclidean") %>% hclust(method = "ward.D2") %>% .$order
namesx<-heat_dat %>% arrange(gene_symbol) %>% spread(gene_symbol,mpi,fill = 0) %>% arrange(query_name) %>% pull(query_name) %>% .[ordx]
ordy<-heat_dat %>% arrange(gene_symbol) %>% spread(query_name,mpi,fill = 0) %>% arrange(gene_symbol) %>% dplyr::select(-gene_symbol) %>% dist(method = "euclidean") %>% hclust(method = "ward.D2") %>% .$order
namesy<-heat_dat %>% arrange(gene_symbol) %>% spread(query_name,mpi,fill = 0) %>% arrange(gene_symbol) %>% pull(gene_symbol) %>% .[ordy]
heat_dat %>%
mutate(gene_symbol=factor(gene_symbol,levels = namesy)) %>%
mutate(query_name=factor(query_name,levels = namesx)) %>%
complete(query_name,gene_symbol) %>%
mutate(mpi=if_else(mpi>10,10,mpi),mpi=if_else(mpi<(-10),(-10),mpi)) %>%
ggplot(
aes(
x=query_name,
y=gene_symbol,
fill=mpi)
) +
scale_fill_gradient2(low=sgi_blue,mid ="black" ,high = sgi_yellow1,na.value = b110_grey,midpoint = 0) + #b110_grey
geom_tile() +
ylab("target genes") +
xlab("query genes") +
ggtitle("GI profile clustering") +
theme_b110() +
theme(axis.text.x = element_text(angle = 45, hjust = 1), axis.text=element_text(size = 10))
```
## Single feature GI profile heatmap
```{r}
corrord<-heat_dat %>%
arrange(gene_symbol) %>%
spread(gene_symbol,mpi,fill = NA_real_) %>%
arrange(query_name) %>%
dplyr::select(-query_name) %>%
corrr::correlate(method = "pearson",diagonal=1,use="p") %>%
dplyr::select(-rowname) %>%
dist(method = "euclidean") %>%
hclust(method = "ward.D2") %>%
.$order
corrnames<-heat_dat %>%
arrange(gene_symbol) %>%
spread(gene_symbol,mpi,fill = NA_real_) %>%
arrange(query_name) %>%
dplyr::select(-query_name) %>%
corrr::correlate(method = "pearson",diagonal=1,use="p") %>%
pull(rowname) %>%
.[corrord]
heat_dat %>%
spread(gene_symbol,mpi,fill = NA_real_) %>%
dplyr::select(-query_name) %>%
corrr::correlate(method = "pearson",diagonal=1,use="p") %>%
corrr::stretch() %>%
mutate(x=factor(x,levels = corrnames)) %>%
mutate(y=factor(y,levels = corrnames)) %>%
ggplot(
aes(
x=x,
y=y,
fill=r)
) +
scale_fill_gradient2(na.value = b110_grey,midpoint = 0) +
geom_tile() +
ylab("target genes") +
xlab("target genes") +
ggtitle("GI profile correlations") +
theme_b110() +
theme(axis.text.x = element_text(angle = 45, hjust = 1), axis.text=element_text(size = 10))
```
## Particular pairwise interactions of gene groups in a point scatter plot
```{r}
particular_interactions <- read_delim("~/Desktop/GitHub/Supplemental-Material/Boutroslab_Rstyle_guide/GI_data_particluar.txt",delim = "\t")
particular_interactions %>%
ggplot(aes(x=gene_symbol1,y=gene_symbol2,size=abs(scale(score)),col=factor(sign(score)))) +
geom_point() +
scale_color_manual(values = c("1"=sgi_yellow1,"-1"=sgi_blue)) +
theme_b110()+
theme(axis.text.x = element_text(angle = 45, hjust = 1))+
scale_size_area() +
xlab("Signaling members")+
ylab("Signaling members")
```