Learn R Programming

phyloTop (version 1.1.1)

utility: Utility Functions

Description

A collection of short, useful functions to save time and allow more intuitive use of the package.

Usage

rtree4(n)
idNodeLabel(tree)
nTipChildren(tree,node)
phyloCheck(object,error = TRUE)

Arguments

n
An integer
tree
An object of class phylo4
node
An integer specifying a node in a tree by it's nodeId
object
Any R object
error
a Boolean

Value

  • rtree4An object of class phylo4 with n tips.
  • idNodeLabelAn object of class phylo4 with nodes labelled by nodeId.
  • nTipChildrenAn integer specifying the exact number of children of that node - note children not descendants.
  • phyloCheckA Boolean specifying if the object is a tree suitable for use in this package.

Details

rtree4 uses ape function rtree and the as function of phylobase to produce a random tree of class phylo4 with a given number of tips. The algorithm used randomly splits one of the edges at each step. idNodeLabel labels the nodes of the tree by nodeId. Note that this includes the tips. nTipChildren gives the number of children of a node which are tips. phyloCheck tests if a object is of the correct form for use in this package. It returns TRUE if the object is a binary tree of class phylo4 and FALSE (with an error message) if either of these conditions are not met. If error=FALSE then no error messages will be printed.

See Also

rtree and nodeId

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)

## Find the number of tip children of a node
nTipChildren(tree,70)

## Checks that the tree is of the correct type
phyloCheck(tree)

Run the code above in your browser using DataLab