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,
  packages = NULL,
  file = NULL,
  engine = NULL,
  model_args = NULL,
  engine_args = NULL,
  strict = TRUE
)

Arguments

model

A slendr model generating function

grid

A data frame object containing parameter grid such as one produced by tidyr::expand_grid or base::expand.grid

functions

A named list of summary statistic functions to apply on simulated tree sequences

replicates

How many simulation replicates to run for each parameter combination?

sequence_length

Amount of sequence to simulate using slendr (in numbers of basepairs)

recombination_rate

Recombination rate to use for the simulation

mutation_rate

Mutation rate to use for the simulation

packages

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.

file

If not NULL, a path where to save the data frame with simulated grid results

engine

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.

model_args

Optional (non-prior) arguments for the slendr model generating function. Setting this argument for custom simulation script has no effect.

engine_args

Optional arguments for the slendr simulation back end. Setting this argument for custom simulation script has no effect.

strict

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.

Value

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