added separate scripts for layout for convinience
This commit is contained in:
parent
d78b072732
commit
cd86fcf8e8
6 changed files with 468 additions and 78 deletions
|
@ -1,27 +1,198 @@
|
|||
#!/usr/bin/env Rscript
|
||||
#########################################################
|
||||
#main script that generates plot objects:
|
||||
#source("basic_barplots.R")
|
||||
#########################################################
|
||||
# source basic_barplots.R
|
||||
|
||||
#============
|
||||
# Plot labels
|
||||
#============
|
||||
tit1 = "Stability outcome"
|
||||
tit2 = "Affinity outcome"
|
||||
tit3 = "Conservation outcome"
|
||||
pt_size = 30
|
||||
|
||||
|
||||
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 = pt_size
|
||||
)
|
||||
|
||||
pt2 = ggdraw() +
|
||||
draw_label(
|
||||
tit2,
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
size = pt_size
|
||||
)
|
||||
|
||||
pt3 = ggdraw() +
|
||||
draw_label(
|
||||
tit3,
|
||||
fontfamily = title_theme$family,
|
||||
fontface = title_theme$face,
|
||||
size = pt_size
|
||||
)
|
||||
|
||||
# extract common legend
|
||||
common_legend_outcome = get_legend(mLigP +
|
||||
guides(color = guide_legend(nrow = 1)) +
|
||||
theme(legend.position = "top"))
|
||||
|
||||
|
||||
|
||||
my_label_size = 25
|
||||
#======================
|
||||
# Output plot function
|
||||
#======================
|
||||
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"
|
||||
)
|
||||
}
|
||||
|
||||
#=======================================================================
|
||||
#=======
|
||||
# output
|
||||
#=======
|
||||
outdir_images = paste0("~/git/Writing/thesis/images/results/"
|
||||
, tolower(gene), "/")
|
||||
cat("plots will output to:", outdir_images)
|
||||
#=====================
|
||||
# OutPlot: svg and png
|
||||
#======================
|
||||
#ratio 11.69 by 8.27
|
||||
w = 8.27*2
|
||||
h = 11.69*2
|
||||
|
||||
df_colname = "duet_outcome"
|
||||
#svg
|
||||
bp_all_CLP = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_bp_all_CL.svg")
|
||||
cat(paste0("plot filename:", bp_all_CLP))
|
||||
|
||||
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)
|
||||
svg(bp_all_CLP, width = w, height = h)
|
||||
OutPlotBP()
|
||||
dev.off()
|
||||
|
||||
#png
|
||||
bp_all_CLP_png = paste0(outdir_images
|
||||
,tolower(gene)
|
||||
,"_bp_all_CL.png")
|
||||
cat(paste0("plot filename:", bp_all_CLP_png))
|
||||
|
||||
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 = "Number of nsSNPs"
|
||||
, yaxis_title = "Number of Sites"
|
||||
, subtitle_size = 20)
|
||||
|
||||
# ------------------------------
|
||||
# bp site site count: mCSM-lig
|
||||
# < 10 Ang ligand
|
||||
# ------------------------------
|
||||
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 = "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)
|
||||
# ------------------------------
|
||||
# bp site site count: ppi2
|
||||
# < 10 Ang interface
|
||||
# ------------------------------
|
||||
|
||||
posC_ppi2 = site_snp_count_bp(plotdf = df3_ppi2
|
||||
, df_colname = "position"
|
||||
, xaxis_title = "Number of nsSNPs"
|
||||
, yaxis_title = "Number of Sites"
|
||||
, subtitle_text = paste0(common_bp_title, " interface")
|
||||
, subtitle_size = 20
|
||||
, subtitle_colour = subtitle_colour)
|
||||
|
||||
# ------------------------------
|
||||
#FIXME: bp site site count: na
|
||||
# < 10 Ang TBC
|
||||
# ------------------------------
|
||||
# posC_na = site_snp_count_bp(plotdf = df3_na
|
||||
# , df_colname = "position"
|
||||
# , xaxis_title = ""
|
||||
# , yaxis_title = "")
|
||||
|
||||
|
||||
#===========================
|
||||
# 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 = 20, height = 5.5)
|
||||
print(paste0("plot filename:", pos_count_combined_CLP))
|
||||
|
||||
cowplot::plot_grid(posC_all, posC_lig, posC_ppi2
|
||||
#, posC_na
|
||||
, nrow = 1
|
||||
, ncol = 3
|
||||
, labels = "AUTO"
|
||||
, label_size = my_label_size)
|
||||
|
||||
dev.off()
|
||||
|
||||
|
||||
#===============================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue