This document discusses parallelization options for this package. Because the full analysis can involve many independent calculations (esp. at the step of identifying the pairwise interactions), taking advantage of the ability to run code in parallel can speed things up.
To facilitate different computer setups, we use the future
package, which enables the user to define the parallelization setup.
# future::plan(NULL)
tictoc::tic()
ccm_results <- compute_ccm(simplex_results,
lib_sizes = seq(10, 100, by = 10),
random_libs = TRUE, num_samples = 10,
replace = TRUE, RNGseed = 42,
silent = TRUE)
tictoc::toc()
#> 8.472 sec elapsed
future.callr
.future::plan(future.callr::callr)
tictoc::tic()
ccm_results_parallel <- compute_ccm(simplex_results,
lib_sizes = seq(10, 100, by = 10),
random_libs = TRUE, num_samples = 10,
replace = TRUE, RNGseed = 42,
silent = TRUE)
tictoc::toc()
#> 8.95 sec elapsed
my_plan <- drake_plan(ccm_results_drake = compute_ccm(simplex_results,
lib_sizes = seq(10, 100, by = 10),
random_libs = TRUE, num_samples = 10,
replace = TRUE, RNGseed = 42,
silent = TRUE)
)
future::plan(future.callr::callr)
tictoc::tic()
clean(destroy = TRUE, force = TRUE)
#> Warning: Argument `force` is deprecated in small drake utility functions.
make(my_plan)
#> target ccm_results_drake
tictoc::toc()
#> 9.154 sec elapsed