-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathclassifier_repeat_wrapper.R
71 lines (63 loc) · 2.53 KB
/
classifier_repeat_wrapper.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
# J. Taroni Jul 2016
# This script is a wrapper for running the BRCA subtype pipeline repeatedly with
# different random seeds.
# It should be run from the command line.
# USAGE: Rscript classifier_repeat_wrapper.R --cancer_type [BRCA|GBM] --predictor [subtype|TP53|PIK3CA] --n_repeats (default: 10) --null_model --ncores
option_list <- list(
optparse::make_option("--cancer_type",
default = NA_character_,
help = "Cancer type"),
optparse::make_option("--predictor",
default = NA_character_,
help = "Predictor used"),
optparse::make_option("--n_repeats",
default = 10,
help = "Number of times experiment is repeated [default: %default]"),
optparse::make_option("--null_model",
action = "store_true",
default = FALSE,
help = "Permute dependent variable (within subtype if predictor is a gene)"),
optparse::make_option("--ncores",
default = NA_integer_,
help = "Set the number of cores to use")
)
opt <- optparse::parse_args(optparse::OptionParser(option_list=option_list))
source(here::here("util/option_functions.R"))
check_options(opt)
# set options
cancer_type <- opt$cancer_type
predictor <- opt$predictor
n.repeats <- opt$n_repeats
null_model <- opt$null_model
ncores <- min(parallel::detectCores() - 1,
opt$ncores,
na.rm = TRUE)
message(paste("\nPredicting", predictor,
"in", cancer_type,
ifelse(null_model,
"(null model) ...",
"...")))
message(paste("\nNumber of repeats set to", n.repeats))
message(paste("\nUsing", ncores, "out of", parallel::detectCores(), "cores"))
initial.seed <- 12
set.seed(initial.seed)
seeds <- sample(1:10000, n.repeats)
rep.count <- 1
for(seed in seeds){
message(paste("\n\n#### REPEAT NUMBER", rep.count, "####\n\n"))
system(paste("Rscript run_experiments.R",
"--cancer_type", cancer_type,
"--predictor", predictor,
"--seed", seed,
ifelse(null_model,
"--null_model",
""),
"--ncores", ncores))
rep.count <- rep.count + 1
}
system(paste("Rscript 3-combine_category_kappa.R",
"--cancer_type", cancer_type,
"--predictor", predictor,
ifelse(null_model,
"--null_model",
"")))