Learn R Programming

pirouette (version 1.6.9)

combine_brts_and_topology: Substitute branching times keeping the topology

Description

Set the branching times (in time units before the present) of a phylogeny, while preserving its topology.

Usage

combine_brts_and_topology(brts, tree)

Value

a phylogeny of class phylo

Arguments

brts

numeric vector of (all postive) branching times, in time units before the present. Assuming no stem, the heighest value equals the crown age.

tree

an ultrametric phylogenetic tree of class phylo

Author

Giovanni Laudanno, David Bapst, Richèl J.C. Bilderbeek

Examples

Run this code
# Branching times as 3 (crown age) and 2 (branch of A and B) time units ago
phylogeny <- ape::read.tree(text = "((A:2, B:2):1, C:3);")
# Branching times will be c(3, 2)
as.numeric(ape::branching.times(phylogeny))
# Will be 2
ape::dist.nodes(phylogeny)[1, ape::getMRCA(phylogeny, c("A", "B"))]

# Create a new phylogeny with the same topology, but with
# branching times at 5 (crown age) and 4 (branch of A and B) time units ago
new_phylogeny <- combine_brts_and_topology(
  brts = c(5, 4),
  tree = phylogeny
)
# Will be c(5, 4)
as.numeric(ape::branching.times(new_phylogeny))
# Will be 4
ape::dist.nodes(new_phylogeny)[
    1, ape::getMRCA(new_phylogeny, c("A", "B"))
]

Run the code above in your browser using DataLab