modifiers | R Documentation |
Different modifiers for the birth death process implemented in treats.
modifiers(bd.params = NULL, lineage = NULL, trait.values = NULL,
modify.fun = NULL)
bd.params |
A named list of birth death parameters (see details). |
lineage |
A named list containing the lineage data (see details). |
trait.values |
A matrix containing the trait values (see details). |
modify.fun |
A list of internals functions that can modified by |
bd.params
can be either a named list of parameter values (e.g. list("extinction" = 0, "speciation" = 1)
) but it is typically handled internally from a "treats"
"bd.params"
object.
modifiers
are functions passed to the birth death process in treats
to either generate the branch length (named branch.length
and similar) or to decide whether to speciate or go extinct (named speciation
and similar).
For user defined functions, the modifiers
must have at least the arguments described above. For safety, we suggest setting these arguments to NULL
.
The pre-build modifiers
in the treats
package are (so far):
branch.length
the simple branch length generator that randomly gets a numeric value drawn from the exponential distribution (rexp
) with a rate equal to the number of taxa (lineage$n * bd.params$speciation + bd.params$extinction
).
branch.length.trait
a modification of the branch.length
modifier
where the resulting branch length is changed by modify.fun$modify
if the parent trait(s) meet the condition modify.fun$condition
.
selection
a function returning a randomly sampled integer among the number of taxa available.
speciation
a function returning TRUE
(speciation) if a random uniform number (runif
) is smaller than the ratio of speciation by speciation and extinction (bd.params$speciation / (bd.params$speciation) + bd.params$extinction
). If it's bigger, the function returns FALSE
(exinction).
speciation.trait
a modification of the speciation
modifier
where the random uniform number is changed by modify.fun$modify
if the parent trait(s) meet the condition modify.fun$condition
.
More details about the modifiers
functions is explained in the treats
manual: http://tguillerme.github.io/treats.
These functions returns either "numeric"
or "logical"
values to be passed to make.modifiers
and treats
.
Thomas Guillerme
treats
make.modifiers
## These functions should be fed to the make.modifiers function to create
## modifiers for treats objects. For example, the following sets specifies that
## the branch length should be generated using the branch.length.trait function
## the selection using the selection function and the speciation using the
## speciation.trait function:
my_modifiers <- make.modifiers(branch.length = branch.length.trait,
selection = selection,
speciation = speciation.trait)
## Creating a treats simulation using these modifiers
treats(stop.rule = list(max.taxa = 20),
traits = make.traits(),
modifiers = my_modifiers)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.