-
Notifications
You must be signed in to change notification settings - Fork 2
/
gene_vul_plots_parallel.R
81 lines (57 loc) · 2.08 KB
/
gene_vul_plots_parallel.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Vulnerability modeling - parallel
# Imports ----
source("vulnerability_modeling_tools.R")
source("vulnerability_plotting_tools.R")
require("optparse")
# Options ----
# Main ----
args = commandArgs(trailingOnly=TRUE)
# test if there is at least one argument: if not, return an error
option_list = list(
# Data stuff:
make_option("--data", type="character", default="",
help="Input data"),
make_option("--dir", type="character", default="./",
help="Base data dir"),
make_option("--strain", type="character", default="",
help="The strain used for this data e.g. H37Rv"),
make_option("--label", type="character", default="",
help="Label to use aka strain_exp_date"),
make_option("--genes", type="character", default="",
help="Gene path"),
make_option("--output", type="character", default="./data",
help="Output dir"),
#System stuff:
make_option("--cores", type="numeric", default=20,
help="Number of cores to use"),
# plotting stuff:
make_option("--ymax", type="numeric", default=0.05,
help="Max value for the y-axis"),
make_option("--ymin", type="numeric", default=-1.0,
help="minimum for the y-axis")
);
opt_parser = OptionParser(option_list=option_list);
opt = parse_args(opt_parser);
desired_strain = opt$strain
label = paste(opt$label, sep="_")
has_necessary_stuff = opt$label !="" & opt$strain !=""
stopifnot(has_necessary_stuff)
if (file.exists(opt$data)){
DATA_PATH = opt$data
} else {
DATA_PATH = file.path(opt$dir, paste0("data_", label, ".txt"))
}
DEBUG = FALSE
XFULL = read.table(DATA_PATH, sep=",", stringsAsFactors = FALSE, header=T)
ii_bad = is.na(XFULL$ESS)
XFULL$ESS[ii_bad] = "N/A"
data = XFULL
unique_genes = unique(data$ORF)
if(opt$cores > 1){
mclapply(unique_genes, plot_samples, mc.cores=opt$cores, strain=desired_strain,
folder=label, prefix=opt$output)
} else {
for(gene in unique_genes){
plot_samples(gene, strain=desired_strain, folder=label, prefix=opt$output)
}
}