scale_tree | R Documentation |
Scale a tree in the additive scale by factor
.
This results in the coancestry matrix of this tree being scaled by the same factor.
The (non-additive) IBD edges are transformed in a non-linear fashion.
scale_tree(tree, factor)
tree |
The coancestry tree to edit.
Must be a |
factor |
The scalar factor to multiply all edges in additive scale. Must be non-negative, and not be so large that any edge exceeds 1 after scaling. |
Internally, additive edges ($edge.length.add
) are calculated using tree_additive()
if not already present, then they are all scaled, including the root edge ($root.edge
) if present, and lastly IBD edges ($edge.length
) are recalculated from the additive edges using tree_additive()
with option rev = TRUE
.
Stops if any of the edges exceed 1 before or after scaling (since these edges are IBD probabilities).
The edited tree with all edges scaled as desired. This tree will always contain (correctly scaled) additive edges in addition to the default non-additive edges.
ape::read.tree()
for reading phylo
objects and their definition.
tree_additive()
for difference between IBD and additive edges.
# create a random tree
library(ape)
k <- 5
tree <- rtree( k )
# scale this tree
tree_scaled <- scale_tree( tree, 0.5 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.