bpp-phyl3
3.0.0
|
The BioNJ distance method. More...
#include <Bpp/Phyl/Distance/BioNJ.h>
Public Member Functions | |
BioNJ (bool rooted=false, bool positiveLengths=false, bool verbose=true) | |
Create a new BioNJ object instance and compute a tree from a distance matrix. More... | |
BioNJ (const DistanceMatrix &matrix, bool rooted=false, bool positiveLengths=false, bool verbose=true) | |
Create a new BioNJ object instance and compute a tree from a distance matrix. More... | |
BioNJ * | clone () const |
virtual | ~BioNJ () |
std::string | getName () const |
void | setDistanceMatrix (const DistanceMatrix &matrix) |
Set the distance matrix to use. More... | |
void | computeTree () |
Compute the tree corresponding to the distance matrix. 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... | |
virtual void | outputPositiveLengths (bool yn) |
bool | hasTree () const override |
const Tree & | tree () const override |
void | setVerbose (bool yn) override |
bool | isVerbose () const override |
Protected Member Functions | |
std::vector< size_t > | getBestPair () |
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... | |
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_ |
std::unique_ptr< Tree > | tree_ |
std::map< size_t, Node * > | currentNodes_ |
bool | verbose_ |
bool | rootTree_ |
Private Attributes | |
DistanceMatrix | variance_ |
double | lambda_ |
The BioNJ distance method.
Reference: Gascuel O. BIONJ: an improved version of the NJ algorithm based on a simple model of sequence data. Mol Biol Evol. 1997 Jul;14(7):685-95.
|
inline |
Create a new BioNJ object instance and compute a tree from a 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 36 of file BioNJ.h.
Referenced by clone().
|
inline |
Create a new BioNJ 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 49 of file BioNJ.h.
References computeTree(), bpp::NeighborJoining::outputPositiveLengths(), and setDistanceMatrix().
|
inlinevirtual |
Implements bpp::AgglomerativeDistanceMethodInterface.
Definition at line 60 of file BioNJ.h.
References BioNJ().
|
protectedvirtualinherited |
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 56 of file NeighborJoining.cpp.
|
virtual |
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.
|
virtual |
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.
Reimplemented from bpp::AbstractAgglomerativeDistanceMethod.
Definition at line 25 of file BioNJ.cpp.
References bpp::ApplicationTools::displayGauge(), and bpp::Node::setDistanceToFather().
Referenced by BioNJ().
|
protectedvirtualinherited |
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 81 of file NeighborJoining.cpp.
References bpp::Node::addSon(), and bpp::Node::setDistanceToFather().
|
protectedvirtualinherited |
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 occurred. |
Implements bpp::AbstractAgglomerativeDistanceMethod.
Definition at line 15 of file NeighborJoining.cpp.
References bpp::numeric::log().
|
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 75 of file AbstractAgglomerativeDistanceMethod.cpp.
|
inlinevirtual |
Implements bpp::DistanceMethodInterface.
|
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 80 of file AbstractAgglomerativeDistanceMethod.cpp.
References bpp::Node::addSon().
|
inlineoverridevirtualinherited |
Implements bpp::DistanceMethodInterface.
Definition at line 86 of file AbstractAgglomerativeDistanceMethod.h.
References bpp::AbstractAgglomerativeDistanceMethod::tree_.
|
inlineoverridevirtualinherited |
Implements bpp::DistanceMethodInterface.
Definition at line 114 of file AbstractAgglomerativeDistanceMethod.h.
References bpp::AbstractAgglomerativeDistanceMethod::verbose_.
|
inlinevirtualinherited |
Definition at line 70 of file NeighborJoining.h.
References bpp::NeighborJoining::positiveLengths_.
Referenced by 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::NeighborJoining.
Definition at line 67 of file BioNJ.h.
References bpp::NeighborJoining::setDistanceMatrix(), and variance_.
Referenced by BioNJ().
|
inlineoverridevirtualinherited |
yn | Enable/Disable verbose mode. |
Implements bpp::DistanceMethodInterface.
Definition at line 113 of file AbstractAgglomerativeDistanceMethod.h.
References bpp::AbstractAgglomerativeDistanceMethod::verbose_.
|
inlineoverridevirtualinherited |
Implements bpp::DistanceMethodInterface.
Definition at line 91 of file AbstractAgglomerativeDistanceMethod.h.
References bpp::AbstractAgglomerativeDistanceMethod::tree_.
|
protectedinherited |
Definition at line 33 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::operator=().
|
protectedinherited |
Definition at line 30 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::operator=().
|
protectedinherited |
Definition at line 24 of file NeighborJoining.h.
Referenced by bpp::NeighborJoining::outputPositiveLengths().
|
protectedinherited |
Definition at line 35 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::operator=().
|
protectedinherited |
Definition at line 23 of file NeighborJoining.h.
Referenced by bpp::NeighborJoining::NeighborJoining(), and bpp::NeighborJoining::setDistanceMatrix().
|
protectedinherited |
Definition at line 31 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::AbstractAgglomerativeDistanceMethod(), bpp::AbstractAgglomerativeDistanceMethod::hasTree(), bpp::AbstractAgglomerativeDistanceMethod::operator=(), and bpp::AbstractAgglomerativeDistanceMethod::tree().
|
private |
Definition at line 25 of file BioNJ.h.
Referenced by setDistanceMatrix().
|
protectedinherited |
Definition at line 34 of file AbstractAgglomerativeDistanceMethod.h.
Referenced by bpp::AbstractAgglomerativeDistanceMethod::isVerbose(), bpp::AbstractAgglomerativeDistanceMethod::operator=(), and bpp::AbstractAgglomerativeDistanceMethod::setVerbose().