bpp-phyl3  3.0.0
bpp::PhyloTreeTools Class Reference

Generic utilitary methods dealing with trees. More...

#include <Bpp/Phyl/Tree/PhyloTreeTools.h>

+ Collaboration diagram for bpp::PhyloTreeTools:

Classes

struct  Moments_
 

Public Member Functions

 PhyloTreeTools ()
 
virtual ~PhyloTreeTools ()
 

Static Public Member Functions

static std::shared_ptr< PhyloTreebuildFromTreeTemplate (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)
 

Detailed Description

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.

See also
PhyloTree

Definition at line 34 of file PhyloTreeTools.h.

Constructor & Destructor Documentation

◆ PhyloTreeTools()

bpp::PhyloTreeTools::PhyloTreeTools ( )
inline

Definition at line 37 of file PhyloTreeTools.h.

◆ ~PhyloTreeTools()

virtual bpp::PhyloTreeTools::~PhyloTreeTools ( )
inlinevirtual

Definition at line 38 of file PhyloTreeTools.h.

Member Function Documentation

◆ bestRootPosition_()

double PhyloTreeTools::bestRootPosition_ ( const PhyloTree tree,
const std::shared_ptr< PhyloNode node1,
const std::shared_ptr< PhyloNode node2,
double  length 
)
staticprivate

◆ buildFromTreeTemplate()

◆ computeBranchLengthsGrafen() [1/2]

void PhyloTreeTools::computeBranchLengthsGrafen ( PhyloTree tree,
double  power = 1,
bool  init = true 
)
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

Parameters
treeThe tree to use.
powerThe rho parameter.
initTell 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().

◆ computeBranchLengthsGrafen() [2/2]

void PhyloTreeTools::computeBranchLengthsGrafen ( PhyloTree tree,
std::shared_ptr< PhyloNode node,
double  power,
double  total,
double &  height,
double &  heightRaised 
)
staticprivate

◆ constrainedMidPointRooting()

void PhyloTreeTools::constrainedMidPointRooting ( PhyloTree tree)
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).

Parameters
treeThe 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().

◆ convertToClockTree()

double PhyloTreeTools::convertToClockTree ( PhyloTree tree,
std::shared_ptr< PhyloNode node 
)
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.

Parameters
treeThe tree to use.
nodeThe node defining the subtree.
Returns
The modified height of the node.

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().

◆ convertToClockTree2()

double PhyloTreeTools::convertToClockTree2 ( PhyloTree tree,
std::shared_ptr< PhyloNode node 
)
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.

Parameters
treeThe tree to use.
nodeThe node defining the subtree.
Returns
The modified height of the node.

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().

◆ getHeight()

double PhyloTreeTools::getHeight ( const PhyloTree tree,
const std::shared_ptr< PhyloNode node 
)
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.

Parameters
treeThe tree.
nodeThe node defining the subtree.
Returns
The height of 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().

◆ initBranchLengthsGrafen() [1/2]

void PhyloTreeTools::initBranchLengthsGrafen ( PhyloTree tree)
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

Parameters
treeThe tree.

Definition at line 94 of file PhyloTreeTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getRoot().

◆ initBranchLengthsGrafen() [2/2]

size_t PhyloTreeTools::initBranchLengthsGrafen ( PhyloTree tree,
std::shared_ptr< PhyloNode node 
)
staticprivate

◆ statFromNode_()

Member Data Documentation

◆ BOOTSTRAP

const string PhyloTreeTools::BOOTSTRAP = "bootstrap"
static

Bootstrap tag.

Definition at line 146 of file PhyloTreeTools.h.


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