-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare_registry_conf.R
180 lines (155 loc) · 5.76 KB
/
prepare_registry_conf.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# ##############################################################################
#
## Run tests for a confounded simulation
#
# ##############################################################################
library("tidyverse")
library("batchtools")
library("here")
# load SIMBA
devtools::load_all(simba.loc)
# get sim & paramaters
args <- commandArgs(trailingOnly = TRUE)
simulation <- args[1]
sim.files <- list.files(here('simulations'),
full.names = TRUE, recursive = TRUE)
sim.file <- sim.files[str_detect(sim.files, pattern = simulation)]
if (length(sim.file) != 1){
stop("Cannot find the correct simulation!")
}
if (!file.exists(sim.file)){
stop("No such simulation exists!")
}
file.loc <- paste0(temp.loc, 'simulations/', simulation, '.h5')
# file.copy(from=sim.file, file.loc)
sim.params <- h5read(file.loc, name='simulation_parameters/sim_params')
# tests <- list or vector
tests <- c('limma', 'wilcoxon', 'lm', 'ANCOMBC', 'metagenomeSeq2',
'wilcoxon_conf', 'limma_conf', 'ANCOMBC_conf',
'lme_conf', 'fastANCOM', 'fastANCOM_conf', "corncob", "corncob_conf")
# make experiment registry - might need to load pkgs here
job.registry <- paste0(temp.loc, 'test_results_registries/',
paste0(simulation, '_test'))
if (!dir.exists(job.registry)) {
reg <- makeExperimentRegistry(file.dir = job.registry,
work.dir = here(),
conf.file = here('cluster_config',
'batchtools_test_conf.R'),
make.default = TRUE)
} else {
stop("Registry already exists!")
}
# get groups -- e.g. ab1_rep1
temp <- h5ls(file.loc, recursive=FALSE)
groups <- setdiff(temp$name, c('original_data', 'simulation_parameters'))
conf.params <- h5read(file.loc, name='simulation_parameters/conf_bias_test_idx')
bias.terms <- conf.params$bias
subsets <- conf.params$subsets
### ADD PROBLEMS, ALGORITHMS, THEN EXPERIMENTS
sim.location <- file.loc
# add problems
addProblem(name = simulation,
data = sim.location,
fun = function(data, job) data,
reg = reg)
# add algorithms (tests)
.f_apply <- function(data, job, instance, group, subsets, norm, test,
bias, ...){
type <- paste0('confounder::', bias)
if (grepl('_conf', test)){
conf <- 'conf'
test <- gsub(x=test, pattern='_conf', replacement='')
} else {
conf <- NULL
}
apply.test(sim.location = data,
group=group,
subset=subsets,
norm=norm,
test=test,
type=type,
conf=conf)
}
walk(tests, ~ addAlgorithm(name = ., fun = .f_apply))
# a bit manual tweaking, but could work...
ades.fast <- c('fastANCOM', 'fastANCOM_conf') %>%
map(~ data.table::CJ(test = .,
group=unique(str_remove(groups, '_rep[0-9]*$')),
norm = c('pass'),
subsets=NA_real_,
bias=seq_along(bias.terms))) %>%
set_names(c('fastANCOM', 'fastANCOM_conf'))
addExperiments(algo.designs = ades.fast)
submitJobs()
# corncob
groups <- groups[str_detect(groups, 'rep[1-9]{1}$')]
ades.ancombc <- c('corncob', 'corncob_conf') %>%
map(~ data.table::CJ(test = .,
group=groups,
norm = c('pass'),
subsets=NA_real_,
bias=seq_along(bias.terms))) %>%
set_names(c('corncob', 'corncob_conf'))
# slow tests
ades.ancombc <- c('ANCOMBC', 'ANCOMBC_conf') %>%
map(~ data.table::CJ(test = .,
group=groups,
norm = c('pass'),
subsets=NA_real_,
bias=seq_along(bias.terms))) %>%
set_names(c('ANCOMBC', 'ANCOMBC_conf'))
# limma
ades.limma <- c('limma', 'limma_conf') %>%
map(~ data.table::CJ(test=.,
group=unique(str_remove(groups, '_rep[0-9]*$')),
norm = c('TSS.arcsin'),
subsets=NA_real_,
bias=seq_along(bias.terms))) %>%
set_names(c('limma', 'limma_conf'))
# LM
ades.lm <- c('lm') %>%
map(~ data.table::CJ(test=.,
group=unique(str_remove(groups, '_rep[0-9]*$')),
norm = c('TSS.log'),
subsets=NA_real_,
bias=seq_along(bias.terms))) %>%
set_names(c('lm'))
ades.lme.c <- c('lme_conf') %>%
map(~ data.table::CJ(test=.,
group=groups,
norm = c('TSS.log'),
subsets=NA_real_,
bias=seq_along(bias.terms))) %>%
set_names(c('lme_conf'))
# wilcoxon
ades.wi <- c('wilcoxon') %>%
map(~ data.table::CJ(test=.,
group=unique(str_remove(groups, '_rep[0-9]*$')),
norm = c('TSS'),
subsets=NA_real_,
bias=seq_along(bias.terms))) %>%
set_names(c('wilcoxon'))
# wilcoxon_conf
ades.wi.c <- c('wilcoxon_conf') %>%
map(~ data.table::CJ(test=.,
group=groups,
norm = c('TSS'),
subsets=NA_real_,
bias=seq_along(bias.terms))) %>%
set_names(c('wilcoxon_conf'))
# others
ades.m <- c('metagenomeSeq2') %>%
map(~ data.table::CJ(test = .,
group=groups,
norm = c('pass'),
subsets=NA_real_),
bias=seq_along(bias.terms)) %>%
set_names(c('metagenomeSeq2'))
ades <- append(ades.ancombc, ades.limma) %>%
append(ades.lm) %>%
append(ades.lme.c) %>%
append(ades.wi) %>%
append(ades.wi.c) %>%
append(ades.m)
addExperiments(algo.designs = ades, reg = reg)
submitJobs(x$job.id, resources=list(max.concurrent.jobs=2000))