LSHTM_analysis/scripts/plotting/barplots_subcolours.R

127 lines
3.5 KiB
R
Executable file

#!/usr/bin/env Rscript
getwd()
setwd("~/git/LSHTM_analysis/scripts/plotting")
getwd()
source("Header_TT.R")
drug = 'streptomycin'
gene = 'gid'
spec = matrix(c(
"drug" , "d", 1, "character",
"gene" , "g", 1, "character",
"data_file1" , "fa", 2, "character",
"data_file2" , "fb", 2, "character"
), byrow = TRUE, ncol = 4)
opt = getopt(spec)
drug = opt$drug
gene = opt$gene
infile_params = opt$data_file1
infile_metadata = opt$data_file2
if(is.null(drug)|is.null(gene)) {
stop("Missing arguments: --drug and --gene must both be specified (case-sensitive)")
}
#===========
# Input
#===========
source("get_plotting_dfs.R")
#===========
# output
#===========
# PS
bp_subcols_duet = "barplot_coloured_PS.svg"
plot_bp_subcols_duet = paste0(plotdir, "/", bp_subcols_duet)
# LIG
bp_subcols_lig = "barplot_coloured_LIG.svg"
plot_bp_subcols_lig = paste0(plotdir, "/", bp_subcols_lig)
##############################################################################
#********************
# generate plot: PS
# NO axis colours
#********************
# axis label size
my_xaxls = 12
my_yaxls = 20
# axes text size
my_xaxts = 18
my_yaxts = 20
title_ps = "Protein stability (DUET)"
print(paste0("plot name:", plot_bp_subcols_duet))
svg(plot_bp_subcols_duet, width = 26, height = 4)
g = ggplot(subcols_df_ps, aes(factor(position, ordered = T)))
outPlot_bp_ps = g +
geom_bar(aes(fill = group), colour = "grey") +
scale_fill_manual( values = subcols_ps
, guide = "none") +
theme( axis.text.x = element_text(size = my_xaxls
, angle = 90
, hjust = 1
, vjust = 0.4)
, axis.text.y = element_text(size = my_yaxls
, angle = 0
, hjust = 1
, vjust = 0)
, axis.title.x = element_text(size = my_xaxts)
, axis.title.y = element_text(size = my_yaxts ) ) +
labs(title = ""
#title = title_ps
, x = "Position"
, y = "Frequency")
print(outPlot_bp_ps)
dev.off()
####################################################
#******************
# generate plot: LIG
# NO axis colours
#******************
# axis label size
my_xaxls = 12
my_yaxls = 20
# axes text size
my_xaxts = 18
my_yaxts = 20
title_lig = "Ligand Affinity"
print(paste0("plot name:", plot_bp_subcols_lig))
svg(plot_bp_subcols_lig, width = 26, height = 4)
g2 = ggplot(subcols_df_lig, aes(factor(position, ordered = T)))
outPlot_bp_lig = g2 +
geom_bar(aes(fill = group_lig), colour = "grey") +
scale_fill_manual( values = subcols_lig
, guide = "none") +
theme( axis.text.x = element_text(size = my_xaxls
, angle = 90
, hjust = 1
, vjust = 0.4)
, axis.text.y = element_text(size = my_yaxls
, angle = 0
, hjust = 1
, vjust = 0)
, axis.title.x = element_text(size = my_xaxts)
, axis.title.y = element_text(size = my_yaxts ) ) +
labs(title = ""
#title = title_lig
, x = "Position"
, y = "Frequency")
print(outPlot_bp_lig)
dev.off()
######################################################################=
# End of script
######################################################################=