API
    Preparing search index...

    Class Tree

    Index

    Constructors

    Properties

    labelNodeMap: undefined | { [key: string]: Node }

    A public property

    nodeIDMap: undefined | { [key: number]: Node }

    A public property

    recombEdgeMap: undefined | { [key: string]: Node[] }

    A public property

    root: Node

    Public property used to construct tree

    ultrametric: undefined | boolean

    A public property

    Accessors

    • get leafList(): Node[]

      A getter that returns an array of nodes (Node[]) from private _nodeList property in order determined by a pre-order search

      Returns Node[]

    • get nodeList(): Node[]

      A getter that returns an array of nodes (Node[]) from private _nodeList property in order determined by a pre-order search

      Returns Node[]

    Methods

    • Convenience function applied function post-order to all nodes in the tree. Is a wrapper for Node.applyPostOrder()

      Parameters

      • func: (node: Node) => void

        Function to apply to each node

      Returns void

    • Convenience function applied function pre-order to all nodes in the tree. Is a wrapper for Node.applyPreOrder()

      Parameters

      • func: (node: Node) => void

        Function to apply to each node

      Returns void

    • Clear various node caches

      Returns void

    • Returns the Colless Imbalance (CI) index, with an option to normalise or use the standard method. The CI is defined for binary trees, so NaN is returned if the tree is not binary. In essence, the CI adds the difference between the number of tips descending from each internal node. The square of each difference is taking if the method selected is quadratic. If the method is set to "corrected", then the overall sum is scaled by the number of tips. If method is "standard", then sum is returned. The value should be smaller for more balanced trees (less ladder-like). As for the Sacking Index, see "Tree balance indices: a comprehensive survey (https://doi.org/10.1007/978-3-031-39800-1_12, https://doi.org/10.1007/978-3-031-39800-1_13, https://doi.org/10.1007/978-3-031-39800-1_15) for further details.

      Parameters

      • method: "standard" | "corrected" | "quadratic" = 'standard'

      Returns number

    • Computes height of each node above the root. Automatically done if rerooting. NaN if any undefined branch lengths ancestral to a particular node. Contrasts Tree.getRTTD() in not converting undefined branch lengths to 0.0.

      Returns void

    • Calculates Gamma statistic from Pybus and Harvey 2000 (10.1098/rspb.2000.1278 ). The Gamma statistic measures deviation from a constant rate pure-birth process in the underlying population (also known as a Yule process). Values above 0 indicate longer external branches, while values corresond to internal branches. Calculating the Gamma statistic involves manipulations that mean the statistic should follow a standard normal distribution, such that one can perform a frequentist test to measure consistency with the pure birth process.

      Since the Gamma statistic applies to a pure birth process, the tree is expected to be ultrametric and the method throws an error if it is not. It also returns NaN if any node node heights are undefined, due to undefined branch lengths.

      Parameters

      • tol: number = 1e-6

        Tolerance for ultrametricity passed to .isUltrametric()

      Returns number

    • Return branch lengths in order matching .nodeList

      Returns (undefined | number)[]

    • Return sub-stree descending from a given node

      Parameters

      Returns Tree

      root node root of desired subtree

    • Returns height above the root for each internal node. Root height is assumed to be 0 and undefined branch lengths are assumed to be zero.

      Returns number[]

    • Get the most recent common ancestor of a set of nodes

      Parameters

      • nodes: Node[]

        Nodes for which the MRCA is sought

      Returns null | Node

    • Get node given its numerical id

      Parameters

      • nodeID: number

        Numerical id of node

      Returns null | Node

    • Retrieve node having given label

      Parameters

      • label: string

        Node's label

      Returns null | Node

    • Retrieve map from recomb edge IDs to src/dest node pairs

      Returns { [key: string]: Node[] }

    • Returns root to tip distances. Counts undefined branch lengths as zero

      Returns number[]

    • Get all tip names from tree or descending from a node

      Parameters

      • Optionalnode: Node

        Optional node whose descending tips are returned. Defaults to root

      Returns string[]

    • Sum of all defined branch lengths. Elsewhere referred to tree "length" if all baranch lengths are defined

      Returns number

    • Check whether the tree is binary (each internal node has <= 2 descendents)

      Returns boolean

    • Check if the tree is a phylogenetic network.

      Returns boolean

    • Check if node is a destination node for a hybrid edge in the tree.

      Parameters

      Returns boolean

    • Check if node is a source node for a hybrid edge in the tree.

      Parameters

      Returns boolean

    • Reflects whether all tips are the same age (0), equivalently if they are all the same height about the root. Only makes sense for time trees. Sets property on tree object and returns boolean. The tolerance for differences in tip heights is 1e-6 as a default, but can be adjusted.

      Parameters

      • tol: number = 1e-6

      Returns boolean

    • Ladderises the tree. Applies a pre-order search. For each node, child nodes are ordered by increasing number of descending tips

      Returns void

    • Assign new node IDs (use with care!)

      Returns void

    • Reroot a tree at a given node.

      Parameters

      • edgeBaseNode: Node

        Node to reroot at

      • prop: number = 0.5

        Proportion of the branch descending from edgeBaseNode at which to cut and place the root. Defaults ot 0.5

      Returns void

    • Returns the Sackin Index, which measures imbalance as the sum of the number of tips descending from each internal node. The sum increases for more imbalances (ladder-like) trees. See Chapter 5 in "Tree balance indices: a comprehensive survey" (https://doi.org/10.1007/978-3-031-39800-1_5) for further details, a reference we point to from the treebalance R package

      Returns number