Skip to contents

Create a DatedTree class object; it includes heights for each node and other helper variables

Usage

DatedTree(
  phylo,
  sampleTimes,
  sampleStates = NULL,
  sampleStatesAnnotations = NULL,
  tol = 1e-06,
  minEdgeLength = 0
)

Arguments

phylo

A phylogenetic tree of class ape::phylo. Note that this tree should be a timetree.

sampleTimes

A numeric vector providing the times of samples. If named, taxon labels will be based on names of the corresponding sample times

sampleStates

For models with more than one deme, a matrix must be supplied describing the probability of sampling from each deme. Each row corresponds to a sample in the same order as sampleTimes. Each column corresponds to probability of sampling each deme. Column names should be defined which correspond to deme names in the model. Rows should sum to one.

sampleStatesAnnotations

Vector of possible discrete character states for taxa. If inferring taxon state from label, this provides the possible matches for taxon annotations.

tol

Numeric to set the amount of error allowed in the edge length of the phylogenetic tree.

minEdgeLength

Numeric and it is the minimum length in the returned phylogenetic tree.

Value

A dated phylogenetic tree with additional metadata to use with phydynR functions.

Details

tol and minEdgeLength are necessary because it will adjust the edge length of the tree to ensure they are greater than 0 and taking into consideration the sample times.

Author

Erik Volz

Examples

# read the tree
#usually this is a tree that the branch lengths are in unit of calendar time
tree <- read.tree(system.file('extdata/hivSimulation.nwk', package='phydynR'))

# the sample times are the same, because it is a homochronous sample at 50 years
sampleTimes <- rep(50, length(tree$tip.label))
names(sampleTimes) <- tree$tip.label

# create a tree with dated tips and internal nodes,
# will infer the sample states from tip labels
bdt <- DatedTree(phylo = tree, 
                sampleTimes = sampleTimes,
                minEdgeLength = 0.01)
bdt
#> 
#> Phylogenetic tree with 318 tips and 317 internal nodes.
#> 
#> Tip labels:
#>   89_I1, 349_I2, 339_I1, 64_I1, 203_I1, 30_I0, ...
#> 
#> Rooted; includes branch lengths.
class(bdt)
#> [1] "DatedTree" "phylo"