-
Notifications
You must be signed in to change notification settings - Fork 0
/
Visualizing_the_results.R
2786 lines (2353 loc) · 141 KB
/
Visualizing_the_results.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
### Figure 1: Visualization of the FVA flux results of selected metabolites with literature evidence
### Figure 2: a) Predicted essential gene with common-essential and literature support
### Figure 2: b) Single drug targets
### Figure 3: Predicted combinations viability reduction in silico (a) and their targets (b)
### Figure 4: In vitro potency and CSF bio availability of the predicted drugs and combinations
### Figure 5: Xenografts data in screening databases (a) and literature (b)
### Figure 6: a) Summary of effective, ineffective, untested drugs in vitro, xenografts and clinical trials
### Figure 6: b) Survival measures of phase 2, 2-arms, clinical trials of the effective drugs
setwd("./GliomGEM")
signif.ceiling <- function(x, n){
pow <- floor( log10( abs(x) ) ) + 1 - n
y <- ceiling(x / 10 ^ pow) * 10^pow
# handle the x = 0 case
y[x==0] <- 0
y
}
wrap_text <- function(string, n) {
spaces <- str_locate_all(string, " ")[[1]][,1]
chars <- nchar(string)
for(i in 1:floor(chars/n)) {
s <- spaces[which.min(abs(spaces - n*i))]
substring(string, s, s) <- "\n "
}
return(string)
}
firstup <- function(x) {
x <- tolower(x)
substr(x, 1, 1) <- toupper(substr(x, 1, 1))
x
}
library(clipr)
#remotes::install_github("simmwill/coolors")
library(coolors)
library(data.table)
library(devtools)
library(DT)
#library(dplyr)
library(extrafont)
library(ggallin)
library(ggtext)
library(ggrepel)
library(ggplot2)
library(ggh4x)
library(gridExtra)
library(grid)
library(ggpubr)
library(ggplotify)
library(hrbrthemes)
library(knitr)
library(lemon)
#install.packages("pacman")
#install.packages("remotes")
#install.packages(c("here", "mice", "naniar"))
#remotes::install_github("emilelatour/lamisc")
library(lamisc)
library(vroom)
library(magrittr)
library(openxlsx)
library(pheatmap)
library(patchwork)
library(readxl)
library(rrcov)
library(RColorBrewer)
library(stringi)
library(scales)
library(tidyr)
library(tidytext)
library(tidyverse)
library(tibble)
library(readr)
library(vegalite)
library(vroom)
set_breaks = function(limits) {
seq(limits[1], limits[2], by = 1)
}
### Visualze TCGA metadata
tcga_meta <- read_csv('./data/TCGA_TCGBiolinks_metadata_Summary.csv')
# Number of samples in each subtype
table(tcga_meta$WHO_2021)
# Visualizing the metadata itself
summary(tcga_meta[,c('definition','paper_IDH.status','paper_X1p.19q.codeletion','primary_diagnosis')])
x <- table(tcga_meta[,c('definition','paper_IDH.status','paper_X1p.19q.codeletion','primary_diagnosis')], useNA = "always")
x<- as.data.frame(x)
x <- x[x$Freq>0,]
fwrite(x,'./data/TCGA_TCGBiolinks_metadata_statistics.csv',row.names = TRUE)
# Creating a Mosaoic plot of 3 features definition + paper_IDH.status + primary_diagnosis
library(vcd)
library(MASS)
library(forcats)
library(viridis)
tcga_meta_ <- tcga_meta[,c('definition','paper_IDH.status','paper_X1p.19q.codeletion','primary_diagnosis')] #'definition'
tcga_meta_table <- structable(~definition+paper_IDH.status+primary_diagnosis,data=tcga_meta_ )
# Mosiac plot for definition + primary_diagnosis + paper_IDH.status
mosaic(~ definition + primary_diagnosis + paper_IDH.status, data = tcga_meta_table,
split_vertical = c(TRUE, FALSE, TRUE),
labeling_args = list(rot_labels = c(bottom = 90, top = 90,left=0,right=90)),
margins = c(left = 13, bottom = 5,top=10),
offset_labels = c(left = 4.6,top=3.2,bottom=1),
offset_varnames=c(left= 9))
library(ggmosaic)
flights <- fly %>%
filter(!is.na(do_you_recline), !is.na(rude_to_recline))
tcga_meta_ <- tcga_meta[,c('paper_Histology','paper_IDH.status','paper_X1p.19q.codeletion','WHO_2021')]
tcga_meta_ <- na.omit(tcga_meta_)
colnames(tcga_meta_) <- str_replace(colnames(tcga_meta_) ,'paper_','')
tcga_meta_$IDH.status[tcga_meta_$IDH.status=='WT'] <- 'IDH Wt '
tcga_meta_$IDH.status[tcga_meta_$IDH.status=='Mutant'] <- 'IDH Mut '
tcga_meta_$X1p.19q.codeletion[tcga_meta_$X1p.19q.codeletion=='non_codel'] <- 'Non Codel'
tcga_meta_$X1p.19q.codeletion[tcga_meta_$X1p.19q.codeletion=='codel'] <- 'Codel'
tcga_meta_$IDH.status <- factor(tcga_meta_$IDH.status,c('IDH Wt ','IDH Mut '))
tcga_meta_$X1p.19q.codeletion <- factor(tcga_meta_$X1p.19q.codeletion,c('Non Codel','Codel'))
tcga_meta_$Histology <- str_to_sentence(tcga_meta_$Histology )
tcga_meta_$Histology <- factor(tcga_meta_$Histology,rev(c('Astrocytoma','Glioblastoma','Oligodendroglioma','Oligoastrocytoma')))
tcga_meta_$WHO_2021
mosaic2_examp <- ggplot(data = tcga_meta_) +
geom_mosaic(aes(x=product(IDH.status,Histology, X1p.19q.codeletion),
fill = Histology, alpha = IDH.status),offset = 0.02, na.rm = TRUE) +
geom_mosaic_text(aes(x = product(IDH.status,Histology, X1p.19q.codeletion)), na.rm = TRUE, repel = TRUE)+
scale_fill_viridis(discrete = TRUE)+
scale_alpha_manual(values =c(.6,.9)) +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = .5,size = 12),
axis.text.y = element_text(angle = 0,size = 12),
axis.title.x = element_text(angle = 0,size = 14),
axis.title.y = element_text(angle = 90,size = 14)) +
labs(y="Histology", x="IDH mutation status + 1p.19q.codeletion",
title = "Stratification of TCGA-GBM & TCGA-LGG patients\nbased on IDH mutation and 1p/19q codeletion")
mosaic2_examp
ggsave('Figure/Fig_XX_metadata.png', mosaic2_examp,units = 'in', width = 10,height = 8,dpi = 300)
### Figure 1: Visualization of the FVA flux results and compare with literature evidence for sub type specific updates
fva <- read_csv('./Sample_models/Subtypes_Models_FVA.csv') # Fluxes of exchange reactions
fva %>% pivot_longer(cols = c( "minFlux_ast", "maxFlux_ast", "minFlux_gbm", "maxFlux_gbm" ,"minFlux_odg" ,"maxFlux_odg"),
names_to = 'Model',values_to = 'Flux') -> fva
fva %>% group_by(ex_rxns) %>%
mutate(to_keep = if_else(is.na(Flux) | abs(Flux)<1,'remove','keep')) -> fva
#fva %>% group_by(ex_rxns) %>% filter(any(to_keep=='keep')) -> fva
#fva <- na.omit(fva)
#fva <- fva[fva$Flux>1e-4,]
unique(fva$ex_rxns)
fva$Subtype <- str_to_upper(str_split(fva$Model,'_',simplify = T)[,2])
fva$FluxType <- str_split(fva$Model,'Flux',simplify = T)[,1]
fva %>% group_by(ex_rxns) %>%
mutate(average_flux = mean(abs(Flux), na.rm=TRUE)) -> fva
# Ceiling the measure to the 2nd decimal
fva$Flux_ <- lapply(as.numeric(fva$Flux) , function(x) signif.ceiling(x, 3))
fva$newname <- str_c(fva$Subtype,'_',fva$FluxType)
fva$FluxType[fva$FluxType=='min'] <- 'Min'
fva$FluxType[fva$FluxType=='max'] <- 'Max'
#fva$FluxType <- factor(fva$FluxType ,levels = c('Min','Max'))
met_list <- c("Glutamine","Thymidine","Glutamate",
"4-Aminobutanoate","L-Phenylalanine","Myo-Inositol","Lactate")
fva$Subtype_rxn <- str_c(fva$Formula,fva$Subtype)
fva %>% group_by(Subtype_rxn) %>% mutate(ymin=min(Flux),ymax=max(Flux)) -> fva
fva$Subtype <- factor(fva$Subtype,c('GBM','AST','ODG'))
fva$Formula <- str_replace(fva$Formula,' <=>','')
#fva %>% group_by(Formula, Subtype) %>%
# mutate(Reaction=ifelse(sum(Flux)==0,'Inactive','Release')) ->fva
fva$Reaction <- NA
#fva$Reaction[fva$ymin=='NaN' & fva$ymax=='NaN' ] <- 'Inactive'
#fva$Reaction[fva$ymin==0 & fva$ymax==0] <- 'Inactive'
#fva$Reaction[fva$ymin=>-1e-12 & fva$ymax<=1e-12 ] <- 'Inactive'
#fva$Reaction[fva$ymin=>0 & fva$ymax>0 ] <-'Release' 3
#fva$Reaction[fva$ymax<=0 & fva$ymin<0 ] <- 'Uptake'
#fva$Reaction[fva$ymin<0 & fva$ymax>0 ] <-'Uptake/Release'
#fva$Reaction[fva$ymin=>-1e-12 & fva$ymax<=1e-12 ] <- 'Inactive'
fva$Reaction[fva$Flux==0 | fva$Flux =='NaN'] <- 'Inactive'
#fva$Reaction[fva$ymin=>0 & fva$ymax>0 ] <-'Release' 3
fva$Reaction[fva$Flux <0 ] <- 'Uptake'
fva$Reaction[fva$Flux >0 ] <-'Release'
fva$VMH_ID <- str_split(fva$ex_rxns,'EX_',simplify = T)[,2]
fva$VMH_ID <- str_split(fva$VMH_ID,'\\[',simplify = T)[,1]
fva$VMH_ID <- str_to_upper(fva$VMH_ID)
### Map VMH metaboolite IDs to super class
dico_met <- read_delim('./Generic_Models/metabolites_09_2021.csv',delim = '\t')
require(XML)
data <- xmlParse("csf_metabolites.xml")
#data <- xmlParse("hmdb_metabolites.xml")
xml_data <- xmlToList(data)
xml_data[5]$metabolite$taxonomy$direct_parent
length(xml_data$metabolite$accession)
class_df <- data.frame(metHMDBID=rep('',length(xml_data)),
VMH_ID=NA, Name=NA,
super_class=NA, class=NA,sub_class=NA,molecular_framework=NA)
for(i in 1:length(xml_data)){
class_df[i,'metHMDBID'] <- as.character(xml_data[i]$metabolite$accession)
class_df[i,'Name'] <- xml_data[i]$metabolite$name
vmh_id <- xml_data[i]$metabolite$vmh_id
super_class <- xml_data[i]$metabolite$taxonomy$super_class
class <- xml_data[i]$metabolite$taxonomy$class
sub_class <- xml_data[i]$metabolite$taxonomy$sub_class
molecular_framework <- xml_data[i]$metabolite$taxonomy$molecular_framework
if (!is.null(vmh_id)){ class_df[i,'VMH_ID'] <-vmh_id }
else{class_df[i,'VMH_ID'] <- NA }
if (!is.null(super_class)){ class_df[i,'super_class'] <-super_class }
else{class_df[i,'super_class'] <- NA }
if (!is.null(class)){ class_df[i,'class'] <-class }
else{class_df[i,'class'] <- NA }
if (!is.null(sub_class)){ class_df[i,'sub_class'] <-sub_class }
else{class_df[i,'sub_class'] <- NA }
if (!is.null(molecular_framework)){ class_df[i,'molecular_framework'] <-molecular_framework }
else{class_df[i,'molecular_framework'] <- NA }
}
write_csv(class_df, 'Generic_Models/HMDB_Metabolie_Taxonomy.csv')
####
fva <- left_join(fva,class_df)
fva$super_class[is.na(fva$super_class)] <- 'Undefined'
unique(fva$Formula[is.na(fva$super_class)])
## Count the number of narriow-bound reactions
fva%>% group_by(ex_rxns, Subtype) %>%
mutate(rank_3_1 = Flux[FluxType=="Max"] - Flux[FluxType=="Min"]) -> fva
n_distinct(fva$ex_rxns[fva$rank_3_1 >200])
min(fva$rank_3_1 )
max(na.omit(fva$rank_3_1 ))
min(na.omit(fva$rank_3_1 ))
n_distinct(fva$ex_rxns[fva$rank_3_1 >1e-4 & abs(fva$Flux) >250])
unique(fva$ex_rxns[fva$rank_3_1 >1e-4 & abs(fva$Flux) >250])
#dico_met <- left_join(dico_met,class_df)
#
# dico_met$super_class <- NA
# dico_met$class <- NA
# dico_met$sub_class <- NA
# dico_met$molecular_framework<- NA
# for(i in 1:3){ #hmdb_ids
# hmdb_id <- hmdb_ids[i]
# x <- HmdbEntry(
# prefix = "http://www.hmdb.ca/metabolites/",
# id = hmdb_id,
# keepFull = TRUE
# )
# y<- store(x)
# super_class <- y$taxonomy$super_class
# class<- y$taxonomy$class
# sub_class <- y$taxonomy$sub_class
# molecular_framework <- y$taxonomy$molecular_framework
# dico_met[dico_met$metHMDBID==hmdb_id, 'super_class'] <- super_class
# dico_met[dico_met$metHMDBID==hmdb_id, 'class'] <- class
# dico_met[dico_met$metHMDBID==hmdb_id, 'sub_class'] <- sub_class
# dico_met[dico_met$metHMDBID==hmdb_id, 'molecular_framework'] <- molecular_framework
# }
#
# data(hmdb1)
# y<- store(hmdb1)
# x <- diseases(hmdb1)
# names(store(hmdb1))
# biospecimens(hmdb1)
# tissues(hmdb1)
# hmdb1
# as.data.frame(hmdb1)
# x <- HmdbEntry(
# prefix = "http://www.hmdb.ca/metabolites/",
# id = "HMDB0000005",
# keepFull = TRUE
# )
# biospecimens(x)
# y<- store(x)
# y$name
# y$taxonomy$super_class
# y$taxonomy$molecular_framework
# y$vmh_id
# Read the literature evidence of the exchange reaction to add in the plot
fva_literature <- read_excel('./Supplementary File 2.xlsx',sheet = "Table_S10_Exchange_Reactions")
colnames(fva_literature) <- c("Formula","Prediction","Literature","Subtype","Matching", "Cell Lines/ Tissue samples", "Reference" )
#fva_literature$Literature <- wrap_text(fva_literature$Literature,n=25)
fva_literature$Formula <- str_split(fva_literature$Formula,'\ ',simplify = T)[,1]
fva_literature$FluxType <- c('Max','Max','Min','Max','Max','Max',"Max")
fva_selected <- fva[str_detect(fva$Formula,paste0(met_list,collapse = '|')),]
fva_selected <- fva_selected[fva_selected$Formula!= "(R)-Lactate",]
fva_selected$Formula <- factor(fva_selected$Formula,fva_literature$Formula)
#fva_selected_2 <- fva[str_detect(fva$Formula,paste0(c("Glutamine","Thymidine"),collapse = '|')),]
fva_selected <- left_join(fva_selected,fva_literature) # Joining, by = c("Formula", "Subtype")
fva_selected$Literature2 <- str_wrap(fva_selected$Literature , width = 40)
fva_selected$Subtype <- factor(fva_selected$Subtype,c("GBM","AST","ODG"))
fill = rev(c("cyan","cyan","cyan","cyan","cyan","cyan","magenta"))
muh_grob <- grid::rectGrob(
x=0, y=1:7, gp=gpar(
color='black', fill=fill, alpha=0.2))#rainbow(7)
fva_selected$Subtype_ <-str_c("i",fva_selected$Subtype)
fva_selected$Subtype_ <- factor(fva_selected$Subtype_,c("iGBM","iAST","iODG"))
P1 <- ggplot(fva_selected,aes(y=Formula,alpha=FluxType,x = abs(Flux)/10,group=Subtype_,shape=Reaction,
color=Subtype_,fill=Subtype_,size=FluxType))+
geom_point(position = position_dodge(width = 0.5))+ #
geom_linerange(aes(color = Subtype_,xmin=abs(ymin)/10,xmax=abs(ymax)/10), size = 1, alpha = 0.5,
position = position_dodge(width = 0.5))+
scale_color_manual(values = c('#BB173A','#2F6790','forestgreen'))+
scale_alpha_manual(values=c(1,0.3))+
scale_size_manual(values=c(4,6))+
xlab("Absolute relative flux rate (%)") +
ylab("Exchange reactions") +theme_classic()+
theme(axis.text.x = element_text(angle = 0,size = 14),
axis.text.y = element_text(angle = 0,size = 14,face='bold'),
axis.title.y = element_text(size = 14),
#panel.background = element_rect(fill = "grey92", colour = NA)
) + guides(size="none",alpha="none",fill=guide_legend(title = "Subtype\nmodel"),
color=guide_legend(title = "Subtype\nmodel",legend.title=element_text(size=14),legend.label=element_text(size=14))) +
coord_cartesian(clip='off') +
theme(axis.text.x = element_text(margin=margin(t=10),size =14),
strip.text = element_text(size = 14),
legend.text=element_text(size=12),legend.title = element_text(size=13),
axis.title = element_text(size = 12))+
annotation_custom(grob=muh_grob, ymin = -0, ymax = 1, xmin = -24, xmax=8)
P1
P1_final <-P1 + xlim(0, 130) +
geom_text_repel(aes(label=Literature2),size=3.8,alpha=0.9,
#force = 4,
nudge_x = 5,hjust=0,
nudge_y = 0.43,
direction = "both",
fontface = 'bold',
segment.colour = "black",
box.padding = unit(0.35, "lines"),
segment.size = 0.2
)
P1_final
ggsave(P1_final,filename="Figure/Figure_1_Exchange_Reactions.png", units="in", width=11, height=8.5)
#ggsave(P1_final,filename="Figure/Figure_1_Exchange_Reactions.pdf", units="in", width=11, height=8.5)
# ## FVA for all reactions
fva %>% group_by(Formula) %>%
mutate(rank = sum(abs(Flux),na.rm = T))%>%
group_by(class) %>%
mutate(rank_2 = sum(abs(Flux),na.rm = T))-> fva
n_distinct(fva$class)
n_distinct(fva$sub_class)
unique(fva$molecular_framework)
CLASS <- sub_class
fva$Subtype_ <-str_c("i",fva$Subtype)
fva$Subtype_ <- factor(fva$Subtype_,c("iGBM","iAST","iODG"))
P_S1 <- ggplot(fva,aes(y=reorder_within(Formula,rank,rank_2),alpha=FluxType,x = abs(Flux)/10,
group=Subtype_,
shape=Reaction,
color=class,fill=class,
#color=sub_class,fill=sub_class,
size=FluxType))+
geom_point(position = position_dodge(width = 0.7))+ #
geom_linerange(aes(xmin=abs(ymin)/10,xmax=abs(ymax)/10), size = 0.6, alpha = 0.5,
position = position_dodge(width = 0.7))+
ggtitle("Uptake flux rate in the three glioma subtype models") +
#scale_color_manual(values = c('#BB173A','#2F6790','forestgreen'))+
scale_y_reordered()+
scale_alpha_manual(values=c(1,0.3))+
scale_size_manual(values=c(2,3))+
xlab("Absolute relative flux rate (%)") +
ylab("Reactions") +theme_classic() +
guides(size="none",alpha="none",
color=guide_legend(legend.title=element_text(size=14),legend.label=element_text(size=14))) +
facet_grid(.~Subtype_,scales = "free")+ #Subtype
theme(axis.text.x = element_text(angle = 0,size = 11),
axis.text.y = element_text(angle = 0,size = 8),
)
P_S1
ggsave(P_S1,filename="Figure/FigS_X_Subtype_Models_FVA.png", units="in", width=11, height=12)
ggsave(P_S1,filename="Figure/FigS_X_Subtype_Models_FVA.pdf", units="in", width=11, height=12)
### Figure 2: Essential gene with common-essential and literature support
### Add drug targets
sko_df <- read_csv('Integrated_Drug_Db/SKO_result_with_Effective_Targets.csv')
sko_df$TYPE2 <- "Single Drug Deletion"
dko_df = read_csv('Integrated_Drug_Db/DKO_result_with_Effective_Targets.csv')
#colnames(dko_df) <- c('Drugs','Subtype','grRatio','DelRxns')
#dko_df$ <-'__'
dko_df$TYPE2 <- "Double Drug Deletion"
dko_df %>% separate_rows(Drugs,sep=' ;')%>%distinct() ->dko_df
sko_df <- rbind(sko_df,dko_df)
sko_df$TYPE2 <- factor(sko_df$TYPE2,c("Single Drug Deletion","Double Drug Deletion"))
sko_df <- sko_df[sko_df$Drugs !="fludarabine",]
unique(sko_df$Drugs)
## Convert ENTREZ to symbol sing in house dico disctionary
# sko_df_longer <- sko_df[,colnames(sko_df)!='All_Targets']
# cols <- c("Effective_Targets", "All_Targets")
# sko_df_longer %>% separate_rows(Effective_Targets,sep='; ')%>%distinct()%>%
# mutate(entrez_id=str_split(Effective_Targets,"[.]",simplify = TRUE)[,1])->sko_df_longer
sko_df_longer <- sko_df[,colnames(sko_df)!='Effective_Targets']
cols <- c("Effective_Targets", "Effective_Targets")
sko_df_longer %>% separate_rows(All_Targets,sep='; ')%>%distinct()%>%
mutate(entrez_id=str_split(All_Targets,"[.]",simplify = TRUE)[,1])->sko_df_longer
dico = read_csv('./Generic_Models/dico_201911.csv')
dico <- dico[,c('ENTREZ','SYMBOL')]
colnames(dico) <- c('entrez_id','SYMBOL')
dico <- na.omit(dico)
dico$entrez_id <- as.character(dico$entrez_id)
sko_df_longer <- left_join(sko_df_longer,dico)
sko_df_longer <- sko_df_longer[,c('Drugs','Subtype','TYPE2','SYMBOL','DelRxns')]
## Removing drug targets from the individual drugs in the combination
integrated_db <- read_csv('Integrated_Drug_Db/DrugBank_PROMISCUOUS_DRH.csv');
integrated_db <- integrated_db[integrated_db$name%in% sko_df_longer$Drugs,]
colnames(integrated_db)[1] <- 'Drugs'
sko_df_longer <- left_join(sko_df_longer,integrated_db[,c('Drugs','SYMBOL','database')],)
sko_df_longer <- distinct(sko_df_longer[!is.na(sko_df_longer$database),
c('Drugs','Subtype','TYPE2','SYMBOL','DelRxns')])
#### Create a dataframe of gene, rxnname and rule
recon_pathways <- read_csv('Generic_Models/Recon3D_Rxn_Rules_Pathways.csv')
recon_pathways$SYMBOL <- recon_pathways$Rule
recon_pathways %>% separate_rows(SYMBOL,sep=' | ')%>%distinct()->recon_pathways_longer
recon_pathways_longer %>% separate_rows(SYMBOL,sep=' & ')%>%distinct()->recon_pathways_longer
recon_pathways_longer$SYMBOL <- str_replace_all(recon_pathways_longer$SYMBOL,'[(|)]','')
recon_pathways_longer <- recon_pathways_longer[!(recon_pathways_longer$SYMBOL %in% c("","&","|")),]
recon_pathways_longer <- recon_pathways_longer[! is.na(recon_pathways_longer$SYMBOL),]
recon_pathways_rule <- distinct(recon_pathways_longer[,c('SYMBOL',"Rule",'Pathway')])
recon_pathways_rxn <- distinct(recon_pathways_longer[,c("Rxn",'SYMBOL',"Rule",'Pathway')])
recon_pathways_longer <- distinct(recon_pathways_longer[,c('SYMBOL','Pathway')])
## Keep the targets of the deleted rxns
sko_df_longer_delrxn <- sko_df_longer
sko_df_longer_delrxn %>% separate_rows(DelRxns,sep='; ')%>%distinct()->sko_df_longer_delrxn
sko_df_longer_delrxn <- left_join(sko_df_longer_delrxn,recon_pathways_rxn,by=c('DelRxns'='Rxn')) #Rxn'='DelRxns',
sko_df_longer_delrxn %>% group_by(Drugs,Subtype,TYPE2) %>%
summarise(SYMBOL = intersect(SYMBOL.x,SYMBOL.y)) -> sko_df_longer_delrxn
sko_df_longer <- sko_df_longer_delrxn
write_csv(sko_df_longer,"./Integrated_Drug_Db/Predicted_drug_targets_filtered.csv")
####
genes_literature <- read_excel('./Supplementary File 2.xlsx',sheet = "Table_S11_Essential_Genes")
depmap_genes = read.csv("CRISPR/22Q1_Genes_Metadata.csv")
#data <- read.csv('./Sample_models/Essential_genes_UpSet_table_DMEM.csv',sep = ",")
data <- read.csv('./Sample_models/Essential_genes_UpSet_table_.csv',sep = ",")
depmap_scr_dep <- read_csv('./CRISPR/22Q1_DepMap_Chronos_Score_Probability.csv')
data
data%>%
pivot_longer(!Row,names_to = "Genes", values_to = "Predicted_Essential") ->data_longer
data_longer$Row <- str_replace(data_longer$Row ,'Thiele2020_','')
data_longer$Row <- str_replace(data_longer$Row ,'__','_')
data_longer$Row <- str_replace(data_longer$Row,'_IDH_wt','')
data_longer$Row <- str_replace(data_longer$Row,'_IDH_mut','')
data_longer$Row <- str_replace(data_longer$Row,'_Codel','')
data_longer$Genes <- str_replace(data_longer$Genes,'X','')
data_longer%>%separate(Row, c("Model", "Data","Curation","Subtype"), "_") ->data_longer
# drop Human1 models
data_longer[str_detect(data_longer$Model,'Recon3D'),]-> data_longer
data_longer[str_detect(data_longer$Data,'Rahman2015'),]-> data_longer
data_longer[str_detect(data_longer$Curation,'CSF'),]-> data_longer
data_longer[!str_detect(data_longer$Subtype,'CTRL'),]-> data_longer
## number of common essentials in the predictions
colnames(data_longer) <- c("Model" , "Data" , "Curation", "Subtype" , "Gene_ENTREZ" ,'Predicted_Essential')
depmap_genes <- depmap_genes[depmap_genes$Essentiality_Type!='Non-Essential',]
depmap_genes$Gene_ENTREZ <- as.character(depmap_genes$Gene_ENTREZ)
depmap_genes$Symbol <- str_replace(depmap_genes$Symbol," ","")
data_longer_ <- left_join(data_longer,depmap_genes)
## Cluster drugs by genes
sko_df_genes <- sko_df_longer %>% group_by(SYMBOL,TYPE2) %>%
summarise(Drugs_ = paste0(unique(Drugs),collapse = "; " ))
sko_df_longer <- left_join(sko_df_longer,
data_longer_[data_longer_$Predicted_Essential==1,c('Symbol',"Predicted_Essential")],
by=c('SYMBOL'='Symbol'))
sko_df_longer$Predicted_Essential[is.na(sko_df_longer$Predicted_Essential)] <- 0
sko_df_longer$SYMBOL_ <- sko_df_longer$SYMBOL
sko_df_longer$SYMBOL_[sko_df_longer$SYMBOL %in% c("CA7","CA6","CA5B","CA3","CA12","CA14","CA1","CA9","CA5A","CA4","CA2","CA8","CA13") ] <- "CA*"
sko_df_genes <- distinct(sko_df_longer[,c('SYMBOL','SYMBOL_','Drugs','Subtype','TYPE2',
'Predicted_Essential')])#
sko_df_genes$Drugs <- firstup(sko_df_genes$Drugs)
sko_df_genes %>% group_by(SYMBOL_,TYPE2,Predicted_Essential,Subtype) %>%mutate(
SYMBOL_id = str_length(paste0(unique(Drugs),collapse = "; " )),
Drug_len = str_length(Drugs),n_drugs = n_distinct(Drugs),
Drug_rank = ntile(rank(Drugs),n_distinct(Drugs)),
) ->sko_df_genes
#sko_df_genes$Subtype_ <- 'NA'
#sko_df_genes$Subtype_ <- sko_df_genes$Subtype
#sko_df_genes$Subtype_[sko_df_genes$Subtype_ %in% c('AST','ODG')] <- "AST/ODG"
sko_df_genes$Subtype <- factor(sko_df_genes$Subtype,c('GBM','AST','ODG'))
#sko_df_genes$Subtype_ <- factor(sko_df_genes$Subtype_,c('GBM',"AST/ODG"))
sko_df_genes$Predicted_Essential[sko_df_genes$Predicted_Essential==1] <- 'Essential drug targets'
sko_df_genes$Predicted_Essential[sko_df_genes$Predicted_Essential==0] <- 'Non-essential drug targets'
sko_placeholder__ <- sko_df_genes # A placeholder to add approved drug targets
sko_df_genes$Predicted_Essential <- factor(sko_df_genes$Predicted_Essential,c('Essential drug targets','Non-essential drug targets'))
#n_distinct(sko_df_genes[sko_df_genes$TYPE2=='Single Drug Deletion' & sko_df_genes$Predicted_Essential!= "Essential drug targets", "Drugs"])
sko_df_genes$Drugs_two_ch <- substr(sko_df_genes$Drugs ,1,2)
sko_df_genes$Drugs_one_ch <- substr(sko_df_genes$Drugs ,1,1)
mycols=c("dodgerblue2", "#E31A1C", "green4", "#6A3D9A", "#FF7F00", "gray",
"gold1", "skyblue2", "#FB9A99", "palegreen2", "#CAB2D6", "#FDBF6F",
"gray70", "khaki2", "maroon", "orchid1", "deeppink1", "blue1",
"steelblue4", "darkturquoise", "green1", "yellow4",
"darkorange4", "yellow3", "brown", "skyblue3", "palegreen3", "khaki3", "#E31B4D",
"gold3","green2","orchid3","turquoise")
x <- unique(sko_df_genes[sko_df_genes$TYPE2=='Single Drug Deletion',
c("Drugs","Drugs_one_ch")])
# # Legend key width = maximum label * 1.10 to add some padding
# width <- unit(max(sapply(key_label, strwidth, units = "inches")) * 1.10, "in")
#unique(sko_df_genes[sko_df_genes$TYPE2=='Single Drug Deletion', "Pathway"])
#Y <- unique(sko_df_genes[sko_df_genes$TYPE2=='Single Drug Deletion', colnames(sko_df_genes)!="Pathway"])
#sko_df_genes$SYMBOL_[sko_df_genes$SYMBOL %in% c("CA9","CA5A","CA4","CA2") ] <- "CA**"
#sko_df_genes$SYMBOL_[sko_df_genes$SYMBOL %in% c("PI4KB","PI4KA","PI4K2A") ] <- "PI4K*"
#sko_df_genes$SYMBOL_[sko_df_genes$SYMBOL %in% c("SLC7A1","SLC7A2","SLC7A3") ] <- "SLC7A*"
#sko_df_genes$SYMBOL_[sko_df_genes$SYMBOL %in% c("IMPDH1","IMPDH2") ] <- "IMPDH*"
sko_df_genes_ <- unique(sko_df_genes[sko_df_genes$TYPE2!='Double Drug Deletion', c('Drugs','SYMBOL_',"Subtype",'n_drugs',
"Predicted_Essential",
'Drug_rank','Drugs_one_ch')])
# # Make font map for the essential genes
n_distinct(sko_df_genes_$SYMBOL_)
unique(sko_df_genes_$SYMBOL_)
unique(sko_df_genes$SYMBOL[sko_df_genes$TYPE2 =="Single Drug Deletion"])
n_distinct(sko_df_genes$SYMBOL[sko_df_genes$TYPE2 =="Single Drug Deletion"])
#bold_map = data.frame(FACE = rep("plain",n_distinct(sko_df_genes_$SYMBOL_)))
bold_map <-sko_df_genes_# unique(sko_df_genes_[,c("SYMBOL_","Subtype","n_drugs","Predicted_Essential")])
#bold_map %>% group_by(SYMBOL_) %>% mutate(n_drugs=max(n_drugs)) -> bold_map
#bold_map <- unique(bold_map)
bold_map$FACE <-"plain"
bold_map$FACE[bold_map$Predicted_Essential=='Essential drug targets'] <- "bold"
bold_map <- bold_map[order(bold_map$FACE),]
n_essential <- n_distinct(sko_df_genes_$SYMBOL_[sko_df_genes_$Predicted_Essential=='Essential drug targets'])
bold_map$FACE[1:n_essential] <- "bold"
bold_map$FACE <- factor(bold_map$FACE,c('bold','plain'))
#
sko_df_genes_$Subtype_ <-str_c("i",sko_df_genes_$Subtype)
sko_df_genes_$Subtype_ <- factor(sko_df_genes_$Subtype_,c("iGBM","iAST","iODG"))
P2_2 <- ggplot(sko_df_genes_,#(sko_df_genes[sko_df_genes$TYPE2=='Single Drug Deletion',],
aes(y=reorder(SYMBOL_,n_drugs),x=Drug_rank))+
geom_tile(alpha=0.7,stat = 'identity',aes(fill=Drugs)) +
geom_text(aes(label=Drugs_one_ch,color=Drugs,group=Drugs_one_ch, size=Predicted_Essential),position="identity" )+ #,size=2.5
facet_grid(Predicted_Essential~Subtype_,scales = 'free')+#, space='free_y')+
force_panelsizes(rows = c(1.5, 2.7),
cols = c(1, 1)) +
ggtitle("B") +# #ggtitle("Predicted drug targets") +#
ylab("")+xlab("Number of drugs per gene")+
theme_classic() +
scale_fill_manual(values=mycols)+
scale_color_manual(values=rep("black",33),labels=sort(x$Drugs))+
scale_size_manual(values=c(4,2.5))+
theme(axis.text.x = element_text(angle = 0,size = 12),
axis.text.y = element_text(angle = 0,size = 9) ,
strip.text = element_text(size = 14),
legend.text=element_text(size=12),legend.title = element_text(size=13),
axis.title = element_text(size = 12))+
#axis.text.y= element_markdown(size = 8,face =bold_map$FACE )
#axis.text.y = element_text(angle = 0,size = 8,face =bold_map$FACE )
#axis.text.y = element_text(angle = 0,
# color = ifelse(sko_df_genes_$defensive_industries == "N", "red", "black"))
guides(fill=guide_legend(title="Drugs",ncol = 1,keywidth = 0.5),
color=guide_legend(override.aes = list(label = sort(x$Drugs_one_ch))),size="none"
)
P2_2
#fill <- c("#FF0000","#2FD4DC","#FF9300","#0000FF","#00B900","#FF30F7","#6100A0","#AD7E55")
fill <- c("#2FD4DC","#00B900","#FF30F7","#FF0000","#2FD4DC","#FF0000","#FF0000","#FF0000","#2FD4DC","#FF0000",
"#FF0000","#FF9300","#FF0000","#FF30F7","#0000FF","#FF0000","#FF0000","#00B900","#00B900","#2FD4DC",
"#0000FF","#00B900","#00B900","#6100A0","#FF0000","#00B900","#2FD4DC","#2FD4DC","#2FD4DC","#AD7E55",
"#2FD4DC","#2FD4DC","#2FD4DC")
unique(sko_df_genes_$Drugs)
legend_text_colors <- list()
legend_text_colors["ASC"] <- "red"
legend_text_colors["ASC2"] <- "blue"
drugs <- unique(sko_df_genes_$Drugs)
#P2_2 + theme(legend.text=element_markdown(color=legend_text_colors))
#P2_2 <- P2_2 + theme(legend.text=element_text(color=fill))
#g <- ggplotGrob(P2_2)
#g$grobs[[25]]
#sko_df_genes$SYMBOL_ <- sko_df_genes$SYMBOL
#sko_df_genes$SYMBOL_[str_detect(sko_df_genes$SYMBOL_,"^CA.*[0-9].*")] <- "CA genes"
x2 <- unique(sko_df_genes[sko_df_genes$TYPE2=='Double Drug Deletion',
c("Drugs","Drugs_one_ch")])
#sko_df_genes$SYMBOL_[sko_df_genes$SYMBOL_ %in% c("CA*","CA**","CA13") ] <- "CA*"
sko_df_genes$SYMBOL_[sko_df_genes$SYMBOL %in% c("SLCO1A2","SLCO1B1",'SLCO2A1','SLCO2B1') ] <- "SLCO*"
sko_df_genes_2 <- unique(sko_df_genes[sko_df_genes$TYPE2=='Double Drug Deletion', c('Drugs','SYMBOL_','Subtype','Drugs_one_ch')])
sko_df_genes_2$Subtype_ <-str_c("i",sko_df_genes_2$Subtype)
sko_df_genes_2 %>% group_by(SYMBOL_,Subtype) %>%
mutate(
SYMBOL_id = str_length(paste0(unique(Drugs),collapse = "; " )),
Drug_len = str_length(Drugs),n_drugs = n_distinct(Drugs),
Drug_rank = ntile(rank(Drugs),n_distinct(Drugs)),
) ->sko_df_genes_2
sko_df_genes_2$Subtype_ <- factor(sko_df_genes_2$Subtype_,c("iGBM","iAST","iODG"))
sko_df_genes_2 <- sko_df_genes_2[,!colnames(sko_df_genes_2)%in% "SYMBOL"]
sko_df_genes_2 <- unique(sko_df_genes_2)
P3_2 <- ggplot(sko_df_genes_2,
aes(y=reorder(SYMBOL_,n_drugs),x=Drug_rank))+
geom_tile(alpha=0.7,stat = 'identity',aes(fill=Drugs)) +
geom_text(aes(label=Drugs_one_ch,color=Drugs,group=Drugs_one_ch),position="identity" ,size=3.7)+
ggtitle("B") +# #ggtitle("Predicted drug targets") +#
ylab("")+xlab("Number of drugs per gene")+
facet_grid(.~Subtype_,scales = 'free')+#, space='free_y')+
theme_classic() +
scale_fill_manual(values=mycols[1:19])+
scale_color_manual(values=rep("black",19),labels=sort(x2$Drugs))+
#scale_fill_discrete(labels=c('High Program', 'Low Program'))
theme(axis.text.x = element_text(angle = 0,size = 11),
axis.text.y = element_text(angle = 0,size = 11),
strip.text = element_text(size = 14),
legend.text=element_text(size=10.5),legend.title = element_text(size=12),
axis.title = element_text(size = 12))+
guides(fill=guide_legend(title="Combination\ndrugs",ncol = 1,keywidth = 0.5),#,override.aes = list(fill=NA)
color=guide_legend(title="Combination\ndrugs",override.aes = list(label = sort(x2$Drugs_one_ch)))
) + #theme(legend.position = c(0.54,0.33))
theme(legend.position = c(0.2,0.5))
P3_2
## Essential genes
## Bar plot of the number of predicted esssential genes ##
data_longer_[,] %>% #c("Model", "Data","Curation","Subtype")
group_by(Subtype, Model, Data,Curation) %>%
filter( Predicted_Essential==1) %>%
dplyr::summarise(All_Genes=n_distinct(Gene_ENTREZ),
Common_Essential = n_distinct(Gene_ENTREZ[Essentiality_Type=='Common-Essential']))-> data_longer_genes
write_csv(data_longer_[data_longer_$Predicted_Essential==1,],'Integrated_Drug_Db/Predicted_essential_genes.csv')
data_longer_genes <- melt(data_longer_genes)
p <- ggplot(data_longer_genes, aes(x=Subtype,y=value,fill = variable)) + #,x = (..count..)/sum(..count..))
geom_bar(position = "dodge", stat="identity")+
geom_text(aes(label=value), position=position_dodge(width=0.9), stat="identity", vjust=-0.5)+
ggtitle("Predicted Essential Genes in glioma subtypes") +
#facet_grid(Model ~Data ,scales="free") +
ylab("Number of predicted essential genes") +
theme_classic() +
theme(axis.text.x = element_text(angle = 0,size = 11),
axis.text.y = element_text(angle = 0,size = 14))+
theme(legend.title = element_blank())
p
## Heat map of genes vs subtype
data_longer_$Essentiality_Type[data_longer_$Essentiality_Type =='NA_'] <- 'Normal'
data_longer_$Essentiality_Type[data_longer_$Essentiality_Type =='Normal'] <- 'Cancer type-specific'
data_longer_$Essentiality_Type[data_longer_$Essentiality_Type =='Common-Essential'] <- 'Commone essential'
data_longer_$Essentiality_Type[data_longer_$Essentiality_Type =='Commone essential'] <- 'Common essential'
data_longer_$Subtype <- factor(data_longer_$Subtype ,c('GBM','AST','ODG'))
data_longer_$Symbol <- str_replace(data_longer_$Symbol," ","")
## Merge literature Information to the essential genes
genes_literature <- na.omit(genes_literature)
genes_literature$Subtype <- 'ODG'
colnames(genes_literature)[1] <- 'Symbol'
colnames(genes_literature)[4] <- 'Evidence'
data_longer_ <- left_join(data_longer_,genes_literature[c('Symbol','Evidence')])
data_longer_$Common_Essential <- 'No'
data_longer_$Common_Essential[data_longer_$Essentiality_Type =='Common essential'] <- 'Yes'
data_longer_$Common_Essential <- factor(data_longer_$Common_Essential ,c('Yes','No'))
data_longer_$Glioma_Essential <- 'No'
data_longer_$Glioma_Essential[!is.na(data_longer_$Evidence)] <- 'Yes'
data_longer_$Glioma_Essential <- factor(data_longer_$Glioma_Essential ,c('Yes','No'))
data_longer_$Evidence2 <- str_wrap(data_longer_$Evidence , width = 40)
data_longer_$Evidence2[data_longer_$Subtype!='ODG' & data_longer_$Symbol !='SLC6A14'] <- NA
#data_longer_$Evidence2[data_longer_$Symbol %in% c('SPTLC2',"SPTLC3")] <- data_longer_$Evidence2[data_longer_$Symbol=='SPTLC1']
c(data_longer_$Symbol[data_longer_$Predicted_Essential==1])
data_longer_ <- left_join(data_longer_,sko_df_genes[,c('SYMBOL','n_drugs')],
by=c("Symbol"="SYMBOL"))
data_longer_$n_drugs[is.na(data_longer_$n_drugs)] <- 0
data_longer_$Glioma_Essential_2 <- 'No evidence'
data_longer_$Glioma_Essential_2[data_longer_$Glioma_Essential == 'Yes'] <- 'Decrease proliferation'
data_longer_$Glioma_Essential_2[data_longer_$Symbol == 'PCYT2'] <- 'Increase proliferation'
font_import()
fonts()
bold_map <- rep("plain",n_distinct(data_longer_$Symbol[data_longer_$Predicted_Essential==1]))
#n_essential <- n_distinct(sko_df_genes_$SYMBOL_[sko_df_genes_$Predicted_Essential=='Essential drug targets'])
bold_map[1:n_essential] <- "bold"
data_longer_$Subtype_ <-str_c("i",data_longer_$Subtype)
data_longer_$Subtype_ <- factor(data_longer_$Subtype_,c("iGBM","iAST","iODG"))
P2 <- ggplot(data_longer_[data_longer_$Predicted_Essential==1,],
aes(x=Subtype_,y=reorder(Symbol,n_drugs),color=Subtype,
shape=Glioma_Essential_2,
#alpha=Glioma_Essential,
group=Evidence2,
size = Common_Essential)) +
geom_point()+ # position = position_dodge(width = 0.5)
scale_color_manual(values = c('#BB173A','#2F6790','forestgreen'),guide='none')+
scale_size_manual(values = c(10,6))+
scale_shape_manual(values=c("\u2193","\u2191","\u2022" ))+ # "\u23EC","\u23EB","\u2022" "\uf0e3","\uf0e4",
scale_alpha_manual(values = c(1,0.3))+
#scale_fill_brewer(palette="Dark2")+
ggtitle("A") +ylab('Predicted essential genes')+ xlab('Subtype models')+#Predicted essential genes
#facet_grid(Model ~Data ,scales="free") +
#ylab("Predicted essential genes") +
theme_classic() +
theme(axis.text.x = element_text(angle = 0,size = 12),
axis.text.y = element_text(angle = 0,size = 12),
strip.text = element_text(size = 14),
legend.text=element_text(size=12),legend.title = element_text(size=13),
axis.title = element_text(size = 12))+
#axis.text.y = element_markdown(angle = 0,size = 12, face =rev(bold_map)),
guides(fill=guide_legend(title="Gene essentiality"),
size=guide_legend(title="Common essential",title.position = "top",ncol = 1,
override.aes = list(shape="\u2022")),#"\u2195"
#alpha=guide_legend(title="Essential in glioma\nfrom literature")
shape=guide_legend(title="Knock-out/down\nin glioma",ncol=1
,title.position = "top",override.aes = list(size=8)))+
theme(legend.position='bottom',legend.justification = 0.8)
#P2_final <- P2 + plot_spacer()+ P2_2+ plot_layout(ncol = 3,tag_level = "new",#guides = "collect", widths = c(3.5, -0.75 ,4.8))#
#P2_final
P2_final <- cowplot::plot_grid(P2, P2_2, ncol = 2,rel_widths = c(3.3,4.8))
P2_final
ggsave(P2_final,filename="Figure/Figure_2_Essential_Genes.png", units="in", width=11, height=10.5,dpi=300)
# quartz(type = 'pdf', file = 'Figure/Figure_2_Essential_Genes_2.pdf', width=11, height=10.5)
# P2_final
# dev.off()
# ggsave(P2_final,filename="Figure/Figure_2_Essential_Genes.pdf", units="in", width=11, height=11.5,dpi=300)
# library(Cairo)
#
# quartz(type = 'pdf', file = 'Figure/Figure_2_Essential_Genes.pdf', width=11, height=11.5)
# P2_final
# dev.off()
### Figure 3
# Predicted combination are synergistic with drug targets
dko_df = read_csv('Integrated_Drug_Db/DKO_Combination_result.csv')
colnames(dko_df) <- c('Drugs','Subtype','grRatio')
dko_df$Drug1 <- str_split(dko_df$Drugs,' ;',simplify = T)[,1]
dko_df$Drug2 <- str_split(dko_df$Drugs,' ;',simplify = T)[,2]
unique(dko_df$Drug1)
p2 <- ggplot(dko_df,aes(x=Drug1,y=Drug2,fill=Subtype))+
geom_tile()+
scale_fill_brewer(palette="Dark2")+
facet_grid(. ~Subtype ,scales="free")+
ggtitle("Drug combination prediction") +
theme_classic()+
theme(axis.text.x = element_text(angle = 90,size = 12),
axis.text.y = element_text(angle = 0,size = 12))
p2
## Compare the grRion of the drug combinations individually
dko_df_sko = read_csv('Integrated_Drug_Db/DKO_Combination_individual_grRatio_result.csv')
colnames(dko_df_sko) <- c('Drugs','Subtype','grRatio_single')
# Add the dko without cutoff on grRatio
n_distinct(dko_df_sko$Drugs)
dko_df_all = read_csv('Integrated_Drug_Db/DKO_Combination_result_all_predictions.csv')
colnames(dko_df_all) <- c('Drugs','Subtype','grRatio','DelRxns')
dko_df_all <- dko_df_all[,colnames(dko_df_all)!='DelRxns']
dko_df_all <- unique(dko_df_all[,colnames(dko_df_all) != "DelRxns"])
dko_df_all$Drug1 <- str_split(dko_df_all$Drugs,' ;',simplify = T)[,1]
dko_df_all$Drug2 <- str_split(dko_df_all$Drugs,' ;',simplify = T)[,2]
dko_df_all <- dko_df_all[dko_df_all$Drug1 %in% dko_df_sko$Drugs,]
dko_df_all <- dko_df_all[dko_df_all$Drug2 %in% dko_df_sko$Drugs,]
dko_df_all <- dko_df_all[dko_df_all$Drug1 != dko_df_all$Drug2,]
## Make sure that combinations with no measure grRatio due to missing targets for faster computing
## in the model are added
drugs_1 = unique(dko_df$Drug1)
drugs_2 = unique(dko_df$Drug2)
x <- data.frame(Drug1=paste0(drugs_1,collapse = "; "),
Drug2=paste0(drugs_2,collapse = "; "),
Subtype=paste0(c("AST","GBM","ODG"),collapse = "; "))
x %>%separate_rows(Drug1,sep = "; ") %>%separate_rows(Subtype,sep = "; ")%>%separate_rows(Drug2,sep = "; ")-> x
dko_df_all <- left_join(x,dko_df_all)
dko_df_all$Drugs[is.na(dko_df_all$grRatio)] <- str_c(dko_df_all$Drug1[is.na(dko_df_all$grRatio)] ,dko_df_all$Drug2[is.na(dko_df_all$grRatio)] ,sep = " ;")
dko_df_all$grRatio[is.na(dko_df_all$grRatio)] <- 1
#drugs_all = unique(dko_df_sko$Drugs)3
#x <- data.frame(Drugs=paste0(drugs_all,collapse = "; "),
# Subtype=paste0(c("AST","GBM","ODG"),collapse = "; "))
#x%>%separate_rows(Drugs,sep = "; ") %>%separate_rows(Subtype,sep = "; ")-> x
#
# dko_df_sko <- left_join(x,dko_df_sko)
# dko_df_sko$Drugs[is.na(dko_df_all$grRatio)] <- dko_df_sko$Drug1[is.na(dko_df_sko$grRatio)] ,dko_df_all$Drug2[is.na(dko_df_all$grRatio)] ,collapse = " ;")
# dko_df_all$grRatio[is.na(dko_df_all$grRatio)] <- 1
#
dko_df_all <- data.frame(dko_df_all)
nrow(dko_df_all)
dko_df <- data.frame(dko_df)
dko_df_sko <- data.frame(dko_df_sko)
dko_df_ <-left_join(dko_df_all,dko_df_sko,by=c('Drug1'='Drugs','Subtype'='Subtype'))
dko_df_ <-left_join(dko_df_,dko_df_sko,by=c('Drug2'='Drugs','Subtype'='Subtype'))
colnames(dko_df_)
dko_df_ <- dko_df_[,c("Drugs" , "Subtype" , "grRatio" , "Drug1" ,"Drug2","grRatio_single.x" ,"grRatio_single.y") ]
dko_df_ %>% pivot_longer(cols =c("grRatio","grRatio_single.x",'grRatio_single.y') ,
names_to = "Deletion_type",values_to = "grRatio") ->dko_df_longer
dko_df_longer$Deletion_type[dko_df_longer$Deletion_type=='grRatio'] <- 'Combination'
dko_df_longer$Deletion_type[dko_df_longer$Deletion_type%in%c("grRatio_single.x")] <- 'Drug1'
dko_df_longer$Deletion_type[dko_df_longer$Deletion_type%in%c("grRatio_single.y")] <- 'Drug2'
dko_df_longer$Subtype <- factor(dko_df_longer$Subtype,c('GBM','AST','ODG'))
dko_df_longer <- dko_df_longer[dko_df_longer$Drugs %in% dko_df$Drugs ,]
dko_df_longer$Drug1 <- firstup(dko_df_longer$Drug1)
dko_df_longer$Drug2 <- firstup(dko_df_longer$Drug2)
dko_df_longer$Combination_name <- str_c(dko_df_longer$Drug1,str_to_lower(dko_df_longer$Drug2),sep = "/")
dko_df_longer$growth_red <- 1 - dko_df_longer$grRatio
#dko_df_longer$EA <- dko_df_longer$growth_red[dko_df_longer$Deletion_type == 'Drug1']
dko_df_longer %>%
# mutate( ) %>%
group_by(Combination_name, Subtype) %>% mutate(
EA = unique(growth_red[Deletion_type == 'Drug1']),
EB = unique(growth_red[Deletion_type == 'Drug2']),
EAB = unique(growth_red[Deletion_type == 'Combination']),
#Combination Subthresholding
Synergism_score = sum(grRatio[Deletion_type == 'Combination'])- sum(grRatio[Deletion_type == 'Drug1'] , grRatio[Deletion_type == 'Drug2']),
CI_Subthresholding = (EA + EB)/EAB,
#Bliss Independence
Sum_A_B = EA+EB/EAB,
CI_Bliss = (EA+EB-(EA*EB))/EAB,
) -> dko_df_longer
dko_df_longer_result <- dko_df_longer[dko_df_longer$Deletion_type == 'Combination',]
df2 <- unique(dko_df_longer[order(dko_df_longer$Synergism_score),c('Combination_name','Drug1','Drug2')])
myColors <- data.frame(myColors=c("#21de04","#2bdba6","#ffcc33", "#ed9b0e" ,"#cf68ed"),
Gene_type=c("Predicted drug main target","Predicted drug off-target","Predicted non-druggable essential",
"Approved anti-melanoma target","NO-related genes"))
dko_df_longer$Combination_name
dko_df_longer$Combination_name_ <- str_replace(dko_df_longer$Combination_name," \\+ ","\\/")
dko_df_longer$Subtype_ <-str_c("i",dko_df_longer$Subtype)
dko_df_longer$Subtype_ <- factor(dko_df_longer$Subtype_,c("iGBM","iAST","iODG"))
#dko_df_longer$Synergism_score[dko_df_longer$Combination_name =="Fluorouracil + Celecoxib"] <- -3.97610
# Rank the combinations based on the selection done
comp_selection <- read_excel("Supplementary File 2.xlsx",sheet = 4)
dko_df_longer$Combination_name <- str_c(dko_df_longer$Drug1,"-",str_to_lower(dko_df_longer$Drug2))
dko_df_longer <- left_join(dko_df_longer,comp_selection[,c("Combinations","Rank")], by=c("Combination_name"="Combinations"))
dko_df_longer$Deletion_type <- factor(dko_df_longer$Deletion_type,c("Drug1","Drug2","Combination" ))
P3_1 <- ggplot(dko_df_longer,
aes(x=(1- grRatio) *100,color= forcats::fct_rev(Deletion_type)
,fill= forcats::fct_rev(Deletion_type),
y=reorder(Combination_name_,-Rank)))+ #Synergism_score # [dko_df_longer$Deletion_type!='Combination',]
geom_bar(stat = "identity", position=position_dodge(),size=1,width = 0.8)+
#geom_segment(aes(x=-0.05,xend=1- grRatio,y=paste0(Combination_name,Deletion_type),
# yend=paste0(Combination_name,Deletion_type)),size=3.5,
# position=position_dodge())+
#geom_point(aes(shape= Drug1), position=position_dodge(),size=1,width = 0.8)+
scale_color_brewer(palette="Dark2")+
scale_fill_brewer(palette="Dark2")+
facet_grid(. ~Subtype_ ,scales="free")+
xlab("Growth reduction (%)") +
#scale_x_continuous(trans = 'log10')+
ylab("Predicted combinations") +
#ggtitle("The biomass growth rate in the drug combination\nprediction compared to single drug") +
ggtitle("A")+
#scale_y_discrete(labels= df2$Drug2)+
theme_classic()+
#scale_x_continuous(trans = 'log10')+
theme(axis.text.x = element_text(angle = 0,size = 10),#legend.text = element_text(angle = 0,size = 10),
axis.text.y = element_text(angle = 0,size = 12),axis.title.x =element_text(angle = 0,size = 12) ,
strip.text = element_text(size = 12),
legend.text=element_text(size=12),legend.title = element_text(size=12),
axis.title = element_text(size = 12))+
guides(color=guide_legend(title = 'Drug prediction',ncol=3,title.position = "left",reverse = TRUE),
fill=guide_legend(title = 'Drug prediction',ncol=3,title.position = "left",reverse = TRUE))+
theme(plot.margin=unit(c(0.2,0.21,1,0.2),"cm")) +
theme(legend.position=c(-0.01,-0.08),legend.box = "horizontal") #legend.position=c(0.05,-0.15)
#expand_limits(x = -0.2, y = 0)
#scale_x_continuous(expand = c(0, 0), limits = c(-0.2, 1))
P3_1
empty <- theme(
#panel.background = element_rect(fill='transparent'), #transparent panel bg
plot.background = element_rect(fill='transparent', color=NA), #transparent plot bg
#panel.grid.major = element_blank(), #remove major gridlines
#panel.grid.minor = element_blank(), #remove minor gridlines
legend.background = element_rect(fill='transparent'), #transparent legend bg
#legend.box.background = element_rect(fill='transparent') #transparent legend panel
)
# P3_Final <- P3_1 + plot_spacer()+ P3_2+ plot_layout(ncol = 3,tag_level = "new",#guides = "collect",
# widths = c(4, -0.1 ,3))#
# P3_Final
P3_Final <- cowplot::plot_grid(P3_1, P3_2+ theme(legend.position = c(0.21,0.5)), ncol = 2,rel_widths = c(4 ,4.4))#,-.013 #+ theme(legend.position = c(0.2,0.5))
#P3_Final
ggsave(P3_Final,filename="Figure/Figure_3_Synergistic_Combinations.png", units="in", width=11.5, height=8.5,dpi=300,)
#ggsave(P3_Final,filename="Figure/Figure_3_Synergistic_Combinations_2.pdf", units="in", width=11.5, height=8.5,dpi=300,)
### Figure 4
# Scatter plot of drug potency and CSF bioavailability
### Point plot of the preclinical data with DOSAGE in x axis and Color to EFFECT and shape to the top frequent cell lines
vitro <- read_excel("Supplementary File 2.xlsx", sheet = "Table_S14_inVitro_data")
vitro$Drug <- firstup(vitro$Drug)
vitro %>%
filter(!is.na(Dosage_in_µM)) ->vitro
colnames(vitro)
vitro <- vitro[,c('Drug','Cell_lines','Dosage_in_µM','Effect','Prediction','Effect with TMZ')]
vitro$Cell_lines[vitro$Cell_lines=="patient-derived GSC-enriched 3D spheroid cultures"] <- 'GSC spheroid'
vitro$Dosage_in_µM <- str_replace(vitro$Dosage_in_µM,",",".")
vitro$Dosage_in_µM <- as.numeric(vitro$Dosage_in_µM)
### Classify cell lines based on the glioma subtype
depmap_cellinfo <- read.csv("CRISPR/DepMap_22Q1/sample_info_braincancer.csv")
vitro <- left_join(vitro,depmap_cellinfo,by=c('Cell_lines'='cell_line_name'))
vitro$Subtype[str_detect(vitro$Cell_lines,'GSC')] <- 'GBM'
unique(vitro$lineage_subtype)
nrow(vitro[is.na(vitro$Subtype),])
nrow(vitro[!is.na(vitro$Subtype),])
colnames(vitro)
colnames(vitro)[6] <- "Effect_with_TMZ"
## Select combination classes most frequent
x <- as.data.frame(table(vitro$Cell_lines))
x <- x[x$Var1 !='-',]
x_list <- x[x$Freq<3,'Var1']
vitro$Cell_Lines <- vitro$Cell_lines
vitro$Cell_Lines[vitro$Cell_lines %in% x_list] <- 'Others'
vitro$Cell_Lines[vitro$Cell_lines == '-'] <- 'Others'