scale_tree: Scale a coancestry tree

View source: R/scale_tree.R

scale_treeR Documentation

Scale a coancestry tree

Description

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.

Usage

scale_tree(tree, factor)

Arguments

tree

The coancestry tree to edit. Must be a phylo object from the ape package.

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.

Details

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

Value

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.

See Also

ape::read.tree() for reading phylo objects and their definition.

tree_additive() for difference between IBD and additive edges.

Examples

# create a random tree
library(ape)
k <- 5
tree <- rtree( k )

# scale this tree
tree_scaled <- scale_tree( tree, 0.5 )


StoreyLab/bnpsd documentation built on July 29, 2023, 3:31 a.m.