Learn R Programming

TreeSearch (version 0.2.2)

NNI: NNI

Description

Nearest Neighbour Interchange

Usage

NNI(tree, edgeToBreak = NULL)

NNISwap(parent, child, nTips = (length(parent)/2L) + 1L, edgeToBreak = NULL)

RootedNNI(tree, edgeToBreak = NULL)

RootedNNISwap(parent, child, nTips = (length(parent)/2L) + 1L, edgeToBreak = NULL)

Arguments

tree

A tree of class phylo.

edgeToBreak

(optional) integer specifying the index of an edge to bisect/prune, generated randomly if not specified. Alternatively, set to -1 to return a complete list of all trees one step from the input tree.

parent

the first column of the edge matrix of a tree of class phylo, i.e. tree$edge[, 1]

child

the second column of the edge matrix of a tree of class phylo, i.e. tree$edge[, 2]

nTips

(optional) Number of tips.

Value

Returns a tree with class phylo (if returnAll = FALSE) or a set of trees, with class multiPhylo (if returnAll = TRUE).

a list containing two elements, corresponding in turn to the rearranged parent and child parameters

a list containing two elements, corresponding in turn to the rearranged parent and child parameters

Functions

  • NNISwap: faster version that takes and returns parent and child parameters

  • RootedNNI: Perform NNI rearrangement, retaining position of root

  • RootedNNISwap: faster version that takes and returns parent and child parameters

Details

Performs a single iteration of the nearest-neighbour interchange algorithm. Based on the corresponding phangorn function, but re-coded to improve speed.

Branch lengths are not supported.

References

The algorithm is summarized in Felsenstein2004TreeSearch

Examples

Run this code
# NOT RUN {
tree <- ape::rtree(20, br=NULL)
NNI(tree)
NNI(tree, edgeToBreak = -1)

# }

Run the code above in your browser using DataLab