Learn R Programming

phyloTop (version 1.1.1)

allNodeAnalysis: All Node Analysis

Description

A collection of functions designed to examine all of the nodes in a tree at once. Note that not all of these functions return tolological properties of the trees - two trees could be topologically identical but give different results. Many of the functions below gives results organized by nodeId.

Usage

nDescendants(tree)
nTipDescendants(tree)
dists(tree)
ladderNums(tree)
treeImb(tree)
nodeApply(tree,func,showId = TRUE)

Arguments

tree
An object of class phylo4
func
A function with input being a binary phylogenetic tree and output being a number
showId
A Boolean

Value

  • nDescendantsAn integer vector of length equal to the number of nodes in the tree.
  • nTipDescendantsAn numeric vector of length equal to the number of nodes in the tree. All entries are integers.
  • ladderNumsA numeric vector of length equal to the number of internal nodes of the tree. All entries are integers.
  • treeImbA matrix with two rows and number of columns equal to the number of internal nodes of the tree.
  • nodeApplyA numeric vector of length equal to the number of internal nodes. If showId=TRUE, then the vector is named.

Details

nDescendants gives the number of descendants (including internal nodes) of all the nodes in the tree. It is organized by nodeId. Note that when phylobase's descendants is given a tip it returns that tip as an output. nTipDescendants gives the number of tip descendants of all the nodes in the tree. It is organized by nodeId. dists gives the distance of each node from the root of the tree. It is organized by nodeId. Note that, in phylobase, Depth is how far the node is from the root taking edge length into account. I have stuck with this convention so Dist is the number of steps required to go to that node from the root. ladderNums gives the largest ladder size (away from the root) starting from the given node. It is based on rootLaddDist. Note that it returns a vector of length equal to the number of internal nodes of the tree. Organized by nodeId. laddItr is intended to be applied to this result of this function. treeImb gives the node imbalance of every internal node in the tree using nodeImb. The output ordered by nodeId. nodeApply applies the a given function to all the non-trivial subtrees within the given tree. That is, for every internal node there is a tree - the tree descending from that node. nodeApply applies func to all of these trees. The output is ordered by nodeId and if showId=TRUE then the name of the output is set to show the nodeId of the node corresponding to each subtree.

See Also

nodeId, rootLaddDist. See treeAnalysis for more examples to use in func.

Examples

Run this code
## Creates a random tree of class phylo4
tree <- rtree4(50)

## Label the nodes of a tree by their nodeId
labelledTree <- idNodeLabel(tree)
plot(labelledTree,show.tip.label=FALSE,show.node.label=TRUE)

## Finds the number of descendants of the nodes
nDescendants(tree)

## Finds the number of tip descendants of the nodes in the tree
nTipDescendants(tree)

## Finds the distance of each node from the root of the tree
dists(tree)

## Finds the length of the internal ladders in the tree
ladderNums(tree)

## Calculates the imbalance of each of the internal nodes
treeImb(tree)

## This returns the Colless imbalance of all subtrees of the tree
## The vector is named by the nodeId of the root of each subtree
nodeApply(tree,colless)

Run the code above in your browser using DataLab