This function will execute a SLiM script generated by the compile function during the compilation of a slendr demographic model.

slim(
  model,
  sequence_length,
  recombination_rate,
  output = file.path(model$path, "output"),
  spatial = !is.null(model$world),
  sampling = NULL,
  max_attempts = 1,
  save_locations = FALSE,
  coalescent_only = TRUE,
  method = c("batch", "gui"),
  verbose = FALSE,
  burnin = 0,
  random_seed = NULL,
  slim_path = NULL,
  save_sampling = TRUE
)

Arguments

model

Model object created by the compile function

sequence_length

Total length of the simulated sequence (in base-pairs)

recombination_rate

Recombination rate of the simulated sequence (in recombinations per basepair per generation)

output

A shared prefix path of output files that will be generated by the model (by default, all files will share a prefix "output" and will be placed in the model directory)

spatial

Should the model be executed in spatial mode? By default, if a world map was specified during model definition, simulation will proceed in a spatial mode.

sampling

A data frame of times at which a given number of individuals should be remembered in the tree-sequence (see sampling for a function that can generate the sampling schedule in the correct format). If missing, only individuals present at the end of the simulation will be recorded in the tree-sequence output file.

max_attempts

How many attempts should be made to place an offspring near one of its parents? Serves to prevent infinite loops on the SLiM backend. Default value is 100.

save_locations

Save location of each individual throughout the simulation?

coalescent_only

Should initializeTreeSeq(retainCoalescentOnly = <...>) be set to TRUE (the default) or FALSE? See "retainCoalescentOnly" in the SLiM manual for more detail.

method

How to run the script? ("gui" - open in SLiMgui, "batch" - run on the command-line)

verbose

Write the SLiM output log to the console (default FALSE)?

burnin

Length of the burnin (in model's time units, i.e. years)

random_seed

Random seed (if missing, SLiM's own seed will be used)

slim_path

Optional way to specify path to an appropriate SLiM binary

save_sampling

Save the sampling schedule table together with other output files? If FALSE (default), the sampling table will be saved to a temporary directory.

Examples

if (FALSE)  # run a simulation using the SLiM back end from a compiled slendr model object
slim(model, sequence_length = 100e6, recombination_rate = 1e-8, method = "batch", verbose = TRUE)