Skip to content
Dom Bennett edited this page Apr 12, 2018 · 5 revisions

Adding or removing tips in the tree, be it individually or as a set process, is termed manipulating the tree and is implemented using the manipulation methods. A basic example where you might need these sorts of methods is if you need to add a tip to an already existing phylogenetic tree. Say, you have a tree of all the gibbons but there is one gibbon species that isn't in the tree, Hylobates siki. Molecular work suggests it's most closely related species is Hylobates leucogenys from which it separated 0.46 MYA. Well, you can add it like so....

# get the mammal supertree
data(mammals)
# get just gibbons
gibbon_ids <- getNdsFrmTxnyms(mammals, 'Hylobates')
prnt_id <- getPrnt(mammals, ids=gibbon_ids[[1]])
# prnt_id is the parent of all gibbons
gibbons <- getSubtree(mammals, id=prnt_id)
# add new tip
id <- 'Hylobates_siki'
sister <- 'Hylobates_leucogenys'
end <- 0  # H. siki exists in the present
start <- 0.46  # H. siki appeared 0.46 MYA
tree_age <- getAge(gibbons)
gibbons <- addTip(gibbons, tid=id, sid=sister, end_age=end,
                  strt_age=start, tree_age=tree_age)
(gibbons[['Hylobates_siki']])

For a full list of current manipulation methods see the manip-methods page.

Next page: Calculating

Clone this wiki locally