diff --git a/scripts/plotting/combining_dfs_plotting.R b/scripts/functions/combining_dfs_plotting.R similarity index 100% rename from scripts/plotting/combining_dfs_plotting.R rename to scripts/functions/combining_dfs_plotting.R diff --git a/scripts/functions/test_aa_prop_bp.R b/scripts/functions/test_aa_prop_bp.R index 29931cc..e793091 100644 --- a/scripts/functions/test_aa_prop_bp.R +++ b/scripts/functions/test_aa_prop_bp.R @@ -2,14 +2,14 @@ library(ggplot2) library(tidyverse) library(data.table) -setwd("~/git/LSHTM_analysis/scripts/plotting/functions") +setwd("~/git/LSHTM_analysis/scripts/functions/") getwd() ############################################################# #=========================================== # load functions, data, dirs, hardocded vars # that will be used in testing the functions #=========================================== -source("../plotting_data.R") +source("plotting_data.R") infile = "/home/tanu/git/Data/streptomycin/output/" pd_df = plotting_data(infile) my_df = pd_df[[1]] diff --git a/scripts/functions/test_af_or_calcs.R b/scripts/functions/test_af_or_calcs.R index d48bfef..0532f83 100644 --- a/scripts/functions/test_af_or_calcs.R +++ b/scripts/functions/test_af_or_calcs.R @@ -7,11 +7,15 @@ #source("Header_TT.R") require("getopt", quietly = TRUE) # cmd parse arguments +# working dir and loading libraries +getwd() +setwd("~/git/LSHTM_analysis/scripts/functions/") +getwd() # load functions -source("functions/plotting_globals.R") -source("functions/mychisq_or.R") -source("functions/myaf_or_calcs.R") +source("plotting_globals.R") +source("mychisq_or.R") +source("myaf_or_calcs.R") # cmd options + sensible defaults drug = "streptomycin" diff --git a/scripts/functions/test_bp.R b/scripts/functions/test_bp.R index bf8621e..a71c94a 100644 --- a/scripts/functions/test_bp.R +++ b/scripts/functions/test_bp.R @@ -1,11 +1,11 @@ -setwd("~/git/LSHTM_analysis/scripts/plotting/functions") +setwd("~/git/LSHTM_analysis/scripts/functions/") getwd() ############################################################# #=========================================== # load functions, data, dirs, hardocded vars # that will be used in testing the functions #=========================================== -source("../plotting_data.R") +source("plotting_data.R") infile = "/home/tanu/git/Data/streptomycin/output/gid_comb_stab_struc_params.csv" pd_df = plotting_data(infile) my_df = pd_df[[1]] @@ -13,7 +13,7 @@ my_df_u = pd_df[[2]] my_df_u_lig = pd_df[[3]] dup_muts = pd_df[[4]] -source("../plotting_globals.R") +source("plotting_globals.R") drug = "streptomycin" gene = "gid" @@ -100,4 +100,4 @@ site_snp_count_bp(plotdf = my_df_u_lig , df_colname = "position") dev.off() -#=============================================================== \ No newline at end of file +#=============================================================== diff --git a/scripts/functions/test_combining_dfs_plotting.R b/scripts/functions/test_combining_dfs_plotting.R new file mode 100644 index 0000000..daa6ec3 --- /dev/null +++ b/scripts/functions/test_combining_dfs_plotting.R @@ -0,0 +1,87 @@ +# #!/usr/bin/env Rscript + +# working dir and loading libraries +getwd() +setwd("~/git/LSHTM_analysis/scripts/functions/") +getwd() + +# infile_params = paste0(outdir, "/" , tolower(gene), "_comb_afor.csv") +# infile_metadata = paste0(outdir, "/", tolower(gene), "_metadata") +# +# +# source("combining_dfs_plotting_func.R") +# +#################################################################### +# in_file_params = "~/git/Data/streptomycin/output/gid_comb_afor.csv" +# in_file_metadata = "~/git/Data/streptomycin/output/gid_metadata.csv" +# +# all_plot_dfs = combining_dfs_plotting(df1_mcsm_comb = infile_params +# , df2_gene_metadata = infile_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]] +# +# bar_colnames = data.frame(colnames(merged_df2)) +########################################################### +source("plotting_globals.R") +source("plotting_data.R") +source("combining_dfs_plotting.R") + +gene = 'gid' +drug = 'streptomycin' + +#--------------------- +# call: import_dirs() +#--------------------- +import_dirs(drug, gene) + +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") +} + +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 1: plotting_data() +#============================ +#--------------------- +# call: plotting_data() +#--------------------- +pd_df = plotting_data(infile_params) +my_df = pd_df[[1]] # this forms one of the input for combining_dfs_plotting() + +#====================================== +# Input 2: read _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]]