106 lines
3.5 KiB
R
Executable file
106 lines
3.5 KiB
R
Executable file
#!/usr/bin/env Rscript
|
|
getwd()
|
|
setwd("~/git/LSHTM_analysis/scripts/plotting")
|
|
getwd()
|
|
source("~/git/LSHTM_analysis/scripts/Header_TT.R")
|
|
|
|
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
|
|
#===========
|
|
logo_or_plotname = "logo_or_plot.svg"
|
|
plot_logo_or = paste0(plotdir,"/", logo_or_plotname)
|
|
|
|
logo_logOR_plotname = "logo_logOR_plot.svg"
|
|
plot_logo_logOR = paste0(plotdir,"/", logo_logOR_plotname)
|
|
|
|
##############################################################################
|
|
|
|
#================================
|
|
# Logo plot: custom height (OR)
|
|
#================================
|
|
cat("Logo plot with OR as y axis:", plot_logo_or)
|
|
svg(plot_logo_or, width = 30 , height = 6)
|
|
|
|
logo_or = ggseqlogo(wide_df_or
|
|
, method = "custom"
|
|
, seq_type = "aa") + ylab("my custom height") +
|
|
theme( axis.text.x = element_text(size = 12
|
|
, angle = 90
|
|
, hjust = 1
|
|
, vjust = 0.4)
|
|
, axis.text.y = element_text(size = 22
|
|
, angle = 0
|
|
, hjust = 1
|
|
, vjust = 0)
|
|
, axis.title.y = element_text(size = 25)
|
|
, axis.title.x = element_text(size = 20)
|
|
#, legend.position = "bottom") +
|
|
, legend.position = "none")+
|
|
#, legend.text = element_text(size = 15)
|
|
#, legend.title = element_text(size = 15))+
|
|
scale_x_discrete("Position"
|
|
#, breaks
|
|
, labels = position_or
|
|
, limits = factor(1:length(position_or))) +
|
|
ylab("Odds Ratio")
|
|
|
|
print(logo_or)
|
|
dev.off()
|
|
|
|
#=======================================
|
|
# Logo plot: custom height (Log10 OR)
|
|
#=======================================
|
|
cat("Logo plot with log10 OR as y axis:", plot_logo_logOR)
|
|
svg(plot_logo_logOR, width = 30 , height = 6)
|
|
|
|
logo_logOR = ggseqlogo(wide_df_logor_m
|
|
, method = "custom"
|
|
, seq_type="aa") + ylab("my custom height") +
|
|
theme(legend.position = "bottom"
|
|
, axis.text.x = element_text(size = 13
|
|
, angle = 90
|
|
, hjust = 1
|
|
, vjust = 0.4)
|
|
, axis.text.y = element_text(size = 20
|
|
, angle = 0
|
|
, hjust = 1
|
|
, vjust = 0)
|
|
, axis.title.y = element_text(size = 25)
|
|
, axis.title.x = element_text(size = 20))+
|
|
scale_x_discrete("Position"
|
|
#, breaks
|
|
, labels = position_logor
|
|
, limits = factor(1:length(position_logor)))+
|
|
ylab("Log (Odds Ratio)") +
|
|
scale_y_continuous(limits = c(0, 9))
|
|
|
|
print(logo_logOR)
|
|
dev.off()
|
|
|
|
######################################################################=
|
|
# End of script
|
|
######################################################################=
|