added combined lineage plot
This commit is contained in:
parent
fe292e3717
commit
94454d6fba
10 changed files with 421 additions and 190 deletions
|
@ -224,30 +224,30 @@ consurf_palette2 = c("0" = "yellow2"
|
|||
|
||||
|
||||
consurf_colours = c(
|
||||
"nsd" = rgb(1.00,1.00,0.59)
|
||||
, "1" = rgb(0.63,0.16,0.37)
|
||||
, "2" = rgb(0.94,0.49,0.67)
|
||||
, "3" = rgb(0.98,0.78,0.86)
|
||||
, "4" = rgb(0.98,0.92,0.96)
|
||||
"0" = rgb(1.00,1.00,0.59)
|
||||
, "9" = rgb(0.63,0.16,0.37)
|
||||
, "8" = rgb(0.94,0.49,0.67)
|
||||
, "7" = rgb(0.98,0.78,0.86)
|
||||
, "6" = rgb(0.98,0.92,0.96)
|
||||
, "5" = rgb(1.00,1.00,1.00)
|
||||
, "6" = rgb(0.84,0.94,0.94)
|
||||
, "7" = rgb(0.65,0.86,0.90)
|
||||
, "8" = rgb(0.29,0.69,0.75)
|
||||
, "9" = rgb(0.04,0.49,0.51)
|
||||
, "4" = rgb(0.84,0.94,0.94)
|
||||
, "3" = rgb(0.65,0.86,0.90)
|
||||
, "2" = rgb(0.29,0.69,0.75)
|
||||
, "1" = rgb(0.04,0.49,0.51)
|
||||
)
|
||||
|
||||
consurf_bp_colours = c(
|
||||
"0" = rgb(1.00,1.00,0.59)
|
||||
, "1" = rgb(0.63,0.16,0.37)
|
||||
, "2" = rgb(0.94,0.49,0.67)
|
||||
, "3" = rgb(0.98,0.78,0.86)
|
||||
, "4" = rgb(0.98,0.92,0.96)
|
||||
, "5" = rgb(1.00,1.00,1.00)
|
||||
, "6" = rgb(0.84,0.94,0.94)
|
||||
, "7" = rgb(0.65,0.86,0.90)
|
||||
, "8" = rgb(0.29,0.69,0.75)
|
||||
, "9" = rgb(0.04,0.49,0.51)
|
||||
)
|
||||
# consurf_bp_colours = c(
|
||||
# "0" = rgb(1.00,1.00,0.59)
|
||||
# , "9" = rgb(0.63,0.16,0.37)
|
||||
# , "8" = rgb(0.94,0.49,0.67)
|
||||
# , "7" = rgb(0.98,0.78,0.86)
|
||||
# , "6" = rgb(0.98,0.92,0.96)
|
||||
# , "5" = rgb(1.00,1.00,1.00)
|
||||
# , "4" = rgb(0.84,0.94,0.94)
|
||||
# , "3" = rgb(0.65,0.86,0.90)
|
||||
# , "2" = rgb(0.29,0.69,0.75)
|
||||
# , "1" = rgb(0.04,0.49,0.51)
|
||||
# )
|
||||
|
||||
##################################################
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ site_snp_count_bp <- function (plotdf
|
|||
# FIXME: should really be legend title
|
||||
# but atm being using as plot title
|
||||
#my_leg_title
|
||||
bp_plot_title = paste0("Total SNPs: ", tot_muts
|
||||
bp_plot_title = paste0("Total nsSNPs: ", tot_muts
|
||||
, "\nTotal sites: ", tot_sites)
|
||||
|
||||
#-------------
|
||||
|
|
|
@ -39,7 +39,8 @@ stability_count_bp <- function(plotdf
|
|||
|
||||
#OutPlot_count = ggplot(plotdf, aes(x = eval(parse(text = df_colname)))) +
|
||||
OutPlot_count = ggplot(plotdf, aes_string(x = df_colname)) +
|
||||
geom_bar(aes(fill = eval(parse(text = df_colname))), show.legend = TRUE) +
|
||||
geom_bar(aes(fill = eval(parse(text = df_colname)))
|
||||
, show.legend = TRUE) +
|
||||
geom_label(stat = "count"
|
||||
, aes(label = ..count..)
|
||||
, color = "black"
|
||||
|
|
|
@ -32,37 +32,30 @@ outdir_images = paste0("~/git/Writing/thesis/images/results/"
|
|||
cat("plots will output to:", outdir_images)
|
||||
|
||||
###########################################################
|
||||
df3 = merged_df3
|
||||
# FIXME: port to a common script
|
||||
#=================
|
||||
# PREFORMATTING: for consistency
|
||||
#=================
|
||||
df3$sensitivity = ifelse(df3$dst_mode == 1, "R", "S")
|
||||
table(df3$sensitivity)
|
||||
# get from preformatting.R
|
||||
#df3
|
||||
|
||||
|
||||
# ConSurf labels
|
||||
consurf_colOld = "consurf_colour_rev"
|
||||
consurf_colNew = "consurf_outcome"
|
||||
df3[[consurf_colNew]] = df3[[consurf_colOld]]
|
||||
df3[[consurf_colNew]] = as.factor(df3[[consurf_colNew]])
|
||||
df3[[consurf_colNew]]
|
||||
levels(df3$consurf_outcome) = c( "nsd", 1, 2, 3, 4, 5, 6, 7, 8, 9)
|
||||
levels(df3$consurf_outcome)
|
||||
|
||||
# consurf_colOld = "consurf_colour_rev"
|
||||
# consurf_colNew = "consurf_outcome"
|
||||
# df3[[consurf_colNew]] = df3[[consurf_colOld]]
|
||||
# df3[[consurf_colNew]] = as.factor(df3[[consurf_colNew]])
|
||||
# df3[[consurf_colNew]]
|
||||
consurf_colname = "consurf_outcome"
|
||||
levels(df3[[consurf_colname]])
|
||||
|
||||
# SNAP2 labels
|
||||
snap2_colname = "snap2_outcome"
|
||||
df3[[snap2_colname]] <- str_replace(df3[[snap2_colname]], "effect", "Effect")
|
||||
df3[[snap2_colname]] <- str_replace(df3[[snap2_colname]], "neutral", "Neutral")
|
||||
levels(df3[[snap2_colname]])
|
||||
|
||||
##############################################################
|
||||
gene_all_cols = colnames(df3)[colnames(df3)%in%all_cols]
|
||||
|
||||
gene_outcome_cols = colnames(df3)[colnames(df3)%in%c(outcome_cols_stability
|
||||
, outcome_cols_affinity
|
||||
, outcome_cols_conservation)]
|
||||
gene_outcome_cols
|
||||
|
||||
|
||||
#=======================================================================
|
||||
#------------------------------
|
||||
# stability barplots:
|
||||
|
@ -129,45 +122,45 @@ dynamut2P = stability_count_bp(plotdf = df3
|
|||
|
||||
dynamut2P
|
||||
|
||||
# extract common legend
|
||||
common_legend = get_legend(duetP +
|
||||
guides(color = guide_legend(nrow = 1)) +
|
||||
theme(legend.position = "top"))
|
||||
|
||||
#==========================
|
||||
# output: STABILITY PLOTS
|
||||
#===========================
|
||||
bp_stability_CLP = paste0(outdir_images
|
||||
, tolower(gene)
|
||||
,"_bp_stability_CL.svg")
|
||||
|
||||
svg(bp_stability_CLP, width = 15, height = 12)
|
||||
print(paste0("plot filename:", bp_stability_CLP))
|
||||
|
||||
cowplot::plot_grid(
|
||||
common_legend,
|
||||
cowplot::plot_grid(duetP, foldxP
|
||||
, deepddgP, dynamut2P
|
||||
, nrow = 2
|
||||
, ncol = 2
|
||||
#, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
, labels = "AUTO"
|
||||
, label_size = 25)
|
||||
, ncol = 1
|
||||
, nrow = 2
|
||||
, rel_heights = c(0.4/10,9/10))
|
||||
|
||||
dev.off()
|
||||
# # extract common legend
|
||||
# common_legend = get_legend(duetP +
|
||||
# guides(color = guide_legend(nrow = 1)) +
|
||||
# theme(legend.position = "top"))
|
||||
#
|
||||
# #==========================
|
||||
# #output: STABILITY PLOTS
|
||||
# #===========================
|
||||
# bp_stability_CLP = paste0(outdir_images
|
||||
# , tolower(gene)
|
||||
# ,"_bp_stability_CL.svg")
|
||||
#
|
||||
# svg(bp_stability_CLP, width = 15, height = 12)
|
||||
# print(paste0("plot filename:", bp_stability_CLP))
|
||||
#
|
||||
# cowplot::plot_grid(
|
||||
# common_legend,
|
||||
# cowplot::plot_grid(duetP, foldxP
|
||||
# , deepddgP, dynamut2P
|
||||
# , nrow = 2
|
||||
# , ncol = 2
|
||||
# #, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
# , labels = "AUTO"
|
||||
# , label_size = 25)
|
||||
# , ncol = 1
|
||||
# , nrow = 2
|
||||
# , rel_heights = c(0.4/10,9/10))
|
||||
#
|
||||
# dev.off()
|
||||
###########################################################
|
||||
#=========================
|
||||
# Affinity outcome
|
||||
# check this var: outcome_cols_affinity
|
||||
# get from preformatting or put in globals
|
||||
#==========================
|
||||
DistCutOff = 10
|
||||
DistCutOff
|
||||
LigDist_colname # = "ligand_distance" # from globals
|
||||
ppi2Dist_colname = "interface_dist"
|
||||
naDist_colname = "TBC"
|
||||
ppi2Dist_colname
|
||||
naDist_colname
|
||||
|
||||
###########################################################
|
||||
# get plotting data within the distance
|
||||
|
@ -231,37 +224,37 @@ ppi2P = stability_count_bp(plotdf = df3_ppi2
|
|||
, bp_plot_title = paste(common_bp_title, "interface")
|
||||
)
|
||||
|
||||
# extract common legend
|
||||
common_legend_aff = get_legend(mLigP +
|
||||
guides(color = guide_legend(nrow = 1)) +
|
||||
theme(legend.position = "top"))
|
||||
|
||||
#==========================
|
||||
# output: AFFINITY PLOTS
|
||||
#==========================
|
||||
bp_affinity_CLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_bp_affinity_CL.svg" )
|
||||
|
||||
print(paste0("plot filename:", bp_stability_CLP))
|
||||
svg(bp_affinity_CLP, width = 15, height = 6.5)
|
||||
|
||||
cowplot::plot_grid(
|
||||
common_legend,
|
||||
cowplot::plot_grid(mLigP, mmLigP
|
||||
, ppi2P
|
||||
, nrow = 1
|
||||
, ncol = 3
|
||||
#, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
, labels = "AUTO"
|
||||
, label_size = 25)
|
||||
, ncol = 1
|
||||
, nrow = 2
|
||||
, rel_heights = c(0.4/10,9/10))
|
||||
#, rel_widths = c(1,1,1))
|
||||
|
||||
|
||||
dev.off()
|
||||
# # extract common legend
|
||||
# common_legend_aff = get_legend(mLigP +
|
||||
# guides(color = guide_legend(nrow = 1)) +
|
||||
# theme(legend.position = "top"))
|
||||
#
|
||||
# #==========================
|
||||
# # output: AFFINITY PLOTS
|
||||
# #==========================
|
||||
# bp_affinity_CLP = paste0(outdir_images
|
||||
# ,tolower(gene)
|
||||
# ,"_bp_affinity_CL.svg" )
|
||||
#
|
||||
# print(paste0("plot filename:", bp_stability_CLP))
|
||||
# svg(bp_affinity_CLP, width = 15, height = 6.5)
|
||||
#
|
||||
# cowplot::plot_grid(
|
||||
# common_legend,
|
||||
# cowplot::plot_grid(mLigP, mmLigP
|
||||
# , ppi2P
|
||||
# , nrow = 1
|
||||
# , ncol = 3
|
||||
# #, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
# , labels = "AUTO"
|
||||
# , label_size = 25)
|
||||
# , ncol = 1
|
||||
# , nrow = 2
|
||||
# , rel_heights = c(0.4/10,9/10))
|
||||
# #, rel_widths = c(1,1,1))
|
||||
#
|
||||
#
|
||||
# dev.off()
|
||||
|
||||
################################################################
|
||||
#=========================
|
||||
|
@ -269,6 +262,21 @@ dev.off()
|
|||
# check this var:
|
||||
outcome_cols_conservation
|
||||
#==========================
|
||||
# consurf
|
||||
consurfP = stability_count_bp(plotdf = df3
|
||||
, df_colname = "consurf_outcome"
|
||||
#, leg_title = "ConSurf"
|
||||
#, label_categories = labels_consurf
|
||||
, yaxis_title = "Number of nsSNPs"
|
||||
, leg_position = "top"
|
||||
, subtitle_text = "ConSurf"
|
||||
, geom_ls = 5
|
||||
, bar_fill_values = consurf_colours # from globals
|
||||
, sts = sts
|
||||
, subtitle_colour= subtitle_colour)
|
||||
|
||||
consurfP
|
||||
|
||||
# provean
|
||||
proveanP = stability_count_bp(plotdf = df3
|
||||
, df_colname = "provean_outcome"
|
||||
|
@ -278,73 +286,172 @@ proveanP = stability_count_bp(plotdf = df3
|
|||
, leg_position = "top"
|
||||
, subtitle_text = "PROVEAN"
|
||||
, geom_ls = geom_ls
|
||||
, bar_fill_values = c("#F8766D", "#00BFC4")
|
||||
, bar_fill_values = c("#D01C8B", "#F1B6DA") # light pink and deep
|
||||
, sts = sts
|
||||
, subtitle_colour= subtitle_colour)
|
||||
|
||||
|
||||
# snap2
|
||||
snap2P = stability_count_bp(plotdf = df3
|
||||
, df_colname = "snap2_outcome"
|
||||
#, leg_title = "SNAP2"
|
||||
#, label_categories = labels_snap2
|
||||
, yaxis_title = "Number of nsSNPs"
|
||||
, yaxis_title = ""
|
||||
, leg_position = "top"
|
||||
, subtitle_text = "SNAP2"
|
||||
, geom_ls = geom_ls
|
||||
, bar_fill_values = c("#F8766D", "#00BFC4")
|
||||
, bar_fill_values = c("#D01C8B", "#F1B6DA") # light pink and deep
|
||||
, sts = sts
|
||||
, subtitle_colour= subtitle_colour)
|
||||
|
||||
# consurf
|
||||
consurfP = stability_count_bp(plotdf = df3
|
||||
, df_colname = "consurf_outcome"
|
||||
#, leg_title = "ConSurf"
|
||||
#, label_categories = labels_consurf
|
||||
, yaxis_title = ""
|
||||
, leg_position = "top"
|
||||
, subtitle_text = "ConSurf"
|
||||
, geom_ls = 5
|
||||
, bar_fill_values = consurf_colours # from globals
|
||||
, sts = sts
|
||||
, subtitle_colour= subtitle_colour)
|
||||
|
||||
consurfP
|
||||
#============================
|
||||
# output: CONSERVATION PLOTS
|
||||
#============================
|
||||
bp_conservation_CLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_bp_conservation_CL.svg" )
|
||||
# bp_conservation_CLP = paste0(outdir_images
|
||||
# ,tolower(gene)
|
||||
# ,"_bp_conservation_CL.svg" )
|
||||
#
|
||||
# print(paste0("plot filename:", bp_conservation_CLP))
|
||||
# svg(bp_conservation_CLP, width = 15, height = 6.5)
|
||||
#
|
||||
# cowplot::plot_grid(proveanP, snap2P, consurfP
|
||||
# , nrow = 1
|
||||
# , ncol = 3
|
||||
# #, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
# , labels = "AUTO"
|
||||
# , label_size = 25
|
||||
# #, rel_heights = c(0.4/10,9/10))
|
||||
# , rel_widths = c(0.9, 0.9, 1.1))
|
||||
#
|
||||
#
|
||||
# dev.off()
|
||||
#####################################################################
|
||||
# LAYOUT
|
||||
my_label_size = 25
|
||||
#ratio 11.69 by 8.27
|
||||
w = 8.27*2
|
||||
h = 11.69*2
|
||||
|
||||
print(paste0("plot filename:", bp_conservation_CLP))
|
||||
svg(bp_conservation_CLP, width = 15, height = 6.5)
|
||||
|
||||
cowplot::plot_grid(proveanP, snap2P, consurfP
|
||||
, nrow = 1
|
||||
, ncol = 3
|
||||
#, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
, labels = "AUTO"
|
||||
, label_size = 25
|
||||
#, rel_heights = c(0.4/10,9/10))
|
||||
, rel_widths = c(0.9, 0.9, 1.1))
|
||||
tit1 = "Stability outcome"
|
||||
tit2 = "Affinity outcome"
|
||||
tit3 = "Conservation outcome"
|
||||
|
||||
|
||||
theme_georgia <- function(...) {
|
||||
theme_gray(base_family = "sans", ...) +
|
||||
theme(plot.title = element_text(face = "bold"))
|
||||
}
|
||||
|
||||
|
||||
title_theme <- calc_element("plot.title", theme_georgia())
|
||||
|
||||
pt1 = ggdraw() +
|
||||
draw_label(
|
||||
tit1,
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
#size = title_theme$size
|
||||
size = 30
|
||||
)
|
||||
|
||||
pt2 = ggdraw() +
|
||||
draw_label(
|
||||
tit2,
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
size = 30
|
||||
)
|
||||
|
||||
pt3 = ggdraw() +
|
||||
draw_label(
|
||||
tit3,
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
size = 30
|
||||
)
|
||||
|
||||
# extract common legend
|
||||
common_legend_outcome = get_legend(mLigP +
|
||||
guides(color = guide_legend(nrow = 1)) +
|
||||
theme(legend.position = "top"))
|
||||
|
||||
|
||||
#=============
|
||||
# Output plot
|
||||
#=============
|
||||
OutPlotBP = function(x){
|
||||
cowplot::plot_grid(
|
||||
cowplot::plot_grid(pt1,
|
||||
common_legend_outcome,
|
||||
cowplot::plot_grid( duetP, foldxP
|
||||
, deepddgP, dynamut2P
|
||||
, nrow = 2
|
||||
, ncol = 2
|
||||
, labels = c("A", "B", "C","D")
|
||||
, label_size = my_label_size
|
||||
)
|
||||
, ncol = 1
|
||||
, rel_heights = c(7, 3, 90)),
|
||||
|
||||
cowplot::plot_grid(pt2,
|
||||
cowplot::plot_grid(mLigP, mmLigP, ppi2P
|
||||
, nrow = 1
|
||||
, ncol = 3
|
||||
, labels = c("E","F", "G")
|
||||
, label_size = my_label_size
|
||||
)
|
||||
, ncol = 1
|
||||
, rel_heights = c(1, 9)),
|
||||
|
||||
cowplot::plot_grid(pt3,
|
||||
cowplot::plot_grid(consurfP, proveanP, snap2P
|
||||
, nrow = 1
|
||||
, ncol = 3
|
||||
, labels = c("H", "I", "J")
|
||||
, labels_x = 0.2
|
||||
, label_size = my_label_size
|
||||
, rel_widths = c(0.2, 0.2, 0.2)
|
||||
)
|
||||
, ncol = 1
|
||||
, rel_heights = c(0.07, 0.93)
|
||||
),
|
||||
|
||||
nrow = 3,
|
||||
rel_heights = c(0.58, 0.25, 0.27),
|
||||
align = "hv"
|
||||
)
|
||||
}
|
||||
|
||||
bp_all_CLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_bp_all_CL.svg"); print(paste0("plot filename:", bp_all_CLP))
|
||||
|
||||
bp_all_CLP_png = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_bp_all_CL.png"); print(paste0("plot filename:", bp_all_CLP_png))
|
||||
|
||||
svg(bp_all_CLP, width = w, height = h)
|
||||
OutPlotBP()
|
||||
dev.off()
|
||||
|
||||
png(bp_all_CLP_png, width = w, height = h, units = "in", res = 300 )
|
||||
OutPlotBP()
|
||||
dev.off()
|
||||
|
||||
|
||||
#####################################################################
|
||||
#===============================================================
|
||||
# ------------------------------
|
||||
# bp site site count: ALL
|
||||
# <10 Ang ligand
|
||||
# ------------------------------
|
||||
|
||||
posC_all = site_snp_count_bp(plotdf = df3
|
||||
, df_colname = "position"
|
||||
, xaxis_title = ""
|
||||
, xaxis_title = "Number of nsSNPs"
|
||||
, yaxis_title = "Number of Sites"
|
||||
, subtitle_size = 20)
|
||||
|
||||
|
||||
# ------------------------------
|
||||
# bp site site count: mCSM-lig
|
||||
# < 10 Ang ligand
|
||||
|
@ -354,8 +461,7 @@ common_bp_title = paste0("Sites <", DistCutOff, angstroms_symbol)
|
|||
posC_lig = site_snp_count_bp(plotdf = df3_lig
|
||||
, df_colname = "position"
|
||||
, xaxis_title = "Number of nsSNPs"
|
||||
, yaxis_title = "" #+ annotate("text", x = 1.5, y = 2.2, label = "Text No. 1")
|
||||
|
||||
, yaxis_title = "Number of Sites"#+ annotate("text", x = 1.5, y = 2.2, label = "Text No. 1")
|
||||
, subtitle_text = paste0(common_bp_title, " ligand")
|
||||
, subtitle_size = 20
|
||||
, subtitle_colour = subtitle_colour)
|
||||
|
@ -366,8 +472,8 @@ posC_lig = site_snp_count_bp(plotdf = df3_lig
|
|||
|
||||
posC_ppi2 = site_snp_count_bp(plotdf = df3_ppi2
|
||||
, df_colname = "position"
|
||||
, xaxis_title = ""
|
||||
, yaxis_title = ""
|
||||
, xaxis_title = "Number of nsSNPs"
|
||||
, yaxis_title = "Number of Sites"
|
||||
, subtitle_text = paste0(common_bp_title, " interface")
|
||||
, subtitle_size = 20
|
||||
, subtitle_colour = subtitle_colour)
|
||||
|
@ -386,12 +492,13 @@ posC_ppi2 = site_snp_count_bp(plotdf = df3_ppi2
|
|||
# output: SITE SNP count:
|
||||
# all + affinity
|
||||
#==========================
|
||||
my_label_size = 25
|
||||
pos_count_combined_CLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_pos_count_PS_AFF.svg")
|
||||
|
||||
|
||||
svg(pos_count_combined_CLP, width = 15, height = 6.5)
|
||||
svg(pos_count_combined_CLP, width = 20, height = 5.5)
|
||||
print(paste0("plot filename:", pos_count_combined_CLP))
|
||||
|
||||
cowplot::plot_grid(posC_all, posC_lig, posC_ppi2
|
||||
|
@ -400,7 +507,9 @@ cowplot::plot_grid(posC_all, posC_lig, posC_ppi2
|
|||
, ncol = 3
|
||||
#, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
, labels = "AUTO"
|
||||
, label_size = 25)
|
||||
, label_size = my_label_size)
|
||||
|
||||
dev.off()
|
||||
|
||||
|
||||
#===============================================================
|
||||
|
|
27
scripts/plotting/plotting_thesis/basic_barplots_layout.R
Normal file
27
scripts/plotting/plotting_thesis/basic_barplots_layout.R
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env Rscript
|
||||
#########################################################
|
||||
#main script that generates plot objects:
|
||||
#source("basic_barplots.R")
|
||||
#########################################################
|
||||
|
||||
|
||||
|
||||
|
||||
#=======================================================================
|
||||
#=======
|
||||
# output
|
||||
#=======
|
||||
outdir_images = paste0("~/git/Writing/thesis/images/results/"
|
||||
, tolower(gene), "/")
|
||||
cat("plots will output to:", outdir_images)
|
||||
|
||||
df_colname = "duet_outcome"
|
||||
|
||||
OutPlot_count = ggplot(df3, aes_string(x = df_colname)) +
|
||||
geom_bar(aes(fill = eval(parse(text = df_colname)))
|
||||
, show.legend = TRUE) +
|
||||
geom_label(stat = "count"
|
||||
, aes(label = ..count..)
|
||||
, color = "black"
|
||||
, show.legend = FALSE
|
||||
, size = geom_ls)
|
25
scripts/plotting/plotting_thesis/linage_bp_dist_layout.R
Normal file
25
scripts/plotting/plotting_thesis/linage_bp_dist_layout.R
Normal file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env Rscript
|
||||
|
||||
###########################################
|
||||
my_label_size = 25
|
||||
|
||||
linPlots_combined = paste0(outdir_images
|
||||
, tolower(gene)
|
||||
,"_linP_combined.svg")
|
||||
|
||||
cat("\nOutput plot:", linPlots_combined)
|
||||
svg(linPlots_combined, width = 18, height = 12)
|
||||
|
||||
cowplot::plot_grid(
|
||||
cowplot::plot_grid(lin_countP, lin_diversityP
|
||||
, nrow = 2
|
||||
, labels = "AUTO"
|
||||
, label_size = my_label_size),
|
||||
NULL,
|
||||
linP_dm_om,
|
||||
nrow = 1,
|
||||
labels = c("", "", "C"),
|
||||
label_size = my_label_size,
|
||||
rel_widths = c(35, 3, 52)
|
||||
)
|
||||
dev.off()
|
|
@ -61,9 +61,6 @@ scaled_cols_stab_revised = c(scaled_cols_stab_revised, "foldx_scaled_signC")
|
|||
#=================
|
||||
# PREFORMATTING: for consistency
|
||||
#=================
|
||||
df2$sensitivity = ifelse(df2$dst_mode == 1, "R", "S")
|
||||
table(df2$sensitivity)
|
||||
|
||||
cols_to_extract = colnames(df2)[colnames(df2)%in%c(common_cols
|
||||
, outcome_cols_stability
|
||||
, raw_cols_stability
|
||||
|
@ -102,33 +99,56 @@ df2_plot["ens_stab_new_scaled"] = lapply(df2_plot["ens_stab_new"]
|
|||
)})
|
||||
|
||||
min(df2_plot['ens_stab_new']); max(df2_plot['ens_stab_new'])
|
||||
foo = df2_plot[c("cols2avg_new", "ens_stab_new_scaled")]
|
||||
foo = df2_plot[c("cols2avg_new", "ens_stab_new_scaled"),]
|
||||
min(df2_plot['ens_stab_new_scaled']); max(df2_plot['ens_stab_new_scaled'])
|
||||
|
||||
###########################################################
|
||||
nrow(df2_plot)
|
||||
table(df2_plot$lineage)
|
||||
table(df2_plot$lineage_labels)
|
||||
|
||||
|
||||
#===============
|
||||
#Quick numbers checks
|
||||
#===============
|
||||
nsample_lin = df2_plot[df2_plot$lineage%in%c("L1", "L2", "L3", "L4"),]
|
||||
|
||||
if ( all(table(nsample_lin$sensitivity)== table(nsample_lin$mutation_info_labels)) ){
|
||||
cat("\nTotal no. of samples belonging to L1-l4 for", gene,":", nrow(nsample_lin)
|
||||
, "\nCounting R and S samples")
|
||||
if( sum(table(nsample_lin$sensitivity)) == nrow(nsample_lin) ){
|
||||
cat("\nPASSNumbers cross checked:")
|
||||
print(table(nsample_lin$sensitivity))
|
||||
}
|
||||
}else{
|
||||
stop("Abort: Numbers mismatch. Please check")
|
||||
}
|
||||
|
||||
|
||||
#====================
|
||||
# Output Lineage plot
|
||||
#====================
|
||||
nsample_lin = merged_df2[merged_df2$lineage%in%c("L1", "L2", "L3", "L4"),]
|
||||
cat("\nTotal no. of samples belonging to L1-l4 for", gene,":", nrow(nsample_lin) )
|
||||
|
||||
linD_ens_stabP = paste0(outdir_images
|
||||
, tolower(gene)
|
||||
,"_linD_ens_stabP.svg")
|
||||
my_xlabel = paste0("Average stability ", "(", stability_suffix, ")"); my_xlabel
|
||||
|
||||
cat("\nOutput plot:", linD_ens_stabP)
|
||||
svg(linD_ens_stabP, width = 10, height = 10)
|
||||
# linD_ens_stabP = paste0(outdir_images
|
||||
# , tolower(gene)
|
||||
# ,"_linD_ens_stabP.svg")
|
||||
#
|
||||
# cat("\nOutput plot:", linD_ens_stabP)
|
||||
# svg(linD_ens_stabP, width = 10, height = 10)
|
||||
|
||||
linP_dm_om = lineage_distP(df2_plot
|
||||
, with_facet = F
|
||||
, x_axis = "ens_stab_new_scaled"
|
||||
, y_axis = "lineage_labels"
|
||||
, x_lab = "Average stability"
|
||||
, x_lab = my_xlabel
|
||||
, use_lineages = c("L1", "L2", "L3", "L4")
|
||||
#, fill_categ = "mutation_info_orig", fill_categ_cols = c("#E69F00", "#999999")
|
||||
, fill_categ = "sensitivity"
|
||||
, fill_categ_cols = c("red", "blue")
|
||||
, label_categories = c("Resistant", "Sensitive")
|
||||
, leg_label = ""
|
||||
, leg_label = "Mutation group"
|
||||
, my_ats = 22 # axis text size
|
||||
, my_als = 22 # axis label size
|
||||
, my_leg_ts = 22
|
||||
|
@ -138,4 +158,29 @@ linP_dm_om = lineage_distP(df2_plot
|
|||
)
|
||||
|
||||
linP_dm_om
|
||||
#dev.off()
|
||||
|
||||
###########################################
|
||||
my_label_size = 25
|
||||
|
||||
linPlots_combined = paste0(outdir_images
|
||||
, tolower(gene)
|
||||
,"_linP_combined.svg")
|
||||
|
||||
cat("\nOutput plot:", linPlots_combined)
|
||||
svg(linPlots_combined, width = 18, height = 12)
|
||||
|
||||
cowplot::plot_grid(
|
||||
cowplot::plot_grid(lin_countP, lin_diversityP
|
||||
, nrow = 2
|
||||
# , ncols = 2
|
||||
, labels = "AUTO"
|
||||
, label_size = my_label_size),
|
||||
NULL,
|
||||
linP_dm_om,
|
||||
nrow = 1,
|
||||
labels = c("", "", "C"),
|
||||
label_size = my_label_size,
|
||||
rel_widths = c(35, 3, 52)
|
||||
)
|
||||
dev.off()
|
|
@ -12,10 +12,10 @@ lin_countP = lin_count_bp(lf_data = lineage_dfL[['lin_lf']]
|
|||
, bar_fill_categ = "count_categ"
|
||||
, display_label_col = "p_count"
|
||||
, bar_stat_stype = "identity"
|
||||
, d_lab_size = 10
|
||||
, d_lab_size = 8
|
||||
, d_lab_col = "black"
|
||||
, my_xats = 25 # x axis text size
|
||||
, my_yats = 25 # y axis text size
|
||||
, my_yats = 25 # y axis text sized_lab_size
|
||||
, my_xals = 25 # x axis label size
|
||||
, my_yals = 25 # y axis label size
|
||||
, my_lls = 25 # legend label size
|
||||
|
@ -39,7 +39,7 @@ lin_diversityP = lin_count_bp_diversity(lf_data = lineage_dfL[['lin_wf']]
|
|||
, display_label_col = "snp_diversity_f"
|
||||
, bar_stat_stype = "identity"
|
||||
, x_lab_angle = 90
|
||||
, d_lab_size =10
|
||||
, d_lab_size =9
|
||||
, my_xats = 25 # x axis text size
|
||||
, my_yats = 25 # y axis text size
|
||||
, my_xals = 25 # x axis label size
|
||||
|
@ -49,7 +49,7 @@ lin_diversityP = lin_count_bp_diversity(lf_data = lineage_dfL[['lin_wf']]
|
|||
, y_scale_percent = F
|
||||
, leg_location = "top"
|
||||
, y_label = "Percent" #"SNP diversity"
|
||||
, bp_plot_title = "SNP diversity"
|
||||
, bp_plot_title = "nsSNP diversity"
|
||||
, title_colour = "black" #"chocolate4"
|
||||
, subtitle_text = NULL
|
||||
, sts = 20
|
||||
|
@ -58,18 +58,18 @@ lin_diversityP = lin_count_bp_diversity(lf_data = lineage_dfL[['lin_wf']]
|
|||
#=============================================
|
||||
# Output plots: Lineage count and Diversity
|
||||
#=============================================
|
||||
lineage_bp_CL = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_lineage_bp_CL_Tall.svg")
|
||||
|
||||
cat("Lineage barplots:", lineage_bp_CL)
|
||||
svg(lineage_bp_CL, width = 8, height = 15)
|
||||
|
||||
cowplot::plot_grid(lin_countP, lin_diversityP
|
||||
#, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
, nrow = 2
|
||||
# , ncols = 2
|
||||
, labels = "AUTO"
|
||||
, label_size = 25)
|
||||
|
||||
dev.off()
|
||||
# lineage_bp_CL = paste0(outdir_images
|
||||
# ,tolower(gene)
|
||||
# ,"_lineage_bp_CL_Tall.svg")
|
||||
#
|
||||
# cat("Lineage barplots:", lineage_bp_CL)
|
||||
# svg(lineage_bp_CL, width = 8, height = 15)
|
||||
#
|
||||
# cowplot::plot_grid(lin_countP, lin_diversityP
|
||||
# #, labels = c("(a)", "(b)", "(c)", "(d)")
|
||||
# , nrow = 2
|
||||
# # , ncols = 2
|
||||
# , labels = "AUTO"
|
||||
# , label_size = 25)
|
||||
#
|
||||
# dev.off()
|
|
@ -45,6 +45,9 @@ outcome_cols_stability = c("duet_outcome"
|
|||
, "ddg_dynamut2_outcome"
|
||||
, "foldx_outcome")
|
||||
|
||||
all_stability_cols = c(raw_cols_stability
|
||||
, scaled_cols_stability
|
||||
, outcome_cols_stability)
|
||||
#===================
|
||||
# affinity cols
|
||||
#===================
|
||||
|
@ -62,6 +65,10 @@ outcome_cols_affinity = c( "ligand_outcome"
|
|||
, "mmcsm_lig_outcome"
|
||||
, "mcsm_ppi2_outcome"
|
||||
, "mcsm_na_outcome")
|
||||
|
||||
all_affinity_cols = c(raw_cols_affinity
|
||||
, scaled_cols_affinity
|
||||
, outcome_cols_affinity)
|
||||
#===================
|
||||
# conservation cols
|
||||
#===================
|
||||
|
@ -73,28 +80,45 @@ scaled_cols_conservation = c("consurf_scaled"
|
|||
, "snap2_scaled"
|
||||
, "provean_scaled")
|
||||
|
||||
# CANNOT strictly be used, as categories are not identical with conssurf missing altogether
|
||||
outcome_cols_conservation = c("provean_outcome"
|
||||
, "snap2_outcome"
|
||||
, "consurf_colour_rev"
|
||||
, "consurf_colour"#doesn't exist,use this mapping
|
||||
)
|
||||
, "consurf_outcome")
|
||||
|
||||
all_conserv_cols = c(raw_cols_conservation
|
||||
, scaled_cols_conservation
|
||||
, outcome_cols_conservation)
|
||||
|
||||
|
||||
all_cols = c(common_cols
|
||||
, raw_cols_stability
|
||||
, scaled_cols_stability
|
||||
, outcome_cols_stability
|
||||
, raw_cols_affinity
|
||||
, scaled_cols_affinity
|
||||
, outcome_cols_affinity
|
||||
, raw_cols_conservation
|
||||
, scaled_cols_conservation
|
||||
, outcome_cols_conservation)
|
||||
, all_stability_cols
|
||||
, all_affinity_cols
|
||||
, all_conserv_cols)
|
||||
|
||||
########################################
|
||||
categ_cols_to_factor = grep( "_outcome|_info", colnames(merged_df3) )
|
||||
fact_cols = colnames(merged_df3)[categ_cols_to_factor]
|
||||
|
||||
if (any(lapply(merged_df3[, fact_cols], class) == "character")){
|
||||
cat("\nChanging", length(categ_cols_to_factor), "cols to factor")
|
||||
merged_df3[, fact_cols] <- lapply(merged_df3[, fact_cols], as.factor)
|
||||
if (all(lapply(merged_df3[, fact_cols], class) == "factor")){
|
||||
cat("\nSuccessful: cols changed to factor")
|
||||
}
|
||||
}else{
|
||||
cat("\nRequested cols aready factors")
|
||||
}
|
||||
|
||||
cat("\ncols changed to factor are:\n", colnames(merged_df3)[categ_cols_to_factor] )
|
||||
|
||||
####################################
|
||||
# merged_df3: NECESSARY pre-processing
|
||||
###################################
|
||||
df3 = merged_df3
|
||||
#df3 = merged_df3
|
||||
plot_cols = c("mutationinformation", "mutation_info_labels", "position", "dst_mode"
|
||||
, all_cols)
|
||||
|
||||
df3 = merged_df3[, colnames(merged_df3)%in%plot_cols]
|
||||
|
||||
#=================
|
||||
# PREFORMATTING: for consistency
|
||||
|
|
0
scripts/plotting/plotting_thesis/stats.R
Normal file
0
scripts/plotting/plotting_thesis/stats.R
Normal file
Loading…
Add table
Add a link
Reference in a new issue