fixed cmd running script problem for logo plots

This commit is contained in:
Tanushree Tunstall 2021-06-24 12:12:36 +01:00
parent 552c5e77aa
commit ca2315523d
14 changed files with 206 additions and 748 deletions

View file

@ -65,7 +65,7 @@ if (!is.character(infile_params) && exists("gene")){ # when running as cmd
cat("\nReading mcsm combined data file: ", infile_params)
mcsm_df = read.csv(infile_params, header = T)
pd_df = plotting_data(mcsm_df)
my_df_u = pd_df[[1]] # this forms one of the input for combining_dfs_plotting()
my_df_u = pd_df[[2]] # this forms one of the input for combining_dfs_plotting()
#--------------------------------
# call: combining_dfs_plotting()
@ -172,22 +172,24 @@ p0 = ggseqlogo(tab_mt
, seq_type = 'aa') +
#ylab('my custom height') +
theme(axis.text.x = element_blank()) +
theme(text=element_text(family="FreeSans"))+
theme_logo()+
scale_x_continuous(breaks = 1:ncol(tab_mt)
, labels = colnames(tab_mt))+
scale_y_continuous( breaks = 1:max_mult_mut
, limits = c(0, max_mult_mut))
p0
#p0
cat('p0 done\n')
# further customisation
p1 = p0 + theme(legend.position = "none"
, legend.title = element_blank()
, legend.text = element_text(size = 20)
, axis.text.x = element_text(size = 17, angle = 90)
, axis.text.y = element_blank())
p1
#p1
cat('p0+p1 done\n')
#==============
# matrix for wild type
# frequency of wild type by position
@ -218,14 +220,16 @@ p2 = ggseqlogo(tab_wt
#, col_scheme = chemistry2
) +
#ylab('my custom height') +
theme(text=element_text(family="FreeSans"))+
theme(axis.text.x = element_blank()
, axis.text.y = element_blank()) +
theme_logo() +
scale_x_continuous(breaks = 1:ncol(tab_wt)
, labels = colnames(tab_wt))
p2
#p2
# further customise
cat('p2 done\n')
p3 = p2 +
theme(legend.position = "bottom"
#, legend.title = element_blank()
@ -237,17 +241,20 @@ p3 = p2 +
labs(x= "Position")
p3
#p3
# Now combine using cowplot, which ensures the plots are aligned
suppressMessages( require(cowplot) )
plot_grid(p1, p3, ncol = 1, align = 'v') #+
cat('p3 done\n')
#plot_grid(p1, p3, ncol = 1, align = 'v') #+
cat('p3+p2 done\n')
#colour scheme
#https://rdrr.io/cran/ggseqlogo/src/R/col_schemes.r
cat("Output plot:", plot_logo_multiple_muts)
cat("Output plot:", plot_logo_multiple_muts, "\n")
svg(plot_logo_multiple_muts, width = 32, height = 10)
@ -257,4 +264,4 @@ OutPlot1 = cowplot::plot_grid(p1, p3
, rel_heights = c(3/4, 1/4))
print(OutPlot1)
dev.off()
#dev.off()