From 7686aa39b489846557e3779342c6f099f6acd37c Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Fri, 11 Jun 2021 13:33:25 +0100 Subject: [PATCH] added script to test af_or_calcs --- .../{af_or_calcs.R => myaf_or_calcs.R} | 0 scripts/functions/test_af_or_calcs.R | 55 +++++++++++++++++++ .../functions/{test_functions.R => test_bp.R} | 0 3 files changed, 55 insertions(+) rename scripts/functions/{af_or_calcs.R => myaf_or_calcs.R} (100%) create mode 100644 scripts/functions/test_af_or_calcs.R rename scripts/functions/{test_functions.R => test_bp.R} (100%) diff --git a/scripts/functions/af_or_calcs.R b/scripts/functions/myaf_or_calcs.R similarity index 100% rename from scripts/functions/af_or_calcs.R rename to scripts/functions/myaf_or_calcs.R diff --git a/scripts/functions/test_af_or_calcs.R b/scripts/functions/test_af_or_calcs.R new file mode 100644 index 0000000..d48bfef --- /dev/null +++ b/scripts/functions/test_af_or_calcs.R @@ -0,0 +1,55 @@ +#!/usr/bin/env Rscript +######################################################### +# TASK: To calculate Allele Frequency and +# Odds Ratio from master data +######################################################### +# load libraries +#source("Header_TT.R") +require("getopt", quietly = TRUE) # cmd parse arguments + + +# load functions +source("functions/plotting_globals.R") +source("functions/mychisq_or.R") +source("functions/myaf_or_calcs.R") + +# cmd options + sensible defaults +drug = "streptomycin" +gene = "gid" + +# call function +import_dirs(drug, gene) + +# input file 1: master data +#in_filename_master = 'original_tanushree_data_v2.csv' #19K +in_filename_master = 'mtb_gwas_meta_v6.csv' #35k +infile_master = paste0(datadir, in_filename_master) +cat(paste0('Reading infile1: raw data', ' ', infile_master) ) + +# input file 2: gene associated meta data file to extract valid snps and add calcs to. +# This is outfile_metadata from data_extraction.py +in_filename_metadata = paste0(tolower(gene), '_metadata.csv') +infile_metadata = paste0(outdir, '/', in_filename_metadata) +cat(paste0('Reading input file 2 i.e gene associated metadata:', infile_metadata)) + +# out_filename_af_or = paste0(tolower(gene), '_meta_data_with_AF_OR.csv') +out_filename_af_or = paste0(tolower(gene), '_af_or.csv') +outfile_af_or = paste0(outdir, '/', out_filename_af_or) +cat(paste0('Output file with full path:', outfile_af_or)) + +cat("master data:", infile_master) +cat("gene data:", infile_metadata) + +dr_muts_col # comes from global (dr_mutations_) +other_muts_col # comes from global (other_mutations_) +################################################# +my_afor ( infile_master + , infile_metadata + , outfile = outfile_af_or + #, outfile = "FOO_TEST.csv" + , drug + , gene + , idcol = "id" + , dr_muts_col + , other_muts_col + ) diff --git a/scripts/functions/test_functions.R b/scripts/functions/test_bp.R similarity index 100% rename from scripts/functions/test_functions.R rename to scripts/functions/test_bp.R