LSHTM_analysis/scripts/plotting/plotting_thesis/dm_om_plots.R
2022-08-09 19:58:32 +01:00

268 lines
8.4 KiB
R

#################
# Numbers
##################
all_dm_om_df = dm_om_wf_lf_data(df = merged_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)
#-------------------
# 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 data
#---------------------------------------
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)
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)
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)
#==============
# 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()
#foo = lf_consurfP
# proveanP = lf_bp2(lf_proveanP, colour_categ = "mutation_info_labels"
# , p_title = paste0("Evolutionary conservation")
# , dot_transparency = 1
# , violin_quantiles = c(0.5), monochrome = F)
#
# proveanP