Sleipnir
|
Represents a simple node in a binary tree. More...
#include <clusthierarchical.h>
Public Member Functions | |
CHierarchy (size_t iID, float dSimilarity, const CHierarchy *pLeft, const CHierarchy *pRight) | |
Constructs a new hierarchy node. | |
void | GetGenes (std::vector< size_t > &veciGenes) const |
Retrieve the IDs of the hierarchy's genes by inorder traversal. | |
float | SortChildren (const std::vector< float > &vecdScores) |
Performs node-flipping in the hierarchy according to a given set of leaf node scores. | |
void | Save (std::ostream &ostm, size_t iGenes, const std::vector< std::string > *pvecstrGenes=NULL) const |
Save the hierarchy to the given stream in GTR format. | |
void | Destroy () |
Safety method to delete a hierarchy. | |
float | GetSimilarity () const |
Returns this node's height within the hierarchy. | |
bool | IsGene () const |
Returns true if the current node is a leaf node (i.e. represents a gene in the hierarchy). | |
size_t | GetID () const |
Returns the current node's unique ID within the hierarchy. | |
const CHierarchy & | Get (bool fRight) const |
Returns the current node's left or right child. | |
size_t | GetWeight () const |
Returns the number of leaves under the current node. |
Represents a simple node in a binary tree.
Generated by CClustHierarchical::Cluster, a CHierarchy is an extremely rudimentary representation of an binary tree intended to be serialized to disk as the GTR file in a CDT/GTR pair. Each node either zero or two children, a unique integer identifier within the tree, and a similarity score indicating its height within the tree.
Definition at line 41 of file clusthierarchical.h.
Sleipnir::CHierarchy::CHierarchy | ( | size_t | iID, |
float | dSimilarity, | ||
const CHierarchy * | pLeft, | ||
const CHierarchy * | pRight | ||
) |
Constructs a new hierarchy node.
iID | Unique ID of the new node. |
dSimilarity | Height of the new node within the tree. |
pLeft | First child of the new node, possibly null. |
pRight | Second child of the new node, possibly null. |
Definition at line 52 of file clusthierarchical.cpp.
void Sleipnir::CHierarchy::Destroy | ( | ) | [inline] |
Safety method to delete a hierarchy.
Definition at line 80 of file clusthierarchical.h.
const CHierarchy& Sleipnir::CHierarchy::Get | ( | bool | fRight | ) | const [inline] |
Returns the current node's left or right child.
fRight | If true, return the right (second) child; otherwise, return the left (first). |
Definition at line 137 of file clusthierarchical.h.
void Sleipnir::CHierarchy::GetGenes | ( | std::vector< size_t > & | veciGenes | ) | const |
Retrieve the IDs of the hierarchy's genes by inorder traversal.
veciGenes | Output vector into which gene IDs are placed. |
Definition at line 111 of file clusthierarchical.cpp.
References IsGene().
size_t Sleipnir::CHierarchy::GetID | ( | ) | const [inline] |
Returns the current node's unique ID within the hierarchy.
Definition at line 117 of file clusthierarchical.h.
float Sleipnir::CHierarchy::GetSimilarity | ( | ) | const [inline] |
Returns this node's height within the hierarchy.
Definition at line 91 of file clusthierarchical.h.
size_t Sleipnir::CHierarchy::GetWeight | ( | ) | const [inline] |
Returns the number of leaves under the current node.
Definition at line 148 of file clusthierarchical.h.
bool Sleipnir::CHierarchy::IsGene | ( | ) | const [inline] |
Returns true if the current node is a leaf node (i.e. represents a gene in the hierarchy).
Reimplemented from Sleipnir::CHierarchyImpl.
Definition at line 102 of file clusthierarchical.h.
Referenced by GetGenes(), and SortChildren().
void Sleipnir::CHierarchy::Save | ( | std::ostream & | ostm, |
size_t | iGenes, | ||
const std::vector< std::string > * | pvecstrGenes = NULL |
||
) | const [inline] |
Save the hierarchy to the given stream in GTR format.
ostm | Output stream into which the hierarchy is saved. |
iGenes | Total number of leaf nodes in the hierarchy. |
pvecstrGenes | If non-NULL, vector of gene names to be emitted in place of GENE IDs. |
Reimplemented from Sleipnir::CHierarchyImpl.
Definition at line 66 of file clusthierarchical.h.
float Sleipnir::CHierarchy::SortChildren | ( | const std::vector< float > & | vecdScores | ) |
Performs node-flipping in the hierarchy according to a given set of leaf node scores.
vecdScores | Scores for the hierarchy's leaf nodes indexed by ID. |
SortChildren can be used to node-flip a hierarchy such that an inorder traversal of the leaf nodes results in a strictly increasing value for some precomputed score. Since optimal node ordering is NP-hard, this is often used to heuristically order microarray vectors, e.g. from most green to most red.
Definition at line 138 of file clusthierarchical.cpp.
References IsGene().