bpp-phyl3
3.0.0
|
Generic utilitary methods dealing with trees. More...
#include <Bpp/Phyl/Tree/PhyloTreeTools.h>
Classes | |
struct | Moments_ |
Public Member Functions | |
PhyloTreeTools () | |
virtual | ~PhyloTreeTools () |
Static Public Member Functions | |
static std::shared_ptr< PhyloTree > | buildFromTreeTemplate (const TreeTemplate< Node > &treetemp) |
static double | getHeight (const PhyloTree &tree, const std::shared_ptr< PhyloNode > node) |
Get the height of the subtree defined by node 'node', i.e. the maximum distance between leaves and the root of the subtree. More... | |
static void | initBranchLengthsGrafen (PhyloTree &tree) |
Grafen's method to initialize branch lengths. More... | |
static void | computeBranchLengthsGrafen (PhyloTree &tree, double power=1, bool init=true) |
Compute branch lengths using Grafen's method. More... | |
static double | convertToClockTree (PhyloTree &tree, std::shared_ptr< PhyloNode > node) |
Modify a tree's branch lengths to make a clock tree, by rebalancing branch lengths. More... | |
static double | convertToClockTree2 (PhyloTree &tree, std::shared_ptr< PhyloNode > node) |
Modify a tree's branch lengths to make a clock tree, by rescaling subtrees. More... | |
static void | constrainedMidPointRooting (PhyloTree &tree) |
Determine the mid-point position of the root along the branch that already contains the root. Consequently, the topology of the rooted tree remains identical. More... | |
Static Private Member Functions | |
static size_t | initBranchLengthsGrafen (PhyloTree &tree, std::shared_ptr< PhyloNode > node) |
static void | computeBranchLengthsGrafen (PhyloTree &tree, std::shared_ptr< PhyloNode > node, double power, double total, double &height, double &heightRaised) |
Some properties. | |
static const std::string | BOOTSTRAP = "bootstrap" |
Bootstrap tag. More... | |
static Moments_ | statFromNode_ (const PhyloTree &tree, const std::shared_ptr< PhyloNode > root) |
static double | bestRootPosition_ (const PhyloTree &tree, const std::shared_ptr< PhyloNode > node1, const std::shared_ptr< PhyloNode > node2, double length) |
Generic utilitary methods dealing with trees.
These methods work with all Tree object. However, depending on the tree implementation, they may not be the most efficient.
Definition at line 34 of file PhyloTreeTools.h.
|
inline |
Definition at line 37 of file PhyloTreeTools.h.
|
inlinevirtual |
Definition at line 38 of file PhyloTreeTools.h.
|
staticprivate |
Definition at line 238 of file PhyloTreeTools.cpp.
References bpp::PhyloTreeTools::Moments_::N, and bpp::PhyloTreeTools::Moments_::sum.
|
static |
Definition at line 34 of file PhyloTreeTools.cpp.
References bpp::Node::getId(), bpp::Node::getName(), bpp::Node::getNodeProperty(), bpp::Node::getNodePropertyNames(), bpp::TreeTemplate< N >::getRootNode(), and bpp::Node::hasName().
Referenced by bpp::OptimizationTools::buildDistanceTree(), and bpp::PhylogeneticsApplicationTools::getPhyloTrees().
|
static |
Compute branch lengths using Grafen's method.
The 'height' of each node is divided by the total height of the tree, and the ratio is raised at power 'rho'. A value of rho=0 hence returns a star tree.
Reference: Grafen A. The phylogenetic regression. Philos Trans R Soc Lond B Biol Sci. 1989; 326(1233):119-57
tree | The tree to use. |
power | The rho parameter. |
init | Tell if the height must be initialized by calling the initBranchLengthsGrafen() method. Otherwise use branch lengths. |
Definition at line 133 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getRoot().
Referenced by bpp::PhylogeneticsApplicationTools::getPhyloTrees().
|
staticprivate |
Definition at line 99 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeToFather(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getSons(), and bpp::pow().
|
static |
Determine the mid-point position of the root along the branch that already contains the root. Consequently, the topology of the rooted tree remains identical.
This code uses two inner functions to compute the mid-point position: statFromNode_ and bestRootPosition_. This code is inspired by a code performing a similar calculation in Seaview (Guindon et al., 2010, Mol. Biol. Evol. 27(2):221-4).
tree | The rooted tree for which the root has to be moved to its mid-point position, along the branch where it already stands. |
Definition at line 211 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeToFather(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getRoot(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getSons(), and bpp::AssociationTreeGraphImplObserver< class, class, class >::isRooted().
Referenced by bpp::PhylogeneticsApplicationTools::getPhyloTrees().
|
static |
Modify a tree's branch lengths to make a clock tree, by rebalancing branch lengths.
The height of each node is set to the mean height of all son nodes. This may however lead to negative branch lengths, since the mean height may be inferior to one of the son heights, due to short branch lengths. If the 'noneg' is set to yes, the mean height is checked against all son heights. If it is inferior to one of the son heights, the maximum son height is used instead. This results in a multifurcation.
This method is recursive and will be applied on all sons nodes.
tree | The tree to use. |
node | The node defining the subtree. |
Definition at line 146 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeToFather(), and bpp::AssociationTreeGraphImplObserver< class, class, class >::getSons().
Referenced by bpp::PhylogeneticsApplicationTools::getPhyloTrees().
|
static |
Modify a tree's branch lengths to make a clock tree, by rescaling subtrees.
The height of each node is set to the mean height of all son nodes. All branch lengths of the corresponding subtrees are updated proportionally. This algorithm is smaller than the convertToClockTree method, but may be more accurate.
This method is recursive and will be applied on all sons nodes.
tree | The tree to use. |
node | The node defining the subtree. |
Definition at line 180 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeToFather(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getSons(), and bpp::PhyloTree::scaleTree().
|
static |
Get the height of the subtree defined by node 'node', i.e. the maximum distance between leaves and the root of the subtree.
The distance do not include the branch length of the subtree root node. The height of a leaf is hence 0.
tree | The tree. |
node | The node defining the subtree. |
Definition at line 55 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getNodes(), and bpp::AssociationTreeGraphImplObserver< class, class, class >::getOutgoingEdges().
Referenced by bpp::PhylogeneticsApplicationTools::getPhyloTrees().
|
static |
Grafen's method to initialize branch lengths.
Each height of the node (total distance from the leaves) is set equal to the number of leaf nodes for the corresponding subtrees - 1 for inner nodes, 0 for leaves.
If the tree already has branch lengths, they will be ignored.
Reference: Grafen A. The phylogenetic regression. Philos Trans R Soc Lond B Biol Sci. 1989; 326(1233):119-57
tree | The tree. |
Definition at line 94 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getRoot().
|
staticprivate |
Definition at line 77 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeToFather(), and bpp::AssociationTreeGraphImplObserver< class, class, class >::getSons().
|
staticprivate |
Definition at line 266 of file PhyloTreeTools.cpp.
References bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeToFather(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getSons(), bpp::AssociationTreeGraphImplObserver< class, class, class >::isLeaf(), bpp::PhyloTreeTools::Moments_::N, bpp::PhyloTreeTools::Moments_::squaredSum, and bpp::PhyloTreeTools::Moments_::sum.
|
static |
Bootstrap tag.
Definition at line 146 of file PhyloTreeTools.h.