bpp-phyl
2.2.0
|
The neighbor joining distance method. More...
#include <Bpp/Phyl/Distance/NeighborJoining.h>
Public Member Functions | |
NeighborJoining (bool rooted=false, bool positiveLengths=false, bool verbose=true) | |
Create a new NeighborJoining object instance, without performing any computation. More... | |
NeighborJoining (const DistanceMatrix &matrix, bool rooted=false, bool positiveLengths=false, bool verbose=true) throw (Exception) | |
Create a new NeighborJoining object instance and compute a tree from a distance matrix. More... | |
virtual | ~NeighborJoining () |
NeighborJoining * | clone () const |
std::string | getName () const |
virtual void | setDistanceMatrix (const DistanceMatrix &matrix) throw (Exception) |
Set the distance matrix to use. More... | |
virtual void | outputPositiveLengths (bool yn) |
virtual TreeTemplate< Node > * | getTree () const |
Get the computed tree, if there is one. More... | |
virtual void | computeTree () throw (Exception) |
Compute the tree corresponding to the distance matrix. More... | |
void | setVerbose (bool yn) |
bool | isVerbose () const |
Protected Member Functions | |
std::vector< size_t > | getBestPair () throw (Exception) |
Get the best pair of nodes to agglomerate. More... | |
std::vector< double > | computeBranchLengthsForPair (const std::vector< size_t > &pair) |
Compute the branch lengths for two nodes to agglomerate. More... | |
double | computeDistancesFromPair (const std::vector< size_t > &pair, const std::vector< double > &branchLengths, size_t pos) |
Actualizes the distance matrix according to a given pair and the corresponding branch lengths. More... | |
void | finalStep (int idRoot) |
Method called when there ar eonly three remaining node to agglomerate, and creates the root node of the tree. More... | |
Specific methods. | |
virtual Node * | getLeafNode (int id, const std::string &name) |
Get a leaf node. More... | |
virtual Node * | getParentNode (int id, Node *son1, Node *son2) |
Get an inner node. More... | |
Protected Attributes | |
std::vector< double > | sumDist_ |
bool | positiveLengths_ |
DistanceMatrix | matrix_ |
Tree * | tree_ |
std::map< size_t, Node * > | currentNodes_ |
bool | verbose_ |
bool | rootTree_ |
The neighbor joining distance method.
Reference: N Saitou and M Nei (1987), Molecular Biology and Evolution 4(4) 406-25.
Definition at line 55 of file NeighborJoining.h.
|
inline |
Create a new NeighborJoining object instance, without performing any computation.
rooted | Tell if the output tree should be rooted. |
positiveLengths | Tell if negative lengths should be avoided. |
verbose | Allow to display extra information, like progress bars. |
Definition at line 70 of file NeighborJoining.h.
Referenced by clone().
|
inline |
Create a new NeighborJoining object instance and compute a tree from a distance matrix.
matrix | Input distance matrix. |
rooted | Tell if the output tree should be rooted. |
positiveLengths | Tell if negative lengths should be avoided. |
verbose | Allow to display extra information, like progress bars. |
Definition at line 84 of file NeighborJoining.h.
References bpp::AbstractAgglomerativeDistanceMethod::computeTree(), and sumDist_.
|
inlinevirtual |
Definition at line 93 of file NeighborJoining.h.
|
inline |
Definition at line 95 of file NeighborJoining.h.
References NeighborJoining().
|
protectedvirtual |
Compute the branch lengths for two nodes to agglomerate.
This method compute l1 and l2 given N1 and N2.
pair | The indices of the nodes to be agglomerated. |
Implements bpp::AbstractAgglomerativeDistanceMethod.
Definition at line 92 of file NeighborJoining.cpp.
|
protectedvirtual |
Actualizes the distance matrix according to a given pair and the corresponding branch lengths.
pair | The indices of the nodes to be agglomerated. |
branchLengths | The corresponding branch lengths. |
pos | The index of the node whose distance ust be updated. |
Implements bpp::AbstractAgglomerativeDistanceMethod.
Definition at line 109 of file NeighborJoining.cpp.
|
virtualinherited |
Compute the tree corresponding to the distance matrix.
This method implements the following algorithm: 1) Build all leaf nodes (getLeafNode method) 2) Get the best pair to agglomerate (getBestPair method) 3) Compute the branch lengths for this pair (computeBranchLengthsForPair method) 4) Build the parent node of the pair (getParentNode method) 5) For each remaining node, update distances from the pair (computeDistancesFromPair method) 6) Return to step 2 while there are more than 3 remaining nodes. 7) Perform the final step, and send a rooted or unrooted tree.
Implements bpp::DistanceMethod.
Reimplemented in bpp::BioNJ.
Definition at line 62 of file AbstractAgglomerativeDistanceMethod.cpp.
References bpp::Node::setDistanceToFather().
Referenced by bpp::HierarchicalClustering::HierarchicalClustering(), NeighborJoining(), and bpp::PGMA::PGMA().
|
protectedvirtual |
Method called when there ar eonly three remaining node to agglomerate, and creates the root node of the tree.
idRoot | The id of the root node. |
Implements bpp::AbstractAgglomerativeDistanceMethod.
Definition at line 117 of file NeighborJoining.cpp.
References bpp::Node::addSon(), and bpp::Node::setDistanceToFather().
|
protectedvirtual |
Get the best pair of nodes to agglomerate.
Define the criterion to chose the next pair of nodes to agglomerate. This criterion uses the matrix_ distance matrix.
Exception | If an error occured. |
Implements bpp::AbstractAgglomerativeDistanceMethod.
Definition at line 51 of file NeighborJoining.cpp.
|
protectedvirtualinherited |
Get a leaf node.
Create a new node with the given id and name.
id | The id of the node. |
name | The name of the node. |
Reimplemented in bpp::PGMA, and bpp::HierarchicalClustering.
Definition at line 111 of file AbstractAgglomerativeDistanceMethod.cpp.
|
inlinevirtual |
Implements bpp::DistanceMethod.
Definition at line 98 of file NeighborJoining.h.
|
protectedvirtualinherited |
Get an inner node.
Create a new node with the given id, and set its sons.
id | The id of the node. |
son1 | The first son of the node. |
son2 | The second son of the node. |
Reimplemented in bpp::PGMA, and bpp::HierarchicalClustering.
Definition at line 116 of file AbstractAgglomerativeDistanceMethod.cpp.
References bpp::Node::addSon().
|
inlinevirtualinherited |
Get the computed tree, if there is one.
Implements bpp::DistanceMethod.
Reimplemented in bpp::HierarchicalClustering, and bpp::PGMA.
Definition at line 127 of file AbstractAgglomerativeDistanceMethod.h.
References bpp::AbstractAgglomerativeDistanceMethod::tree_.
Referenced by bpp::TreeTools::MRP(), and bpp::TreeTools::MRPMultilabel().
|
inlinevirtualinherited |
Implements bpp::DistanceMethod.
Definition at line 149 of file AbstractAgglomerativeDistanceMethod.h.
References bpp::AbstractAgglomerativeDistanceMethod::verbose_.
|
inlinevirtual |
Definition at line 106 of file NeighborJoining.h.
References positiveLengths_.
Referenced by bpp::BioNJ::BioNJ().
|
inlinevirtual |
Set the distance matrix to use.
matrix | The matrix to use. |
Exception | In case an incorrect matrix is provided (eg smaller than 3). |
Reimplemented from bpp::AbstractAgglomerativeDistanceMethod.
Reimplemented in bpp::BioNJ.
Definition at line 100 of file NeighborJoining.h.
References bpp::AbstractAgglomerativeDistanceMethod::setDistanceMatrix(), and sumDist_.
Referenced by bpp::BioNJ::setDistanceMatrix().
|
inlinevirtualinherited |
yn | Enable/Disable verbose mode. |
Implements bpp::DistanceMethod.
Definition at line 148 of file AbstractAgglomerativeDistanceMethod.h.
References bpp::AbstractAgglomerativeDistanceMethod::verbose_.
|
protectedinherited |
Definition at line 69 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::operator=().
|
protectedinherited |
Definition at line 66 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::operator=().
|
protected |
Definition at line 60 of file NeighborJoining.h.
Referenced by outputPositiveLengths().
|
protectedinherited |
Definition at line 71 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::operator=().
|
protected |
Definition at line 59 of file NeighborJoining.h.
Referenced by NeighborJoining(), and setDistanceMatrix().
|
protectedinherited |
Definition at line 67 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::AbstractAgglomerativeDistanceMethod(), bpp::AbstractAgglomerativeDistanceMethod::getTree(), bpp::AbstractAgglomerativeDistanceMethod::operator=(), and bpp::AbstractAgglomerativeDistanceMethod::~AbstractAgglomerativeDistanceMethod().
|
protectedinherited |
Definition at line 70 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::isVerbose(), bpp::AbstractAgglomerativeDistanceMethod::operator=(), and bpp::AbstractAgglomerativeDistanceMethod::setVerbose().