lots of per-plot configs
This commit is contained in:
parent
13999a477d
commit
04253b961f
36 changed files with 5121 additions and 540 deletions
271
scripts/plotting/plotting_thesis/gid/basic_barplots_layout_gid.R
Normal file
271
scripts/plotting/plotting_thesis/gid/basic_barplots_layout_gid.R
Normal file
|
@ -0,0 +1,271 @@
|
|||
duetP
|
||||
foldxP
|
||||
deepddgP
|
||||
dynamut2P
|
||||
proveanP
|
||||
snap2P
|
||||
|
||||
mLigP
|
||||
mmLigP
|
||||
posC_lig
|
||||
ppi2P
|
||||
posC_nca
|
||||
peP
|
||||
sensP
|
||||
#========================
|
||||
# Common title settings
|
||||
#=========================
|
||||
theme_georgia <- function(...) {
|
||||
theme_gray(base_family = "sans", ...) +
|
||||
theme(plot.title = element_text(face = "bold"))
|
||||
}
|
||||
title_theme <- calc_element("plot.title", theme_georgia())
|
||||
|
||||
###############################################################
|
||||
common_bp_title = paste0("Sites <", DistCutOff, angstroms_symbol)
|
||||
|
||||
# extract common legends
|
||||
# lig affinity
|
||||
common_legend_outcome = get_legend(mLigP +
|
||||
guides(color = guide_legend(nrow = 1)) +
|
||||
theme(legend.position = "top"))
|
||||
|
||||
# stability
|
||||
common_legend_outcome = get_legend(duetP +
|
||||
guides(color = guide_legend(nrow = 1)) +
|
||||
theme(legend.position = "top"))
|
||||
# conservation
|
||||
cons_common_legend_outcome = get_legend(snap2P +
|
||||
guides(color = guide_legend(nrow = 1)) +
|
||||
theme(legend.position = "top"))
|
||||
###################################################################
|
||||
#==================================
|
||||
# Stability+Conservation: COMBINE
|
||||
#==================================
|
||||
tt_size = 10
|
||||
#----------------------------
|
||||
# stability and consv title
|
||||
#----------------------------
|
||||
tt_stab = ggdraw() +
|
||||
draw_label(
|
||||
paste0("Stability outcome"),
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
#size = title_theme$size
|
||||
size = tt_size
|
||||
)
|
||||
|
||||
tt_cons = ggdraw() +
|
||||
draw_label(
|
||||
paste0("Conservation outcome"),
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
size = tt_size
|
||||
)
|
||||
|
||||
#----------------------
|
||||
# Output plot
|
||||
#-----------------------
|
||||
stab_cons_CLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_stab_cons_BP_CLP.png")
|
||||
|
||||
print(paste0("plot filename:", stab_cons_CLP))
|
||||
png(stab_cons_CLP, units = "in", width = 10, height = 5, res = 300 )
|
||||
|
||||
cowplot::plot_grid(
|
||||
cowplot::plot_grid(
|
||||
cowplot::plot_grid(
|
||||
tt_stab,
|
||||
common_legend_outcome,
|
||||
nrow = 2
|
||||
),
|
||||
cowplot::plot_grid(
|
||||
duetP,
|
||||
foldxP,
|
||||
deepddgP,
|
||||
dynamut2P,
|
||||
nrow = 1,
|
||||
labels = c("A", "B", "C", "D"),
|
||||
label_size = 12),
|
||||
nrow = 2,
|
||||
rel_heights=c(1,10)
|
||||
),
|
||||
NULL,
|
||||
cowplot::plot_grid(
|
||||
cowplot::plot_grid(
|
||||
cowplot::plot_grid(
|
||||
tt_cons,
|
||||
cons_common_legend_outcome,
|
||||
nrow = 2
|
||||
),
|
||||
cowplot::plot_grid(
|
||||
proveanP,
|
||||
snap2P,
|
||||
nrow=1,
|
||||
labels = c("E", "F"),
|
||||
align = "hv"),
|
||||
nrow = 2,
|
||||
rel_heights = c(1, 10),
|
||||
label_size = 12),
|
||||
nrow=1
|
||||
),
|
||||
rel_widths = c(2,0.15,1),
|
||||
nrow=1
|
||||
)
|
||||
|
||||
dev.off()
|
||||
|
||||
#################################################################
|
||||
#=======================================
|
||||
# Affinity barplots: COMBINE ALL three
|
||||
#========================================
|
||||
|
||||
ligT = paste0(common_bp_title, " ligand")
|
||||
lig_affT = ggdraw() +
|
||||
draw_label(
|
||||
ligT,
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
#size = title_theme$size
|
||||
size = 8
|
||||
)
|
||||
|
||||
p1 = cowplot::plot_grid(cowplot::plot_grid(lig_affT
|
||||
, common_legend_outcome
|
||||
, nrow=2),
|
||||
cowplot::plot_grid(mLigP, mmLigP, posC_lig
|
||||
, nrow = 1
|
||||
, rel_widths = c(1,1,1.8)
|
||||
, align = "h"),
|
||||
nrow = 2,
|
||||
rel_heights = c(1,8)
|
||||
|
||||
)
|
||||
p1
|
||||
###########################################################
|
||||
ncaT = paste0(common_bp_title, " Dist-NA")
|
||||
nca_affT = ggdraw() +
|
||||
draw_label(
|
||||
ncaT,
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
#size = title_theme$size
|
||||
size = 8
|
||||
)
|
||||
|
||||
p2 = cowplot::plot_grid(cowplot::plot_grid(nca_affT
|
||||
, common_legend_outcome
|
||||
, nrow=2),
|
||||
cowplot::plot_grid(nca_distP, posC_nca
|
||||
, nrow = 1
|
||||
, rel_widths = c(1.2,1.8)
|
||||
, align = "h"),
|
||||
nrow = 2,
|
||||
rel_heights = c(1,8)
|
||||
)
|
||||
p2
|
||||
###########################################################
|
||||
# PE + All position count
|
||||
peT_allT = ggdraw() +
|
||||
draw_label(
|
||||
paste0("All mutation sites"),
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
#size = title_theme$size
|
||||
size = 8
|
||||
)
|
||||
|
||||
p3 = cowplot::plot_grid(cowplot::plot_grid(peT_allT, nrow = 2
|
||||
, rel_widths = c(1,3),axis = "lr"),
|
||||
cowplot::plot_grid(
|
||||
peP2, posC_all,
|
||||
nrow = 2,
|
||||
rel_widths = c(1,1),
|
||||
align = "v",
|
||||
axis = "lr",
|
||||
rel_heights = c(1,8)
|
||||
),
|
||||
rel_heights = c(1,18),
|
||||
nrow = 2,axis = "lr")
|
||||
p3
|
||||
#===============
|
||||
# Final combine
|
||||
#===============
|
||||
w = 11.79
|
||||
h = 3.5
|
||||
mut_impact_CLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_mut_impactCLP.png")
|
||||
|
||||
#svg(affP, width = 20, height = 5.5)
|
||||
print(paste0("plot filename:", mut_impact_CLP))
|
||||
png(mut_impact_CLP, units = "in", width = w, height = h, res = 300 )
|
||||
|
||||
cowplot::plot_grid(p1, p2
|
||||
#, p3
|
||||
, nrow = 1
|
||||
, labels = "AUTO"
|
||||
, label_size = 12
|
||||
, rel_widths = c(3,2,2)
|
||||
#, rel_heights = c(1)
|
||||
)
|
||||
|
||||
dev.off()
|
||||
##################################################
|
||||
sensP
|
||||
consurfP
|
||||
#=================
|
||||
# Combine sensitivity + ConSurf
|
||||
# or ConSurf
|
||||
#=================
|
||||
w = 3
|
||||
h = 3
|
||||
# sens_conP = paste0(outdir_images
|
||||
# ,tolower(gene)
|
||||
# ,"_sens_cons_CLP.png")
|
||||
#
|
||||
# print(paste0("plot filename:", sens_conP))
|
||||
# png(sens_conP, units = "in", width = w, height = h, res = 300 )
|
||||
#
|
||||
# cowplot::plot_grid(sensP, consurfP,
|
||||
# nrow = 2,
|
||||
# rel_heights = c(1, 1.5)
|
||||
# )
|
||||
#
|
||||
# dev.off()
|
||||
|
||||
conCLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_consurf_BP.png")
|
||||
|
||||
print(paste0("plot filename:", conCLP))
|
||||
png(conCLP, units = "in", width = w, height = h, res = 300 )
|
||||
consurfP
|
||||
|
||||
dev.off()
|
||||
#================================
|
||||
# Sensitivity mutation numbers: geom_tile
|
||||
#================================
|
||||
sensCLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_sensN_tile.png")
|
||||
|
||||
print(paste0("plot filename:", sensCLP))
|
||||
png(sensCLP, units = "in", width = 1, height = 1, res = 300 )
|
||||
sensP
|
||||
dev.off()
|
||||
#================================
|
||||
# Sensitivity SITE numbers: geom_tile
|
||||
#================================
|
||||
sens_siteCLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_sens_siteC_tile.png")
|
||||
|
||||
print(paste0("plot filename:", sens_siteCLP))
|
||||
png(sens_siteCLP, units = "in", width = 1, height = 1, res = 300 )
|
||||
sens_siteP
|
||||
dev.off()
|
||||
|
||||
###########################################################
|
||||
|
320
scripts/plotting/plotting_thesis/gid/dm_om_plots_gid.R
Normal file
320
scripts/plotting/plotting_thesis/gid/dm_om_plots_gid.R
Normal file
|
@ -0,0 +1,320 @@
|
|||
#################
|
||||
# Numbers
|
||||
##################
|
||||
#all_dm_om_df = dm_om_wf_lf_data(df = merged_df3, gene = gene)
|
||||
all_dm_om_df = dm_om_wf_lf_data(df = df3, gene = gene)
|
||||
|
||||
# lf_duet = all_dm_om_df[['lf_duet']]
|
||||
# table(lf_duet$param_type)
|
||||
################################################################
|
||||
|
||||
#======================
|
||||
# Data: Dist+Genomics
|
||||
#======================
|
||||
lf_dist_genP = all_dm_om_df[['lf_dist_gen']]
|
||||
wf_dist_genP = all_dm_om_df[['wf_dist_gen']]
|
||||
|
||||
levels(lf_dist_genP$param_type)
|
||||
#lf_dist_genP$param_type <- factor(lf_dist_genP$param_type, levels=c("Log10(MAF)", "Lig Dist(Å)", "PPI Dist(Å)"))
|
||||
table(lf_dist_genP$param_type)
|
||||
|
||||
genomics_param = c("Log10(MAF)")
|
||||
|
||||
dist_genP = lf_bp2(lf_dist_genP
|
||||
#, p_title
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
dist_genP
|
||||
#-------------------
|
||||
# Genomics data plot
|
||||
#-------------------
|
||||
genomics_dataP = lf_dist_genP[lf_dist_genP$param_type%in%genomics_param,]
|
||||
genomics_dataP$param_type = factor(genomics_dataP$param_type)
|
||||
table(genomics_dataP$param_type)
|
||||
|
||||
genomicsP = lf_bp2(genomics_dataP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
|
||||
genomicsP
|
||||
|
||||
#check
|
||||
wilcox.test(wf_dist_genP$`Log10(MAF)`[wf_dist_genP$mutation_info_labels=="R"]
|
||||
, wf_dist_genP$`Log10(MAF)`[wf_dist_genP$mutation_info_labels=="S"], paired = FALSE)
|
||||
|
||||
tapply(wf_dist_genP$`Log10(MAF)`, wf_dist_genP$mutation_info_labels, summary)
|
||||
|
||||
#-------------------
|
||||
# Distance data plot:
|
||||
#--------------------
|
||||
# not genomics
|
||||
dist_dataP = lf_dist_genP[!lf_dist_genP$param_type%in%genomics_param,]
|
||||
dist_dataP$param_type = factor(dist_dataP$param_type)
|
||||
table(dist_dataP$param_type)
|
||||
levels(dist_dataP$param_type)
|
||||
# relevel factor to control ordering of appearance of plot
|
||||
dist_dataP$param_type <-relevel(dist_dataP$param_type, "Lig Dist(Å)" )
|
||||
table(dist_dataP$param_type)
|
||||
levels(dist_dataP$param_type)
|
||||
|
||||
distanceP = lf_bp2(dist_dataP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
|
||||
distanceP
|
||||
|
||||
# check
|
||||
wilcox.test(wf_dist_genP$`PPI Dist(Å)`[wf_dist_genP$mutation_info_labels=="R"]
|
||||
, wf_dist_genP$`PPI Dist(Å)`[wf_dist_genP$mutation_info_labels=="S"], paired = FALSE)
|
||||
|
||||
wilcox.test(wf_dist_genP$`Lig Dist(Å)`[wf_dist_genP$mutation_info_labels=="R"]
|
||||
, wf_dist_genP$`Lig Dist(Å)`[wf_dist_genP$mutation_info_labels=="S"], paired = FALSE)
|
||||
|
||||
|
||||
wilcox.test(wf_dist_genP$`NA Dist(Å)`[wf_dist_genP$mutation_info_labels=="R"]
|
||||
, wf_dist_genP$`NA Dist(Å)`[wf_dist_genP$mutation_info_labels=="S"], paired = FALSE)
|
||||
|
||||
tapply(wf_dist_genP$`PPI Dist(Å)`, wf_dist_genP$mutation_info_labels, summary)
|
||||
|
||||
tapply(wf_dist_genP$`Lig Dist(Å)`, wf_dist_genP$mutation_info_labels, summary)
|
||||
|
||||
|
||||
#-------------------
|
||||
# Distance data plot: LigDist
|
||||
#--------------------
|
||||
levels(dist_dataP$param_type)[[1]]
|
||||
#Lig Dist(Å), PPI Dist(Å)
|
||||
dist_data_lig = dist_dataP[dist_dataP$param_type%in%c(levels(dist_dataP$param_type)[[1]]),]
|
||||
dist_data_lig$param_type = factor(dist_data_lig$param_type)
|
||||
table(dist_data_lig$param_type)
|
||||
levels(dist_data_lig$param_type)
|
||||
distanceP_lig = lf_bp2(dist_data_lig
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
|
||||
distanceP_lig
|
||||
|
||||
if (tolower(gene)%in%geneL_ppi2){
|
||||
#-------------------
|
||||
# Distance data plot: LigDist
|
||||
#--------------------
|
||||
levels(dist_dataP$param_type)[[2]]
|
||||
#Lig Dist(Å), PPI Dist(Å)
|
||||
dist_data_ppi2 = dist_dataP[dist_dataP$param_type%in%c(levels(dist_dataP$param_type)[[2]]),]
|
||||
dist_data_ppi2$param_type = factor(dist_data_ppi2$param_type)
|
||||
table(dist_data_ppi2$param_type)
|
||||
levels(dist_data_ppi2$param_type)
|
||||
distanceP_ppi2 = lf_bp2(dist_data_ppi2
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
|
||||
distanceP_ppi2
|
||||
}
|
||||
|
||||
if (tolower(gene)%in%geneL_na){
|
||||
#-------------------
|
||||
# Distance data plot: NADist
|
||||
#--------------------
|
||||
levels(dist_dataP$param_type)[[2]]
|
||||
#Lig Dist(Å), PPI Dist(Å)
|
||||
dist_data_na = dist_dataP[dist_dataP$param_type%in%c(levels(dist_dataP$param_type)[[2]]),]
|
||||
dist_data_na$param_type = factor(dist_data_na$param_type)
|
||||
table(dist_data_na$param_type)
|
||||
levels(dist_data_na$param_type)
|
||||
distanceP_na = lf_bp2(dist_data_na
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
|
||||
distanceP_na
|
||||
}
|
||||
#==============
|
||||
# Plot:DUET
|
||||
#==============
|
||||
lf_duetP = all_dm_om_df[['lf_duet']]
|
||||
#lf_duetP = lf_duet[!lf_duet$param_type%in%c(static_colsP),]
|
||||
table(lf_duetP$param_type)
|
||||
lf_duetP$param_type = factor(lf_duetP$param_type)
|
||||
table(lf_duetP$param_type)
|
||||
|
||||
duetP = lf_bp2(lf_duetP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F
|
||||
, dot_transparency = 0.2)
|
||||
|
||||
#==============
|
||||
# Plot:FoldX
|
||||
#==============
|
||||
lf_foldxP = all_dm_om_df[['lf_foldx']]
|
||||
#lf_foldxP = lf_foldx[!lf_foldx$param_type%in%c(static_colsP),]
|
||||
table(lf_foldxP$param_type)
|
||||
lf_foldxP$param_type = factor(lf_foldxP$param_type)
|
||||
table(lf_foldxP$param_type)
|
||||
|
||||
foldxP = lf_bp2(lf_foldxP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F
|
||||
, dot_transparency = 0.1)
|
||||
|
||||
#==============
|
||||
# Plot:DeepDDG
|
||||
#==============
|
||||
lf_deepddgP = all_dm_om_df[['lf_deepddg']]
|
||||
#lf_deepddgP = lf_deepddg[!lf_deepddg$param_type%in%c(static_colsP),]
|
||||
table(lf_deepddgP$param_type)
|
||||
lf_deepddgP$param_type = factor(lf_deepddgP$param_type)
|
||||
table(lf_deepddgP$param_type)
|
||||
|
||||
deepddgP = lf_bp2(lf_deepddgP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F
|
||||
, dot_transparency = 0.2)
|
||||
|
||||
deepddgP
|
||||
|
||||
#==============
|
||||
# Plot: Dynamut2
|
||||
#==============
|
||||
lf_dynamut2P = all_dm_om_df[['lf_dynamut2']]
|
||||
#lf_dynamut2P = lf_dynamut2[!lf_dynamut2$param_type%in%c(static_colsP),]
|
||||
table(lf_dynamut2P$param_type)
|
||||
lf_dynamut2P$param_type = factor(lf_dynamut2P$param_type)
|
||||
table(lf_dynamut2P$param_type)
|
||||
|
||||
dynamut2P = lf_bp2(lf_dynamut2P
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F
|
||||
, dot_transparency = 0.2)
|
||||
|
||||
|
||||
#==============
|
||||
# Plot:ConSurf
|
||||
#==============
|
||||
lf_consurfP = all_dm_om_df[['lf_consurf']]
|
||||
#lf_consurfP = lf_consurf[!lf_consurf$param_type%in%c(static_colsP),]
|
||||
table(lf_consurfP$param_type)
|
||||
lf_consurfP$param_type = factor(lf_consurfP$param_type)
|
||||
table(lf_consurfP$param_type)
|
||||
|
||||
consurfP = lf_bp2(lf_consurfP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
|
||||
#==============
|
||||
# Plot:PROVEAN
|
||||
#==============
|
||||
lf_proveanP = all_dm_om_df[['lf_provean']]
|
||||
#lf_proveanP = lf_provean[!lf_provean$param_type%in%c(static_colsP),]
|
||||
table(lf_proveanP$param_type)
|
||||
lf_proveanP$param_type = factor(lf_proveanP$param_type)
|
||||
table(lf_proveanP$param_type)
|
||||
|
||||
proveanP = lf_bp2(lf_proveanP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
|
||||
#==============
|
||||
# Plot:SNAP2
|
||||
#==============
|
||||
lf_snap2P = all_dm_om_df[['lf_snap2']]
|
||||
#lf_snap2P = lf_snap2[!lf_snap2$param_type%in%c(static_colsP),]
|
||||
table(lf_snap2P$param_type)
|
||||
lf_snap2P$param_type = factor(lf_snap2P$param_type)
|
||||
table(lf_snap2P$param_type)
|
||||
|
||||
snap2P = lf_bp2(lf_snap2P
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F)
|
||||
|
||||
|
||||
############################################################################
|
||||
#================
|
||||
# Plot: mCSM-lig
|
||||
#================
|
||||
lf_mcsm_ligP = all_dm_om_df[['lf_mcsm_lig']]
|
||||
#lf_mcsm_ligP = lf_mcsm_lig[!lf_mcsm_lig$param_type%in%c(static_colsP),]
|
||||
table(lf_mcsm_ligP$param_type)
|
||||
lf_mcsm_ligP$param_type = factor(lf_mcsm_ligP$param_type)
|
||||
table(lf_mcsm_ligP$param_type)
|
||||
|
||||
mcsmligP = lf_bp2(lf_mcsm_ligP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F
|
||||
, dot_transparency = 1)
|
||||
|
||||
|
||||
#=================
|
||||
# Plot: mmCSM-lig2
|
||||
#=================
|
||||
lf_mmcsm_lig2P = all_dm_om_df[['lf_mmcsm_lig2']]
|
||||
#lf_mmcsm_lig2P = lf_mmcsm_lig2P[!lf_mmcsm_lig2P$param_type%in%c(static_colsP),]
|
||||
table(lf_mmcsm_lig2P$param_type)
|
||||
lf_mmcsm_lig2P$param_type = factor(lf_mmcsm_lig2P$param_type)
|
||||
table(lf_mmcsm_lig2P$param_type)
|
||||
|
||||
mcsmlig2P = lf_bp2(lf_mmcsm_lig2P
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F
|
||||
, dot_transparency = 1)
|
||||
|
||||
mcsmlig2P
|
||||
|
||||
#================
|
||||
# Plot: mCSM-ppi2
|
||||
#================
|
||||
if (tolower(gene)%in%geneL_ppi2){
|
||||
lf_mcsm_ppi2P = all_dm_om_df[['lf_mcsm_ppi2']]
|
||||
#lf_mcsm_ppi2P = lf_mcsm_ppi2[!lf_mcsm_ppi2$param_type%in%c(static_colsP),]
|
||||
table(lf_mcsm_ppi2P$param_type)
|
||||
lf_mcsm_ppi2P$param_type = factor(lf_mcsm_ppi2P$param_type)
|
||||
table(lf_mcsm_ppi2P$param_type)
|
||||
|
||||
mcsmppi2P = lf_bp2(lf_mcsm_ppi2P
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F
|
||||
, dot_transparency = 1)
|
||||
|
||||
}
|
||||
|
||||
#==============
|
||||
# Plot: mCSM-NA
|
||||
#==============
|
||||
if (tolower(gene)%in%geneL_na){
|
||||
lf_mcsm_naP = all_dm_om_df[['lf_mcsm_na']]
|
||||
#lf_mcsm_naP = lf_mcsm_na[!lf_mcsm_na$param_type%in%c(static_colsP),]
|
||||
table(lf_mcsm_naP$param_type)
|
||||
lf_mcsm_naP$param_type = factor(lf_mcsm_naP$param_type)
|
||||
table(lf_mcsm_naP$param_type)
|
||||
|
||||
mcsmnaP = lf_bp2(lf_mcsm_naP
|
||||
#, p_title = ""
|
||||
, violin_quantiles = c(0.5), monochrome = F
|
||||
, dot_transparency = 1)
|
||||
|
||||
}
|
||||
|
||||
######################################
|
||||
# Outplot with stats
|
||||
######################################
|
||||
# outdir_images = paste0("~/git/Writing/thesis/images/results/", tolower(gene), "/")
|
||||
#
|
||||
# dm_om_combinedP = paste0(outdir_images
|
||||
# ,tolower(gene)
|
||||
# ,"_dm_om_all.svg" )
|
||||
#
|
||||
# cat("DM OM plots with stats:", dm_om_combinedP)
|
||||
# svg(dm_om_combinedP, width = 32, height = 18)
|
||||
# cowplot::plot_grid(
|
||||
# cowplot::plot_grid(duetP, foldxP, deepddgP, dynamut2P, genomicsP, distanceP
|
||||
# , nrow=1
|
||||
# , rel_widths = c(1/7, 1/7,1/7,1/7, 1/7, 1.75/7)),
|
||||
# #, rel_widths = c(1/8, 1/8,1/8,1/8, 1/8, 2.75/8)), # for 3 distances
|
||||
# cowplot::plot_grid(consurfP, proveanP, snap2P
|
||||
# , mcsmligP
|
||||
# , mcsmlig2P
|
||||
# , mcsmppi2P
|
||||
# #, mcsmnaP
|
||||
# , nrow=1),
|
||||
# nrow=2)
|
||||
#
|
||||
# dev.off()
|
||||
|
||||
|
178
scripts/plotting/plotting_thesis/gid/gg_pairs_all_gid.R
Normal file
178
scripts/plotting/plotting_thesis/gid/gg_pairs_all_gid.R
Normal file
|
@ -0,0 +1,178 @@
|
|||
#source("~/git/LSHTM_analysis/config/embb.R")
|
||||
#source("~/git/LSHTM_analysis/scripts/plotting/plotting_colnames.R")
|
||||
#source("~/git/LSHTM_analysis/scripts/plotting/get_plotting_dfs.R")
|
||||
|
||||
my_gg_pairs=function(plot_df, plot_title
|
||||
, tt_args_size = 2.5
|
||||
, gp_args_size = 2.5){
|
||||
ggpairs(plot_df,
|
||||
columns = 1:(ncol(plot_df)-1),
|
||||
upper = list(
|
||||
continuous = wrap('cor', # ggally_cor()
|
||||
method = "spearman",
|
||||
use = "pairwise.complete.obs",
|
||||
title="ρ",
|
||||
digits=2,
|
||||
justify_labels = "centre",
|
||||
#title_args=c(colour="black"),
|
||||
title_args=c(size=tt_args_size),#2.5
|
||||
group_args=c(size=gp_args_size)#2.5
|
||||
)
|
||||
),
|
||||
lower = list(
|
||||
continuous = wrap("points",
|
||||
alpha = 0.7,
|
||||
size=0.125),
|
||||
combo = wrap("dot",
|
||||
alpha = 0.7,
|
||||
size=0.125)
|
||||
),
|
||||
aes(colour = factor(ifelse(dst_mode==0,
|
||||
"S",
|
||||
"R") ),
|
||||
alpha = 0.5),
|
||||
title=plot_title) +
|
||||
|
||||
scale_colour_manual(values = c("red", "blue")) +
|
||||
scale_fill_manual(values = c("red", "blue")) #+
|
||||
# theme(text = element_text(size=7,
|
||||
# face="bold"))
|
||||
}
|
||||
|
||||
DistCutOff = 10
|
||||
###########################################################################
|
||||
geneL_normal = c("pnca")
|
||||
geneL_na = c("gid", "rpob")
|
||||
geneL_ppi2 = c("alr", "embb", "katg", "rpob")
|
||||
|
||||
merged_df3 = as.data.frame(merged_df3)
|
||||
|
||||
corr_plotdf = corr_data_extract(merged_df3
|
||||
, gene = gene
|
||||
, drug = drug
|
||||
, extract_scaled_cols = F)
|
||||
|
||||
aff_dist_cols = colnames(corr_plotdf)[grep("Dist", colnames(corr_plotdf))]
|
||||
static_cols = c("Log10(MAF)"
|
||||
, "Log10(OR)"
|
||||
)
|
||||
############################################################
|
||||
#=============================================
|
||||
# Creating masked df for affinity data
|
||||
#=============================================
|
||||
corr_affinity_df = corr_plotdf
|
||||
|
||||
#----------------------
|
||||
# Mask affinity columns
|
||||
#-----------------------
|
||||
corr_affinity_df[corr_affinity_df["Lig-Dist"]>DistCutOff,"mCSM-lig"]=0
|
||||
corr_affinity_df[corr_affinity_df["Lig-Dist"]>DistCutOff,"mmCSM-lig"]=0
|
||||
|
||||
if (tolower(gene)%in%geneL_ppi2){
|
||||
corr_affinity_df[corr_affinity_df["PPI-Dist"]>DistCutOff,"mCSM-PPI2"]=0
|
||||
}
|
||||
|
||||
if (tolower(gene)%in%geneL_na){
|
||||
corr_affinity_df[corr_affinity_df["NCA-Dist"]>DistCutOff,"mCSM-NA"]=0
|
||||
}
|
||||
|
||||
# count 0
|
||||
#res <- colSums(corr_affinity_df==0)/nrow(corr_affinity_df)*100
|
||||
unmasked_vals <- nrow(corr_affinity_df) - colSums(corr_affinity_df==0)
|
||||
unmasked_vals
|
||||
|
||||
##########################################################
|
||||
#================
|
||||
# Stability
|
||||
#================
|
||||
corr_ps_colnames = c(static_cols
|
||||
, "DUET"
|
||||
, "FoldX"
|
||||
, "DeepDDG"
|
||||
, "Dynamut2"
|
||||
, aff_dist_cols
|
||||
, "dst_mode")
|
||||
|
||||
corr_df_ps = corr_plotdf[, corr_ps_colnames]
|
||||
|
||||
# Plot #1
|
||||
plot_corr_df_ps = my_gg_pairs(corr_df_ps, plot_title="Stability estimates")
|
||||
##########################################################
|
||||
#================
|
||||
# Conservation
|
||||
#================
|
||||
corr_conservation_cols = c( static_cols
|
||||
, "ConSurf"
|
||||
, "SNAP2"
|
||||
, "PROVEAN"
|
||||
#, aff_dist_cols
|
||||
, "dst_mode"
|
||||
)
|
||||
|
||||
corr_df_cons = corr_plotdf[, corr_conservation_cols]
|
||||
|
||||
# Plot #2
|
||||
plot_corr_df_cons = my_gg_pairs(corr_df_cons, plot_title="Conservation estimates")
|
||||
|
||||
##########################################################
|
||||
#================
|
||||
# Affinity: lig, ppi and na as applicable
|
||||
#================
|
||||
#corr_df_lig = corr_plotdf[corr_plotdf["Lig-Dist"]<DistCutOff,]
|
||||
common_aff_colnames = c("mCSM-lig"
|
||||
, "mmCSM-lig")
|
||||
|
||||
if (tolower(gene)%in%geneL_normal){
|
||||
aff_colnames = common_aff_colnames
|
||||
}
|
||||
if (tolower(gene)%in%geneL_ppi2){
|
||||
aff_colnames = c(common_aff_colnames, "mCSM-PPI2")
|
||||
}
|
||||
|
||||
if (tolower(gene)%in%geneL_na){
|
||||
aff_colnames = c(common_aff_colnames, "mCSM-NA")
|
||||
}
|
||||
|
||||
# building ffinal affinity colnames for correlation
|
||||
corr_aff_colnames = c(static_cols
|
||||
, aff_colnames
|
||||
, "dst_mode") # imp
|
||||
|
||||
corr_df_aff = corr_affinity_df[, corr_aff_colnames]
|
||||
colnames(corr_df_aff)
|
||||
|
||||
# Plot #3
|
||||
plot_corr_df_aff = my_gg_pairs(corr_df_aff,
|
||||
plot_title="Affinity estimates",
|
||||
tt_args_size = 4,
|
||||
gp_args_size = 4)
|
||||
|
||||
#=============
|
||||
# combine
|
||||
#=============
|
||||
|
||||
#png("/home/tanu/tmp/gg_pairs_all.png", height = 6, width=11.75, unit="in",res=300)
|
||||
png(paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_CorrAB.png"), height = 7, width=11.75, unit="in",res=300)
|
||||
|
||||
cowplot::plot_grid(ggmatrix_gtable(plot_corr_df_ps),
|
||||
ggmatrix_gtable(plot_corr_df_cons),
|
||||
# ggmatrix_gtable(plot_corr_df_aff),
|
||||
# nrow=1, ncol=3, rel_heights = 7,7,3
|
||||
nrow=1,
|
||||
rel_widths = c(1.5,1),
|
||||
labels = "AUTO",
|
||||
label_size = 12)
|
||||
dev.off()
|
||||
|
||||
# affinity corr
|
||||
#png("/home/tanu/tmp/gg_pairs_affinity.png", height =7, width=7, unit="in",res=300)
|
||||
png(paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_CorrC.png"), height =7, width=7, unit="in",res=300)
|
||||
|
||||
cowplot::plot_grid(ggmatrix_gtable(plot_corr_df_aff),
|
||||
labels = "C",
|
||||
label_size = 12)
|
||||
dev.off()
|
Loading…
Add table
Add a link
Reference in a new issue