slim_block sets up and Eidos event code block. See details for how to specify the arguments correctly.

slim_block(...)

Arguments

...

A list of arguments corresponding to elements in SLiM code blocks. See details for more information on how to specify these arguments.

Value

A slimr_block object. This is of little use outside a slim_script

function call.

Details

An Eidos event is a block of Eidos code that is executed every generation, within a generation range, to perform a desired task. The syntax of an Eidos event declaration in slimr mimics that of the Eidos (e.g. SLiM) language itself (see SLiM manual). It looks like this: slim_block([species_id = ][id,] [start_gen, [end_gen,]], [slim_callback,] { ... }) where [ ] specifies that the code is optional. The minimum required is a single argument containing Eidos code. This will be run in every generation with slim_callback early(), the default for Eidos events. You can also optionally specify an id for the SLiM code block, which will be the first argument. This is optionally followed by a starting generation (start_gen). If only a starting generation is specified, the event will run only in that generation. Next comes an optional end generation (end_gen), which, if specified, will tell SLiM to run the event every generation between start_gen and end_gen. The special value of .. can be used for end_gen instead, which is shorthand for the last generation (in other words, run the event every generation between start_gen and the last generation used else where in the script). After end_gen is an optional callback, which corresponds to an Eidos callback. The following are valid Eidos callbacks:

  • early()

  • late()

  • initialize()

  • fitness(mut_type_id, subpop_id)

  • mateChoice(subpop_id)

  • modifyChild(subpop_id)

  • recombination(subpop_id)

  • interaction(int_type_id, subpop_id)

  • reproduction(subpop_id, sex)

Multispecies models are supported (if using SLiM >= 4.0), by using a single named argument where the argument name is a species id (e.g. slim_block(species_id = early()) would create a block that would run early in every generation and apply only to species species_id). Note that any of the arguments can be named, but only one. It is usually easiest to name the first argument specified in slim_block(). This may seem a somewhat unusual way to specify a species id but it was the simplest way to support multispecies models without changing the syntax of slim_block() much and maintaining the conciseness of block declarations which is a hallmark of SLiM and slimr.

Examples

slim_script(slim_block("s1", 1, 10000, late(), {print("Hello World!")}))
#> Warning: The arguments do not include an initialize block (use an initialize()
#>             callback to create one) and so the resulting script will not be a valid SLiM
#>             script. You can add an initialize block later through concatenation (using c())
#> <slimr_script[1]>
#> block_1:s1 1:10000 late() {
#>     print("Hello World!");
#> }