adpated combining_dfs.py and plotting.R for gid and attempting to make it generic
This commit is contained in:
parent
2c5c704d0b
commit
a1fef205da
3 changed files with 91 additions and 81 deletions
|
@ -1,56 +1,24 @@
|
|||
#!/usr/bin/env Rscript
|
||||
#########################################################
|
||||
# TASK: formatting data that will be used for various plots
|
||||
|
||||
# useful links
|
||||
#https://stackoverflow.com/questions/38851592/r-append-column-in-a-dataframe-with-frequency-count-based-on-two-columns
|
||||
# TASK: importing dir str
|
||||
# create a function that takes 'drug' and 'gene' as args,
|
||||
# This script is sourced by plotting.R to import dir str
|
||||
# for various plots, etc.
|
||||
#########################################################
|
||||
# working dir and loading libraries
|
||||
getwd()
|
||||
setwd("~/git/LSHTM_analysis/scripts/plotting")
|
||||
getwd()
|
||||
|
||||
#source("Header_TT.R")
|
||||
library(ggplot2)
|
||||
library(data.table)
|
||||
library(dplyr)
|
||||
|
||||
require("getopt", quietly = TRUE) #cmd parse arguments
|
||||
#========================================================
|
||||
# command line args
|
||||
#spec = matrix(c(
|
||||
# "drug" , "d", 1, "character",
|
||||
# "gene" , "g", 1, "character"
|
||||
#), byrow = TRUE, ncol = 4)
|
||||
|
||||
#opt = getopt(spec)
|
||||
|
||||
#drug = opt$druggene = opt$gene
|
||||
|
||||
#if(is.null(drug)|is.null(gene)) {
|
||||
# stop("Missing arguments: --drug and --gene must both be specified (case-sensitive)")
|
||||
#}
|
||||
#========================================================
|
||||
# FIXME: change to cmd
|
||||
#%% variable assignment: input and output paths & filenames
|
||||
drug = "pyrazinamide"
|
||||
gene = "pncA"
|
||||
gene_match = paste0(gene,"_p.")
|
||||
cat(gene_match)
|
||||
|
||||
#=============
|
||||
# directories and variables
|
||||
#=============
|
||||
datadir = paste0("~/git/Data")
|
||||
indir = paste0(datadir, "/", drug, "/input")
|
||||
outdir = paste0("~/git/Data", "/", drug, "/output")
|
||||
plotdir = paste0("~/git/Data", "/", drug, "/output/plots")
|
||||
|
||||
dr_muts_col = paste0('dr_mutations_', drug)
|
||||
other_muts_col = paste0('other_mutations_', drug)
|
||||
resistance_col = "drtype"
|
||||
|
||||
#%%===============================================================
|
||||
|
||||
|
||||
|
||||
import_dirs <- function(drug, gene) {
|
||||
gene_match = paste0(gene,"_p.")
|
||||
cat(gene_match)
|
||||
|
||||
#=============
|
||||
# directories and variables
|
||||
#=============
|
||||
datadir <<- paste0("~/git/Data")
|
||||
indir <<- paste0(datadir, "/", drug, "/input")
|
||||
outdir <<- paste0("~/git/Data", "/", drug, "/output")
|
||||
plotdir <<- paste0("~/git/Data", "/", drug, "/output/plots")
|
||||
|
||||
dr_muts_col <<- paste0('dr_mutations_', drug)
|
||||
other_muts_col <<- paste0('other_mutations_', drug)
|
||||
resistance_col <<- "drtype"
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue