TGuillerme / treats

Simulating trees and traits in R

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing branch length when reaching n taxa

TGuillerme opened this issue · comments

Changing branch length when reaching n taxa

A simulation scenario making a pure birth tree (no extinction) to generate 100 taxa but where branch length growth increases 10 folds after 30 taxa.

What does it do?

What function does it uses? yes/no comments
Uses make.bd.params default
Uses make.traits
Uses make.modifications default
Uses make.events

modifier

The default modifier to be changed several times.

default_modifier <- make.modifiers()

events

Increasing branch length 10 folds after 30 taxa

## Multiplying branch length 10 folds
increase.10.folds <- function(x, trait.values, lineage) {
  return(x * 10)
}
## Event for increasing branch length after reaching 30 taxa
increase_brlen <- make.events(
                  condition = taxa.condition(30),
                  target = "modifiers",
                  modification = modifiers.update(
                                    branch.length = branch.length,
                                    modify  = increase.10.folds))

A running example

## My favorite seed
set.seed(42)

## Some stopping rules
my_stop.rule <- list(max.taxa = 100)

## The simulation
my_simulation <- treats(stop.rule = my_stop.rule,
                        modifiers = default_modifier,
                        events    = increase_brlen)

plot(my_simulation, show.tip.label = FALSE)

Reference

If you use this template in a publication, please cite:

  • treats
  • R