skbio.tree.TreeNode.height#
- TreeNode.height(include_self=False, use_length=True, missing_as_zero=False)[source]#
Calculate the height of the current node.
Added in version 0.6.3.
The height of a node is the maximum sum of branch lengths from it to any of its descending tips.
- Parameters:
- include_selfbool, optional
If True, the height will include the length of the current node. Default is False.
- use_lengthbool, optional
Whether to return the sum of branch lengths (True, default) or the number of branches (False) from self to the most distant tip.
- missing_as_zerobool, optional
When a node without an associated branch length is encountered, raise an error (False, default) or use 0 (True). Applicable when
use_length
is True.
- Returns:
- float
The height of self.
- TreeNode
The most distant descending tip from self.
- Raises:
- NoLengthError
If nodes without branch length are encountered, but
missing_as_zero
is False.
Notes
When a tie is observed among multiple tips, only one of them will be returned. The choice is stable. This often happens when
use_length=False
.Examples
>>> from skbio import TreeNode >>> tree = TreeNode.read(["((a:1,b:2)c:3,(d:4,e:5)f:6)root;"]) >>> dist, tip = tree.find('c').height() >>> dist 2.0 >>> tip.name 'b'