56 lines
1.6 KiB
R
56 lines
1.6 KiB
R
#!/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
|
|
#########################################################
|
|
# 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"
|
|
|
|
#%%===============================================================
|
|
|
|
|
|
|