makePhylo3DBalanced {treeDbalance} | R Documentation |
Turn a rooted 3D tree into one of its balanced versions
Description
makePhylo3DBalanced
- Creates a balanced version of a rooted 3D tree
in phylo3D format. From the leaves of lowest depth to the root, each node
is turned into a balanced node by rotating its pending subtree such that
it is in line with its incoming edge. The edge and subtree lengths and
weights as well as the angles between the outgoing edges of a single node
(the sister edges) are left intact.
Note that this function yields only one of many possible balanced
version of the given rooted 3D tree (most often the minimal tree under the
aforementioned requirements is not unique).
rotate3dVec
- Rotates a vector in 3D space for a given angle and
rotation axis.
Usage
makePhylo3DBalanced(tree)
rotate3dVec(angle, axis, vec)
Arguments
tree |
A rooted tree in phylo3D format (no special node enumeration required, except that nodes are numbered from 1 to |V| = the total number of nodes). There must be at least 2 nodes, i.e., one edge. The attributes 'node.coord' and 'edge.weight' are strictly required. |
angle |
Angle for the rotation. |
axis |
Rotation axis. |
vec |
Numeric vector of size 3 (3D coordinates of the vector that shall be rotated). |
Value
makePhylo3DBalanced
Tree in phylo3D format which is balanced
with regards to all four node imbalance measurements and their
corresponding imbalance indices.
rotate3dVec
Numeric vector of size 3 (3D coordinates of the
rotated vector).
Author(s)
Sophie Kersting, Luise Kühn
Examples
tree <- treeDbalance::extendPhylo(treeDbalance::example3Dtrees$bean22)
tree_bal <- makePhylo3DBalanced(tree)
rotate3dVec(angle = pi/2, axis = c(0,-1,0), vec = c(5,0,0)) # approx. (0,0,5)
round(rotate3dVec(angle = pi/2, axis = c(0,-1,0), vec = c(5,0,0)),15)