R/simulate_grid.R
simulate_grid.Rd
For a given data frame (each column a parameter of a slendr model function) simulates values of given population genetic statistics
simulate_grid(
model,
grid,
functions,
replicates,
sequence_length,
recombination_rate,
mutation_rate = 0,
data = NULL,
format = c("ts", "files"),
packages = NULL,
file = NULL,
engine = NULL,
model_args = NULL,
engine_args = NULL,
strict = TRUE
)
A slendr model generating function
A data frame object containing parameter grid such as one produced by
tidyr::expand_grid
or base::expand.grid
A named list of summary statistic functions to apply on simulated tree sequences
How many simulation replicates to run for each parameter combination?
Amount of sequence to simulate using slendr (in base pairs). Ignored when custom simulations scripts are provided.
Recombination rate to use for the simulation
Mutation rate to use for the simulation
A character vector with package names used by user-defined summary statistic
functions. Only relevant when parallelization is set up using future::plan()
to make
sure that the parallelized tree-sequence summary statistic functions have all of their
packages available.
If not NULL
, a path where to save the data frame with simulated grid results.
If this path is set, the results data frame is returned but invisibly.
Which simulation engine to use? Values "msprime" and "slim" will use one of
the built-in slendr simulation back ends. Which engine will be used is determined
by the nature of the model
. If engine = NULL
, then spatial slendr models will
by default use the "slim" back end, non-spatial models will use the "msprime" back end, and
custom user-defined model scripts will use the "custom" engine. Setting this argument
explicitly will change the back ends (where appropriate). Setting this argument for custom
simulation script has no effect.
Optional (non-prior) arguments for the slendr model generating function. Setting this argument for custom simulation script has no effect.
Optional arguments for the slendr simulation back end. Setting this argument for custom simulation script has no effect.
Should parameter combinations leading to invalid slendr models be treated as
an error? Default is TRUE
. If set to FALSE
, invalid simulations will be simply
dropped, with an informative message.
If file != NULL
, returns a data frame with simulated grid results. Otherwise
does not return anything, saving an object to an .rds file instead.
A data frame object with the results of parameter grid simulations, with values of each summary statistic stored in a list-column