library(ape)
data("hivtree.newick") # example tree in NH format
cat(hivtree.newick, file = "hivtree.phy", sep = "") # generate file "hivtree.phy"
tree.hiv <- read.tree("hivtree.phy") # load tree
unlink("hivtree.phy") # delete the file "hivtree.phy"
ci <- coalescent.intervals(tree.hiv) # from tree
ci
data("hivtree.table") # same tree, but in table format
ci <- coalescent.intervals(hivtree.table$size) # from vector of interval lengths
ci
Run the code above in your browser using DataCamp Workspace