moved combining_dfs_plotting.R to function and added test script for this as well
This commit is contained in:
parent
754cd70a6f
commit
5dec604742
5 changed files with 100 additions and 9 deletions
|
@ -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]]
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
#===============================================================
|
||||
#===============================================================
|
||||
|
|
87
scripts/functions/test_combining_dfs_plotting.R
Normal file
87
scripts/functions/test_combining_dfs_plotting.R
Normal file
|
@ -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 <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]]
|
Loading…
Add table
Add a link
Reference in a new issue