Learn R Programming

phyloTop (version 2.1.2)

getDepths: Find the depth of each node

Description

Determines the depth of each node, defined as the number of steps from the root. (So the root has depth zero, its children have depth one, etc.) The output is given as a list of two vectors: tipDepths gives the depths of the tips, and nodeDepths gives the depths of the internal nodes. This replaces the deprecated dists function. The code is based on that used in the function computeHeights in package treeCentrality.

Usage

getDepths(tree)

Value

A list of two vectors: tipDepths gives the depths of the tips, and nodeDepths gives the depths of the internal nodes.

Arguments

tree

a tree of class phylo or phylo4. The tree should be binary and rooted; if not it will be coerced into a binary rooted tree using multi2di, if possible.

Author

Michelle Kendall michelle.louise.kendall@gmail.com

See Also

nodeDepth, nodeDepthFrac

Examples

Run this code
## Find the node depths in a random tree:
tree <- rtree(20)
treeDepths <- getDepths(tree)
## Plot tree with node depths labelled:
tree$tip.label <- treeDepths$tipDepths
tree$node.label <- treeDepths$nodeDepths
plot(tree, show.node.label=TRUE)


Run the code above in your browser using DataLab