changes made to combining_dfs_plotting.R

This commit is contained in:
Tanushree Tunstall 2021-06-23 16:15:15 +01:00
parent c6d1260f74
commit 2aec79af31
9 changed files with 258 additions and 126 deletions

View file

@ -10,14 +10,66 @@ setwd("~/git/LSHTM_analysis/scripts/plotting")
getwd()
source("Header_TT.R")
#library(ggplot2)
#library(data.table)
#library(dplyr)
source("../functions/plotting_globals.R")
source("../functions/plotting_data.R")
source("../functions/combining_dfs_plotting.R")
###########################################################
# command line args
#********************
drug = 'streptomycin'
gene = 'gid'
#===========
# input
#===========
source("combining_dfs_plotting.R")
#---------------------
# call: import_dirs()
#---------------------
import_dirs(drug, gene)
#---------------------------
# call: plotting_data()
#---------------------------
if (!exists("infile_params") && exists("gene")){
#if (!is.character(infile_params) && exists("gene")){
#in_filename_params = paste0(tolower(gene), "_all_params.csv")
in_filename_params = paste0(tolower(gene), "_comb_afor.csv") # part combined for gid
infile_params = paste0(outdir, "/", in_filename_params)
cat("\nInput file for mcsm comb data not specified, assuming filename: ", infile_params, "\n")
}
# Input 1: read <gene>_comb_afor.csv
pd_df = plotting_data(infile_params)
my_df_u = pd_df[[1]] # this forms one of the input for combining_dfs_plotting()
#--------------------------------
# call: combining_dfs_plotting()
#--------------------------------
if (!exists("infile_metadata") && exists("gene")){
#if (!is.character(infile_params) && exists("gene")){{
in_filename_metadata = paste0(tolower(gene), "_metadata.csv") # part combined for gid
infile_metadata = paste0(outdir, "/", in_filename_metadata)
cat("\nInput file for gene metadata not specified, assuming filename: ", infile_metadata, "\n")
}
# Input 2: read <gene>_meta data.csv
cat("\nReading meta data file:", infile_metadata)
gene_metadata <- read.csv(infile_metadata
, stringsAsFactors = F
, header = T)
all_plot_dfs = combining_dfs_plotting(my_df_u
, gene_metadata
, lig_dist_colname = 'ligand_distance'
, lig_dist_cutoff = 10)
#merged_df2 = all_plot_dfs[[1]]
merged_df3 = all_plot_dfs[[2]]
#merged_df2_comp = all_plot_dfs[[3]]
#merged_df3_comp = all_plot_dfs[[4]]
#merged_df2_lig = all_plot_dfs[[5]]
#merged_df3_lig = all_plot_dfs[[6]]
#===========
# output
@ -32,12 +84,6 @@ plot_logo_multiple_muts = paste0(plotdir,"/", logo_multiple_muts)
# REASSIGNMENT
my_df = merged_df3
#%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# clear excess variables
rm(merged_df2, merged_df2_comp, merged_df2_lig, merged_df2_comp_lig
, merged_df3_comp, merged_df3_comp_lig
, my_df_u, my_df_u_lig, merged_df3_lig)
colnames(my_df)
str(my_df)
@ -117,7 +163,7 @@ p0
p1 = p0 + theme(legend.position = "none"
, legend.title = element_blank()
, legend.text = element_text(size = 20)
, axis.text.x = element_text(size = 20, angle = 90)
, axis.text.x = element_text(size = 17, angle = 90)
, axis.text.y = element_blank())
p1
@ -138,7 +184,6 @@ rownames(tab_wt)
#**************
# Plot 2: wild_type logo
#**************
# sanity check: MUST BE TRUE
@ -164,8 +209,8 @@ p3 = p2 +
theme(legend.position = "bottom"
#, legend.title = element_blank()
, legend.title = element_text("Amino acid properties", size = 20)
, legend.text = element_text( size = 20)
, axis.text.x = element_text(size = 20, angle = 90)
, legend.text = element_text(size = 20)
, axis.text.x = element_text(size = 17, angle = 90)
, axis.text.y = element_blank()
, axis.title.x = element_text(size = 22))+