TreeNode 1.5.2
A library to manipulate phylogenetic trees
Loading...
Searching...
No Matches
PhyloTree.TreeNode Class Reference

Represents a node in a tree (or a whole tree). More...

Public Types

enum  TreeComparisonPruningMode
 Defines ways of pruning trees during comparisons. More...
 
enum  NodeRelationship
 Describes the relationship between two nodes. More...
 
enum  NullHypothesis
 Null hypothesis for normalising tree shape indices. More...
 

Public Member Functions

double RobinsonFouldsDistance (TreeNode otherTree, bool weighted)
 Computes the Robinson-Foulds distance between the current tree and another tree. More...
 
double EdgeLengthDistance (TreeNode otherTree)
 Computes the edge-length distance between the current tree and another tree. More...
 
 TreeNode (TreeNode parent)
 Creates a new TreeNode object. More...
 
bool IsRooted ()
 Checks whether the node belongs to a rooted tree. More...
 
TreeNode GetUnrootedTree ()
 Get an unrooted version of the tree. More...
 
TreeNode GetRootedTree (TreeNode outgroup, double position=0.5)
 Get a version of the tree that is rooted at the specified point of the branch leading to the outgroup . More...
 
TreeNode Clone ()
 Recursively clone a TreeNode object. More...
 
List< TreeNodeGetChildrenRecursive ()
 Recursively get all the nodes that descend from this node. More...
 
IEnumerable< TreeNodeGetChildrenRecursiveLazy ()
 Lazily recursively get all the nodes that descend from this node. More...
 
List< TreeNodeGetLeaves ()
 Get all the leaves that descend (directly or indirectly) from this node. More...
 
List< string > GetLeafNames ()
 Get the names of all the leaves that descend (directly or indirectly) from this node. More...
 
List< string > GetNodeNames ()
 Get the names of all the named nodes that descend (directly or indirectly) from this node. More...
 
TreeNode GetNodeFromName (string nodeName)
 Get the child node with the specified name. More...
 
TreeNode GetNodeFromId (string nodeId)
 Get the child node with the specified Id. More...
 
double UpstreamLength ()
 Get the sum of the branch lengths from this node up to the root. More...
 
double LongestDownstreamLength ()
 Get the sum of the branch lengths from this node down to the leaves of the tree. If the tree is not clock-like, the length of the longest path is returned. More...
 
double ShortestDownstreamLength ()
 Get the sum of the branch lengths from this node down to the leaves of the tree. If the tree is not clock-like, the length of the shortest path is returned. More...
 
TreeNode GetRootNode ()
 Get the node of the tree from which all other nodes descend. More...
 
double PathLengthTo (TreeNode otherNode, NodeRelationship nodeRelationship=NodeRelationship.Unknown)
 Get the sum of the branch lengths from this node to the specified node. More...
 
double TotalLength ()
 Get the sum of the branch lengths of this node and all its descendants. More...
 
void SortNodes (bool descending)
 Sort (in place) the nodes in the tree in an aesthetically pleasing way. More...
 
override string ToString ()
 Convert the tree to a Newick string. More...
 
bool IsClockLike (double tolerance=0.001)
 Determines whether the tree is clock-like (i.e. all tips are contemporaneous) or not. More...
 
TreeNode GetLastCommonAncestor (params string[] monophyleticConstraint)
 Gets the last common ancestor of all the nodes with the specified names, or null if the tree doesn't contain all the named nodes. More...
 
TreeNode GetLastCommonAncestor (IEnumerable< string > monophyleticConstraint)
 Gets the last common ancestor of all the nodes with the specified names, or null if the tree doesn't contain all the named nodes. More...
 
bool IsLastCommonAncestor (IEnumerable< string > monophyleticConstraint)
 Checks whether this node is the last common ancestor of all the nodes with the specified names. More...
 
List< TreeNode > List< TreeNode > side2 GetSplit ()
 
IEnumerable<(List< TreeNode > side1, List< TreeNode > side2, double branchLength)> GetSplits ()
 Gets all the splits in the tree. More...
 
TreeNode Prune (bool leaveParent)
 Prunes the current node from the tree. More...
 
TreeNode Prune (TreeNode nodeToPrune, bool leaveParent)
 Prunes a node from the tree. More...
 
double[][] CreateDistanceMatrixDouble (int maxDegreeOfParallelism=0, Action< double > progressCallback=null)
 Creates a lower triangular distance matrix, where each entry is the path length distance between two leaves in the tree. Entries are in the same order as returned by the GetLeaves method. More...
 
float[][] CreateDistanceMatrixFloat (int maxDegreeOfParallelism=0, Action< double > progressCallback=null)
 Creates a lower triangular distance matrix, where each entry is the path length distance between two leaves in the tree. Entries are in the same order as returned by the GetLeaves method. More...
 
int GetDepth ()
 Compute the depth of the node (number of branches from this node until the root node). More...
 
double SackinIndex (NullHypothesis model=NullHypothesis.None)
 Computes the Sackin index of the tree (sum of the leaf depths). More...
 
double CollessIndex (NullHypothesis model=NullHypothesis.None, double yhkExpectation=double.NaN)
 Compute the Colless index of the tree. More...
 
double NumberOfCherries (NullHypothesis model=NullHypothesis.None)
 Computes the number of cherries in the tree. More...
 

Static Public Member Functions

static double RobinsonFouldsDistance (TreeNode tree1, TreeNode tree2, bool weighted)
 Computes the Robinson-Foulds distance between two trees. More...
 
static double EdgeLengthDistance (TreeNode tree1, TreeNode tree2)
 Computes the edge-length distance between two trees. More...
 
static double[,] RobinsonFouldsDistances (IReadOnlyList< TreeNode > trees, bool weighted, TreeComparisonPruningMode pruningMode=TreeComparisonPruningMode.Pairwise, int maxThreadCount=-1, IProgress< double > progress=null)
 Computes a distance matrix containing the Robinson-Foulds distances between each pair of trees in a list. More...
 
static double[,] EdgeLengthDistances (IReadOnlyList< TreeNode > trees, TreeComparisonPruningMode pruningMode=TreeComparisonPruningMode.Pairwise, int maxThreadCount=-1, IProgress< double > progress=null)
 Computes a distance matrix containing the edge-length distances between each pair of trees in a list. More...
 
static void RobinsonFouldsDistances (IReadOnlyList< TreeNode > trees, out double[,] RFDistances, out double[,] weightedRFDistances, TreeComparisonPruningMode pruningMode=TreeComparisonPruningMode.Pairwise, int maxThreadCount=-1, IProgress< double > progress=null)
 Computes two distance matrices containing the unweighted and weighted Robinson-Foulds distances between each pair of trees in a list. Much faster than computing the two distance matrices separately. More...
 
static void TreeDistances (IReadOnlyList< TreeNode > trees, out double[,] RFDistances, out double[,] weightedRFDistances, out double[,] ELDistances, TreeComparisonPruningMode pruningMode=TreeComparisonPruningMode.Pairwise, int maxThreadCount=-1, IProgress< double > progress=null)
 Computes three distance matrices containing the unweighted and weighted Robinson-Foulds distances and the edge-length distances between each pair of trees in a list. Much faster than computing the three distance matrices separately. More...
 
static TreeNode GetLastCommonAncestor (IEnumerable< TreeNode > monophyleticConstraint)
 Gets the last common ancestor of all the specified nodes, or null if the tree doesn't contain all the nodes. More...
 
static double GetCollessExpectationYHK (int numberOfLeaves)
 Computes the expected value of the Colless index under the YHK model. More...
 

Public Attributes

List< TreeNodeside1
 Gets the split corresponding to the branch underlying this node. If this is an internal node, side1 will contain all the leaves in the tree except those descending from this node, and side2 will contain all the leaves descending from this node. If this is the root side1 will be empty and side2 will contain all the leaves in the tree. If the tree is rooted (the root node has exactly 2 children), side1 will contain in all cases an additional null element. More...
 

Properties

TreeNode Parent [get, set]
 The parent node of this node. This will be null for the root node. More...
 
List< TreeNodeChildren [get]
 The child nodes of this node. This will be empty (but initialised) for leaf nodes. More...
 
AttributeDictionary Attributes = new AttributeDictionary() [get]
 The attributes of this node. Attributes Name, Length and Support are always included. See the respective properties for default values. More...
 
double Length [get, set]
 The length of the branch leading to this node. This is double.NaN for branches whose length is not specified (e.g. the root node). More...
 
double Support [get, set]
 The support value of this node. This is double.NaN for branches whose support is not specified. The interpretation of the support value depends on how the tree was built. More...
 
string Name [get, set]
 The name of this node (e.g. the species name for leaf nodes). Default is "". More...
 
string Id [get]
 A univocal identifier for the node. More...
 

Detailed Description

Represents a node in a tree (or a whole tree).

Definition at line 16 of file TreeNode.Comparisons.cs.

Member Enumeration Documentation

◆ NodeRelationship

Describes the relationship between two nodes.

Definition at line 807 of file TreeNode.cs.

◆ NullHypothesis

Null hypothesis for normalising tree shape indices.

Definition at line 13 of file TreeNode.ShapeIndices.cs.

◆ TreeComparisonPruningMode

Defines ways of pruning trees during comparisons.

Definition at line 99 of file TreeNode.Comparisons.cs.

Constructor & Destructor Documentation

◆ TreeNode()

PhyloTree.TreeNode.TreeNode ( TreeNode  parent)

Creates a new TreeNode object.

Parameters
parentThe parent node of this node. For the root node, this should be null.

Definition at line 378 of file TreeNode.cs.

Member Function Documentation

◆ Clone()

TreeNode PhyloTree.TreeNode.Clone ( )

Recursively clone a TreeNode object.

Returns
The cloned TreeNode

Definition at line 554 of file TreeNode.cs.

◆ CollessIndex()

double PhyloTree.TreeNode.CollessIndex ( NullHypothesis  model = NullHypothesis.None,
double  yhkExpectation = double.NaN 
)

Compute the Colless index of the tree.

Parameters
modelIf this is NullHypothesis.None, the raw Colless index is returned. If this is NullHypothesis.YHK or NullHypothesis.PDA, the Colless index is normalised with respect to the corresponding null tree model (which makes scores comparable across trees of different sizes).
yhkExpectationIf model is NullHypothesis.YHK, you can optionally use this parameter to provide a pre-computed value for the expected value of the Colless index under the YHK model. This is useful to save time if you need to compute the Colless index of many trees with the same number of leaves. If this is double.NaN, the expected value under the YHK model is computed by this method.
Returns
The Colless index of the tree.

Definition at line 139 of file TreeNode.ShapeIndices.cs.

◆ CreateDistanceMatrixDouble()

double[][] PhyloTree.TreeNode.CreateDistanceMatrixDouble ( int  maxDegreeOfParallelism = 0,
Action< double >  progressCallback = null 
)

Creates a lower triangular distance matrix, where each entry is the path length distance between two leaves in the tree. Entries are in the same order as returned by the GetLeaves method.

Parameters
maxDegreeOfParallelismMaximum number of threads to use, or -1 to let the runtime decide. If this argument is set to 0 (the default), the value used is 1 for trees with 1500 or fewer leaves, or -1 for larger trees.
progressCallbackA method used to report progress.
Returns
A T:double[][] jagged array containing the distance matrix.

Definition at line 1325 of file TreeNode.cs.

◆ CreateDistanceMatrixFloat()

float[][] PhyloTree.TreeNode.CreateDistanceMatrixFloat ( int  maxDegreeOfParallelism = 0,
Action< double >  progressCallback = null 
)

Creates a lower triangular distance matrix, where each entry is the path length distance between two leaves in the tree. Entries are in the same order as returned by the GetLeaves method.

Parameters
maxDegreeOfParallelismMaximum number of threads to use, or -1 to let the runtime decide. If this argument is set to 0 (the default), the value used is 1 for trees with 1500 or fewer leaves, or -1 for larger trees.
progressCallbackA method used to report progress.
Returns
A T:float[][] jagged array containing the distance matrix.

Definition at line 1445 of file TreeNode.cs.

◆ EdgeLengthDistance() [1/2]

double PhyloTree.TreeNode.EdgeLengthDistance ( TreeNode  otherTree)

Computes the edge-length distance between the current tree and another tree.

Parameters
otherTreeThe other tree whose distance to the current tree is computed.
Returns
The edge-length distance between this tree and the otherTree .

Definition at line 67 of file TreeNode.Comparisons.cs.

◆ EdgeLengthDistance() [2/2]

static double PhyloTree.TreeNode.EdgeLengthDistance ( TreeNode  tree1,
TreeNode  tree2 
)
static

Computes the edge-length distance between two trees.

Parameters
tree1The first tree.
tree2The second tree.
Returns
The edge-length distance between tree1 and tree2 .

Definition at line 78 of file TreeNode.Comparisons.cs.

◆ EdgeLengthDistances()

static double[,] PhyloTree.TreeNode.EdgeLengthDistances ( IReadOnlyList< TreeNode trees,
TreeComparisonPruningMode  pruningMode = TreeComparisonPruningMode.Pairwise,
int  maxThreadCount = -1,
IProgress< double >  progress = null 
)
static

Computes a distance matrix containing the edge-length distances between each pair of trees in a list.

Parameters
treesThe list of trees that should be compared.
pruningModeIf this is TreeComparisonPruningMode.Global, all trees are pruned so that they only contain the subset of leaves that are present in all trees. If this is TreeComparisonPruningMode.Pairwise, during each comparisons the two trees are pruned so that they contain the subset of leaves that are in common between both of them.
maxThreadCountThe maximum number of threads to use for parallelised steps.
progressAn IProgress<T> for progress reporting.
Returns
A square double[,] matrix containing the requested distances between the trees.

Definition at line 145 of file TreeNode.Comparisons.cs.

◆ GetChildrenRecursive()

List< TreeNode > PhyloTree.TreeNode.GetChildrenRecursive ( )

Recursively get all the nodes that descend from this node.

Returns
A List<T> of TreeNode objects, containing the nodes that descend from this node.

Definition at line 584 of file TreeNode.cs.

◆ GetChildrenRecursiveLazy()

IEnumerable< TreeNode > PhyloTree.TreeNode.GetChildrenRecursiveLazy ( )

Lazily recursively get all the nodes that descend from this node.

Returns
An IEnumerable<T> of TreeNode objects, containing the nodes that descend from this node.

Definition at line 602 of file TreeNode.cs.

◆ GetCollessExpectationYHK()

static double PhyloTree.TreeNode.GetCollessExpectationYHK ( int  numberOfLeaves)
static

Computes the expected value of the Colless index under the YHK model.

Parameters
numberOfLeavesThe number of leaves in the tree.
Returns
The expected value of the Colless index for a tree with the specified numberOfLeaves .

Proof in DOI: 10.1214/105051606000000547

Definition at line 106 of file TreeNode.ShapeIndices.cs.

◆ GetDepth()

int PhyloTree.TreeNode.GetDepth ( )

Compute the depth of the node (number of branches from this node until the root node).

Returns
The depth of the node.

Definition at line 35 of file TreeNode.ShapeIndices.cs.

◆ GetLastCommonAncestor() [1/3]

TreeNode PhyloTree.TreeNode.GetLastCommonAncestor ( IEnumerable< string >  monophyleticConstraint)

Gets the last common ancestor of all the nodes with the specified names, or null if the tree doesn't contain all the named nodes.

Parameters
monophyleticConstraintThe collection of names representing nodes whose last common ancestor is to be determined.
Returns
The last common ancestor of all the nodes with the specified names, or null if the tree doesn't contain all the named nodes.

Definition at line 1056 of file TreeNode.cs.

◆ GetLastCommonAncestor() [2/3]

static TreeNode PhyloTree.TreeNode.GetLastCommonAncestor ( IEnumerable< TreeNode monophyleticConstraint)
static

Gets the last common ancestor of all the specified nodes, or null if the tree doesn't contain all the nodes.

Parameters
monophyleticConstraintThe collection of nodes whose last common ancestor is to be determined.
Returns
The last common ancestor of all the specified nodes, or null if the tree doesn't contain all the nodes.

Definition at line 1022 of file TreeNode.cs.

◆ GetLastCommonAncestor() [3/3]

TreeNode PhyloTree.TreeNode.GetLastCommonAncestor ( params string[]  monophyleticConstraint)

Gets the last common ancestor of all the nodes with the specified names, or null if the tree doesn't contain all the named nodes.

Parameters
monophyleticConstraintThe collection of names representing nodes whose last common ancestor is to be determined.
Returns
The last common ancestor of all the nodes with the specified names, or null if the tree doesn't contain all the named nodes.

Definition at line 1046 of file TreeNode.cs.

◆ GetLeafNames()

List< string > PhyloTree.TreeNode.GetLeafNames ( )

Get the names of all the leaves that descend (directly or indirectly) from this node.

Returns
A List<T> of strings, containing the names of the leaves that descend from this node.

Definition at line 639 of file TreeNode.cs.

◆ GetLeaves()

List< TreeNode > PhyloTree.TreeNode.GetLeaves ( )

Get all the leaves that descend (directly or indirectly) from this node.

Returns
A List<T> of TreeNode objects, containing the leaves that descend from this node.

Definition at line 619 of file TreeNode.cs.

◆ GetNodeFromId()

TreeNode PhyloTree.TreeNode.GetNodeFromId ( string  nodeId)

Get the child node with the specified Id.

Parameters
nodeIdThe Id of the node to search.
Returns
The TreeNode object with the specified Id, or null if no node with such Id exists.

Definition at line 704 of file TreeNode.cs.

◆ GetNodeFromName()

TreeNode PhyloTree.TreeNode.GetNodeFromName ( string  nodeName)

Get the child node with the specified name.

Parameters
nodeNameThe name of the node to search.
Returns
The TreeNode object with the specified name, or null if no node with such name exists.

Definition at line 680 of file TreeNode.cs.

◆ GetNodeNames()

List< string > PhyloTree.TreeNode.GetNodeNames ( )

Get the names of all the named nodes that descend (directly or indirectly) from this node.

Returns
A List<T> of strings, containing the names of the named nodes that descend from this node.

Definition at line 659 of file TreeNode.cs.

◆ GetRootedTree()

TreeNode PhyloTree.TreeNode.GetRootedTree ( TreeNode  outgroup,
double  position = 0.5 
)

Get a version of the tree that is rooted at the specified point of the branch leading to the outgroup .

Parameters
outgroupThe outgroup to be used when rooting the tree.
positionThe (relative) position on the branch connecting the outgroup to the rest of the tree on which to place the root.
Returns
A TreeNode containing the rooted tree.

Definition at line 445 of file TreeNode.cs.

◆ GetRootNode()

TreeNode PhyloTree.TreeNode.GetRootNode ( )

Get the node of the tree from which all other nodes descend.

Returns
The node of the tree from which all other nodes descend

Definition at line 794 of file TreeNode.cs.

◆ GetSplit()

List< TreeNode > List< TreeNode > side2 PhyloTree.TreeNode.GetSplit ( )

Definition at line 1158 of file TreeNode.cs.

◆ GetSplits()

IEnumerable<(List< TreeNode > side1, List< TreeNode > side2, double branchLength)> PhyloTree.TreeNode.GetSplits ( )

Gets all the splits in the tree.

Returns
An IEnumerable<T> that enumerates all the splits in the tree.

Definition at line 1198 of file TreeNode.cs.

◆ GetUnrootedTree()

TreeNode PhyloTree.TreeNode.GetUnrootedTree ( )

Get an unrooted version of the tree.

Returns
A TreeNode containing the unrooted tree, having at least 3 children.

Definition at line 398 of file TreeNode.cs.

◆ IsClockLike()

bool PhyloTree.TreeNode.IsClockLike ( double  tolerance = 0.001)

Determines whether the tree is clock-like (i.e. all tips are contemporaneous) or not.

Parameters
toleranceThe (relative) tolerance when comparing branch lengths.
Returns
A boolean value determining whether the tree is clock-like or not

Definition at line 1000 of file TreeNode.cs.

◆ IsLastCommonAncestor()

bool PhyloTree.TreeNode.IsLastCommonAncestor ( IEnumerable< string >  monophyleticConstraint)

Checks whether this node is the last common ancestor of all the nodes with the specified names.

Parameters
monophyleticConstraintThe collection of names representing nodes whose last common ancestor is to be determined.
Returns
true if this node is the last common ancestor of all the nodes with the specified names, false otherwise.

Definition at line 1080 of file TreeNode.cs.

◆ IsRooted()

bool PhyloTree.TreeNode.IsRooted ( )

Checks whether the node belongs to a rooted tree.

Returns
true if the node belongs to a rooted tree, false otherwise.

Definition at line 389 of file TreeNode.cs.

◆ LongestDownstreamLength()

double PhyloTree.TreeNode.LongestDownstreamLength ( )

Get the sum of the branch lengths from this node down to the leaves of the tree. If the tree is not clock-like, the length of the longest path is returned.

Returns
The sum of the branch lengths from this node down to the leaves of the tree. If the tree is not clock-like, the length of the longest path is returned.

Definition at line 746 of file TreeNode.cs.

◆ NumberOfCherries()

double PhyloTree.TreeNode.NumberOfCherries ( NullHypothesis  model = NullHypothesis.None)

Computes the number of cherries in the tree.

Parameters
modelIf this is NullHypothesis.None, the raw number of cherries is returned. If this is NullHypothesis.YHK or NullHypothesis.PDA, the number of cherries is normalised with respect to the corresponding null tree model (which makes scores comparable across trees of different sizes).
Returns
The number of cherries in the tree.

Proofs in DOI: 10.1016/S0025-5564(99)00060-7

Definition at line 167 of file TreeNode.ShapeIndices.cs.

◆ PathLengthTo()

double PhyloTree.TreeNode.PathLengthTo ( TreeNode  otherNode,
NodeRelationship  nodeRelationship = NodeRelationship.Unknown 
)

Get the sum of the branch lengths from this node to the specified node.

Parameters
otherNodeThe node that should be reached
nodeRelationshipA value indicating how this node is related to otherNode .
Returns
The sum of the branch lengths from this node to the specified node.

Definition at line 836 of file TreeNode.cs.

◆ Prune() [1/2]

TreeNode PhyloTree.TreeNode.Prune ( bool  leaveParent)

Prunes the current node from the tree.

Parameters
leaveParentThis value determines what happens to the parent node of the current node if it only has two children (i.e., the current node and another node). If this is false, the parent node is also pruned; if it is true, the parent node is left untouched.

Note that the node is pruned in-place; however, the return value of this method should be used, because pruning the node may have caused the root of the tree to move.

Returns
The TreeNode corresponding to the root of the tree after the current node has been pruned.

Definition at line 1223 of file TreeNode.cs.

◆ Prune() [2/2]

TreeNode PhyloTree.TreeNode.Prune ( TreeNode  nodeToPrune,
bool  leaveParent 
)

Prunes a node from the tree.

Parameters
nodeToPruneThe node that should be pruned.
leaveParentThis value determines what happens to the parent node of the pruned node if it only has two children (i.e., the pruned node and another node). If this is false, the parent node is also pruned; if it is true, the parent node is left untouched.

Note that the node is pruned in-place; however, the return value of this method should be used, because pruning the node may have caused the root of the tree to move.

Returns
The TreeNode corresponding to the root of the tree after the nodeToPrune has been pruned.

Definition at line 1295 of file TreeNode.cs.

◆ RobinsonFouldsDistance() [1/2]

double PhyloTree.TreeNode.RobinsonFouldsDistance ( TreeNode  otherTree,
bool  weighted 
)

Computes the Robinson-Foulds distance between the current tree and another tree.

Parameters
otherTreeThe other tree whose distance to the current tree is computed.
weightedIf this is true, the distance is weighted based on the branch lengths; otherwise, it is unweighted.
Returns
The Robinson-Foulds distance between this tree and the otherTree .

Definition at line 24 of file TreeNode.Comparisons.cs.

◆ RobinsonFouldsDistance() [2/2]

static double PhyloTree.TreeNode.RobinsonFouldsDistance ( TreeNode  tree1,
TreeNode  tree2,
bool  weighted 
)
static

Computes the Robinson-Foulds distance between two trees.

Parameters
tree1The first tree.
tree2The second tree.
weightedIf this is true, the distance is weighted based on the branch lengths; otherwise, it is unweighted.
Returns
The Robinson-Foulds distance between tree1 and tree2 .

Definition at line 36 of file TreeNode.Comparisons.cs.

◆ RobinsonFouldsDistances() [1/2]

static double[,] PhyloTree.TreeNode.RobinsonFouldsDistances ( IReadOnlyList< TreeNode trees,
bool  weighted,
TreeComparisonPruningMode  pruningMode = TreeComparisonPruningMode.Pairwise,
int  maxThreadCount = -1,
IProgress< double >  progress = null 
)
static

Computes a distance matrix containing the Robinson-Foulds distances between each pair of trees in a list.

Parameters
treesThe list of trees that should be compared.
weightedIf this is true, the distance is weighted based on the branch lengths; otherwise, it is unweighted.
pruningModeIf this is TreeComparisonPruningMode.Global, all trees are pruned so that they only contain the subset of leaves that are present in all trees. If this is TreeComparisonPruningMode.Pairwise, during each comparisons the two trees are pruned so that they contain the subset of leaves that are in common between both of them.
maxThreadCountThe maximum number of threads to use for parallelised steps.
progressAn IProgress<T> for progress reporting.
Returns
A square double[,] matrix containing the requested distances between the trees.

Definition at line 121 of file TreeNode.Comparisons.cs.

◆ RobinsonFouldsDistances() [2/2]

static void PhyloTree.TreeNode.RobinsonFouldsDistances ( IReadOnlyList< TreeNode trees,
out double  RFDistances[,],
out double  weightedRFDistances[,],
TreeComparisonPruningMode  pruningMode = TreeComparisonPruningMode.Pairwise,
int  maxThreadCount = -1,
IProgress< double >  progress = null 
)
static

Computes two distance matrices containing the unweighted and weighted Robinson-Foulds distances between each pair of trees in a list. Much faster than computing the two distance matrices separately.

Parameters
treesThe list of trees that should be compared.
RFDistancesWhen this method returns, this variable will contain the computed Robinson-Foulds distances between the trees.
weightedRFDistancesWhen this method returns, this variable will contain the computed weighted Robinson-Foulds distances between the trees.
pruningModeIf this is TreeComparisonPruningMode.Global, all trees are pruned so that they only contain the subset of leaves that are present in all trees. If this is TreeComparisonPruningMode.Pairwise, during each comparisons the two trees are pruned so that they contain the subset of leaves that are in common between both of them.
maxThreadCountThe maximum number of threads to use for parallelised steps.
progressAn IProgress<T> for progress reporting.
Returns
A square double[,] matrix containing the requested distances between the trees.

Definition at line 164 of file TreeNode.Comparisons.cs.

◆ SackinIndex()

double PhyloTree.TreeNode.SackinIndex ( NullHypothesis  model = NullHypothesis.None)

Computes the Sackin index of the tree (sum of the leaf depths).

Parameters
modelIf this is NullHypothesis.None, the raw Sackin index is returned. If this is NullHypothesis.YHK or NullHypothesis.PDA, the Sackin index is normalised with respect to the corresponding null tree model (which makes scores comparable across trees of different sizes).
Returns
The Sackin index of the tree, either as a raw value, or normalised according to the selected null tree model.

Definition at line 56 of file TreeNode.ShapeIndices.cs.

◆ ShortestDownstreamLength()

double PhyloTree.TreeNode.ShortestDownstreamLength ( )

Get the sum of the branch lengths from this node down to the leaves of the tree. If the tree is not clock-like, the length of the shortest path is returned.

Returns
The sum of the branch lengths from this node down to the leaves of the tree. If the tree is not clock-like, the length of the shortest path is returned.

Definition at line 770 of file TreeNode.cs.

◆ SortNodes()

void PhyloTree.TreeNode.SortNodes ( bool  descending)

Sort (in place) the nodes in the tree in an aesthetically pleasing way.

Parameters
descendingThe way the nodes should be sorted.

Definition at line 921 of file TreeNode.cs.

◆ ToString()

override string PhyloTree.TreeNode.ToString ( )

Convert the tree to a Newick string.

Returns

Definition at line 990 of file TreeNode.cs.

◆ TotalLength()

double PhyloTree.TreeNode.TotalLength ( )

Get the sum of the branch lengths of this node and all its descendants.

Returns
The sum of the branch lengths of this node and all its descendants.

Definition at line 906 of file TreeNode.cs.

◆ TreeDistances()

static void PhyloTree.TreeNode.TreeDistances ( IReadOnlyList< TreeNode trees,
out double  RFDistances[,],
out double  weightedRFDistances[,],
out double  ELDistances[,],
TreeComparisonPruningMode  pruningMode = TreeComparisonPruningMode.Pairwise,
int  maxThreadCount = -1,
IProgress< double >  progress = null 
)
static

Computes three distance matrices containing the unweighted and weighted Robinson-Foulds distances and the edge-length distances between each pair of trees in a list. Much faster than computing the three distance matrices separately.

Parameters
treesThe list of trees that should be compared.
RFDistancesWhen this method returns, this variable will contain the computed Robinson-Foulds distances between the trees.
weightedRFDistancesWhen this method returns, this variable will contain the computed weighted Robinson-Foulds distances between the trees.
ELDistancesWhen this method returns, this variable will contain the computed edge-length distances between the trees.
pruningModeIf this is TreeComparisonPruningMode.Global, all trees are pruned so that they only contain the subset of leaves that are present in all trees. If this is TreeComparisonPruningMode.Pairwise, during each comparisons the two trees are pruned so that they contain the subset of leaves that are in common between both of them.
maxThreadCountThe maximum number of threads to use for parallelised steps.
progressAn IProgress<T> for progress reporting.
Returns
A square double[,] matrix containing the requested distances between the trees.

Definition at line 183 of file TreeNode.Comparisons.cs.

◆ UpstreamLength()

double PhyloTree.TreeNode.UpstreamLength ( )

Get the sum of the branch lengths from this node up to the root.

Returns
The sum of the branch lengths from this node up to the root.

Definition at line 727 of file TreeNode.cs.

Member Data Documentation

◆ side1

List<TreeNode> PhyloTree.TreeNode.side1

Gets the split corresponding to the branch underlying this node. If this is an internal node, side1 will contain all the leaves in the tree except those descending from this node, and side2 will contain all the leaves descending from this node. If this is the root side1 will be empty and side2 will contain all the leaves in the tree. If the tree is rooted (the root node has exactly 2 children), side1 will contain in all cases an additional null element.

Returns
The leaves on the two sides of the split.

Definition at line 1158 of file TreeNode.cs.

Property Documentation

◆ Attributes

AttributeDictionary PhyloTree.TreeNode.Attributes = new AttributeDictionary()
get

The attributes of this node. Attributes Name, Length and Support are always included. See the respective properties for default values.

Definition at line 321 of file TreeNode.cs.

◆ Children

List<TreeNode> PhyloTree.TreeNode.Children
get

The child nodes of this node. This will be empty (but initialised) for leaf nodes.

Definition at line 316 of file TreeNode.cs.

◆ Id

string PhyloTree.TreeNode.Id
get

A univocal identifier for the node.

Definition at line 372 of file TreeNode.cs.

◆ Length

double PhyloTree.TreeNode.Length
getset

The length of the branch leading to this node. This is double.NaN for branches whose length is not specified (e.g. the root node).

Definition at line 326 of file TreeNode.cs.

◆ Name

string PhyloTree.TreeNode.Name
getset

The name of this node (e.g. the species name for leaf nodes). Default is "".

Definition at line 356 of file TreeNode.cs.

◆ Parent

TreeNode PhyloTree.TreeNode.Parent
getset

The parent node of this node. This will be null for the root node.

Definition at line 311 of file TreeNode.cs.

◆ Support

double PhyloTree.TreeNode.Support
getset

The support value of this node. This is double.NaN for branches whose support is not specified. The interpretation of the support value depends on how the tree was built.

Definition at line 341 of file TreeNode.cs.


The documentation for this class was generated from the following files: