#'@title Wrapper function for simulations attempting to use batchtools package
#'@description TBD
#'@param df.stats a nested data.frames of a single high-throughput data type
#'@param structure either 'single.factor' or 'n.factor' (currently only for n = 2)
#'@param type one of 'bootstrap', 'gaussian', or 'nbinom'
#'@param n the number of simulations to run OR NA if replication carried
#' out elsewhere (e.g. within the batchtools framework)
#'@param s.var the stratification variable as a character string OR NULL for pooled analysis
#'@param parallel a character string specifying parallelization strategy,
#' e.g. 'multicore' if forked processes are supported or 'multiprocess' for any system
#'@return a list of data frames, each with additional list-columns of simulated values
#'@importFrom dplyr mutate
#'@importFrom furrr future_map
#'@export
batchtools.simulate.dynamic <- function(df.stats, structure = 'single.factor',
type = 'bootstrap',
n = NA, s.var = NA,
parallel = NA) {
if (!is.na(parallel)) {
# doFuture::registerDoFuture()
future::plan(parallel)}
switch(structure,
'single.factor' = {
df.stats %>%
dplyr::mutate(data = furrr::future_map(data,
~ ansimo::simulate.single.factor.data(.,
type = type,
s.var = s.var,
n = n)))},
'n.factor' = {
df.stats %>%
dplyr::mutate(data = furrr::future_map(data,
~ ansimo::simulate.n.factor.data(.,
type = type,
s.var = s.var,
n = n)))
})
}
test.sim.foreach <- function(df.stats, s.var = NULL, parallel = NULL) {
if (!is.null(parallel)) {
doFuture::registerDoFuture()
future::plan(parallel)}
algs <- c('bootstrap','gaussian','nbinom')
simulated <- foreach::foreach(i = algs, .combine = c) %dopar% {
tmp <- tmp %>%
dplyr::mutate(sim.data = furrr::future_map(data,
~ ansimo::simulate.data(.,
type = i,
s.var = s.var,
n = n)))
}
simulated <- simulated %>%
dplyr::bind_rows() %>%
dplyr::select(-data)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.