#!/usr/bin/env Rscript ######################################################### # TASK: producing barplots for foldx # basic barplots with count of mutations # basic barplots with frequency of count of mutations ######################################################### #======================================================================= # working dir and loading libraries getwd() setwd("~/git/LSHTM_analysis/scripts/plotting") getwd() #source("Header_TT.R") library(ggplot2) library(data.table) library(dplyr) source("plotting_data.R") # should return the following dfs, directories and variables # my_df # my_df_u # my_df_u_lig # dup_muts cat(paste0("Directories imported:" , "\ndatadir:", datadir , "\nindir:", indir , "\noutdir:", outdir , "\nplotdir:", plotdir)) cat(paste0("Variables imported:" , "\ndrug:", drug , "\ngene:", gene , "\ngene_match:", gene_match , "\nLength of upos:", length(upos) , "\nAngstrom symbol:", angstroms_symbol)) # clear excess variable rm(my_df, upos, dup_muts, my_df_u_lig) #======================================================================= #======= # output #======= # plot 1 basic_bp_foldx = "basic_barplot_foldx.svg" plot_basic_bp_foldx = paste0(plotdir,"/", basic_bp_foldx) #======================================================================= #================ # Data for plots #================ # REASSIGNMENT as necessary df = my_df_u # sanity checks str(df) #======================================================================= #**************** # Plot 1:Count of stabilising and destabilsing muts #**************** svg(plot_basic_bp_foldx) print(paste0("plot1 filename:", plot_basic_bp_foldx)) my_ats = 25 # axis text size my_als = 22 # axis label size theme_set(theme_grey()) #-------------- # start plot 1 #-------------- g = ggplot(df, aes(x = foldx_outcome)) OutPlot_count = g + geom_bar(aes(fill = foldx_outcome) , show.legend = TRUE) + geom_label(stat = "count" , aes(label = ..count..) , color = "black" , show.legend = FALSE , size = 10) + theme(axis.text.x = element_blank() , axis.title.x = element_blank() , axis.title.y = element_text(size=my_als) , axis.text.y = element_text(size = my_ats) , legend.position = c(0.73,0.8) , legend.text = element_text(size=my_als-2) , legend.title = element_text(size=my_als) , plot.title = element_blank()) + labs(title = "" , y = "Number of SNPs" #, fill="FoldX Outcome" ) + scale_fill_discrete(name = "FoldX Outcome" , labels = c("Destabilising", "Stabilising")) print(OutPlot_count) dev.off() table(df$foldx_outcome) #=======================================================================