skbio.tree.
TreeNode
(name=None, length=None, support=None, parent=None, children=None)[source]¶Representation of a node within a tree
A TreeNode instance stores links to its parent and optional children nodes. In addition, the TreeNode can represent a length (e.g., a branch length) between itself and its parent. Within this object, the use of “children” and “descendants” is frequent in the documentation. A child is a direct descendant of a node, while descendants are all nodes that are below a given node (e.g., grand-children, etc).
name (str or None) – A node can have a name. It is common for tips in particular to have names, for instance, in a phylogenetic tree where the tips correspond to species.
length (float, int, or None) – Length of the branch connecting this node to its parent. Can represent ellapsed time, amount of mutations, or other measures of evolutionary distance.
support (float, int, or None) – Support value of the branch connecting this node to its parent. Can be bootstrap value, posterior probability, or other metrics measuring the confidence or frequency of this branch.
parent (TreeNode or None) – Connect this node to a parent
children (list of TreeNode or None) – Connect this node to existing children
Attributes
|
Built-ins
Returns a copy of self using an iterative approach |
|
Returns a copy of self using an iterative approach |
|
Node delegates slicing to children. |
|
Return hash(self). |
|
Node iter iterates over the children. |
|
State: Experimental as of 0.4.0. |
|
Returns string version of self, with names and distances |
Methods
|
Return the sum of the distance between self and ancestor |
Returns all ancestors back to the root |
|
|
Appends a node to children, in-place, cleaning up refs |
|
Returns a string containing an ascii drawing of the tree |
Assign topologically stable unique ids to self |
|
Extract support values from internal node labels of a tree. |
|
|
Reorders the tree into a bifurcating tree. |
|
Cache attributes on internal nodes of the tree |
|
Calculates the Robinson and Foulds symmetric difference |
|
Returns fraction of overlapping subsets where self and other differ. |
|
Compares self to other using tip-to-tip distance matrices. |
|
Returns a copy of self using an iterative approach |
|
Get the count of nodes in the tree |
Construct an internal lookups to facilitate searching by name |
|
|
Returns a copy of self using an iterative approach |
|
Find total descending branch length from self or subset of self tips |
|
Return the distance between self and other |
|
Append a list of TreeNode to self. |
|
Find a node by name. |
|
Find all nodes that match name |
|
Find all nodes given a function |
|
Find a node by id. |
|
Return tree from SciPy linkage matrix. |
|
Construct a tree from a taxonomy |
Returns the max tip tip distance between any pair of tips |
|
Returns True if the node has children. |
|
Index a tree for rapid lookups within a tree array |
|
|
Delete lookup and attribute caches |
|
Returns True if the current is a root, i.e. |
|
Returns True if the current node has no children. |
|
Lowest common ancestor for a list of tips |
|
Performs levelorder iteration over tree |
|
Lowest common ancestor for a list of tips |
|
Returns all nodes that are connected to self |
|
Iterates over nontips descended from self |
|
Returns counts of node observations from counts of tip observations |
|
Remove a TreeNode from self. |
|
Performs postorder iteration over tree. |
|
Performs iteration over tree, visiting node before and after |
|
Performs preorder iteration over tree |
|
Reconstructs correct topology after nodes have been removed. |
|
Create a new |
|
Remove a node from self |
|
Delete nodes in which func(node) evaluates True. |
|
Returns root of the tree self is in |
|
Return a new tree rooted at the provided node. |
Return a new tree rooted at midpoint of the two tips farthest apart |
|
|
Lop off tips until the tree just has the desired tip names. |
|
Yield trees with shuffled tip names |
|
Returns all nodes that are children of self parent. |
|
Returns set of names that descend from specified node |
|
Return all sets of names that come from self and its descendants |
|
Make a copy of the subtree |
|
Returns distance matrix between pairs of tips, and a tip order. |
|
Iterates over tips descended from self. |
|
Return an array representation of self |
|
Returns a taxonomy representation of self |
|
Returns iterator over descendants |
|
Unpack an internal node in place. |
|
Unpack internal nodes of a tree that meet certain criteria. |
|
Walks the tree unrooted-style and returns a copy |
|
Walks the tree unrooted-style and returns a new copy |
|
Write an instance of |