Skip to content
Dom Bennett edited this page Jun 4, 2017 · 6 revisions

treeman has a set of methods called get methods that are designed to efficiently extract elements of a phylogenetic tree. All the methods have get as a prefix, they always take a tree as their first argument and require id or ids as additional arguments.

library(treeman)
tree <- randTree(10)
# return the shared unique parent ID of a list of ids
prnt <- getPrnt(tree, ids=c("t1", "t2"))

The majority of get methods return data per node or nodes, and use a getNd* or getNds* naming convention.

# note the loss of the s
n2_chldrn <- getNdKids(tree, id="n2")  # returns a vector
nd_chldrn <- getNdsKids(tree, id=tree["nodes"])  # returns a list of vectors

It is recommended you use the get methods for extracting tree large amounts of information iteratively rather than [] or [[]], as the get methods have been designed to be fast, whereas the indexing methods have been designed to be user-friendly. For a full list of current get methods see the get-methods-page.

Next page: Setting

Clone this wiki locally