simulate_dd_phylo: Simulate a phylogeny with a diversity-dependent birth-death...

View source: R/simulate_dd_phylo.R

simulate_dd_phyloR Documentation

Simulate a phylogeny with a diversity-dependent birth-death model

Description

Use a Gillespie algorithm to create a phylo object from the DD model specified by dd_model and params. The phylogeny is conditioned on the survival of at least one lineage to the end of the simulation.

Usage

simulate_dd_phylo(params, nb_gens, dd_model, stem_or_crown = "stem")

Arguments

params

a named vector containing the values of the parameters of the DD model. Names and length must match those expected by dd_model$params_check

nb_gens

integer, the number of generations the simulation should run for.

dd_model

a list with five named elements that together specify the diversity-dependent model:

  • name a two-letter code, the name of the model. First letter specifies the form of the speciation function, second letter the form of the extinction function: "l" for "linear", "x" for exponential, "c" for constant.

  • speciation_func, a function specifying the diversity-dependent speciation rate. Must take arguments params and N.

  • extinction_func, a function specifying the diversity-dependent extinction rate. Must take arguments params and N.

  • constraints a list of conditions that parameter values must satisfy. Each element is a function that takes arguments params and ..., and returns TRUE if the constraint is satisfied, FALSE if it isn't.

  • params_check a function that controls the format of params. Returns an error if the elements of params are named differently from what is expected or if the length differs from the expectation.

comrad contains several dd_model functions, see for example dd_model_lc().

stem_or_crown

character, either "stem" or "crown", should the simulation start from 1 species (stem lineage) or 2 species (crown lineages)?

Value

a phylo object containign the simulated phylogeny, including extinct lineages and the stem.

Author(s)

Theo Pannetier


TheoPannetier/comrad documentation built on April 8, 2023, 8:06 a.m.