View source: R/tree_distance_utilities.R
NormalizeInfo | R Documentation |
NormalizeInfo()
is an internal function used to normalize information
against a reference, such as the total information present in a pair of
trees.
NormalizeInfo(
unnormalized,
tree1,
tree2,
InfoInTree,
infoInBoth = NULL,
how = TRUE,
Combine = "+",
...
)
unnormalized |
Numeric value, vector or matrix to be normalized. |
tree1 , tree2 |
Trees from which |
InfoInTree |
Function to calculate the information content of each tree. |
infoInBoth |
Optional numeric specifying information content of both
trees independently. If unspecified ( |
how |
Method for normalization, perhaps specified using the |
... |
Additional parameters to |
The unnormalized value(s) are normalized by dividing by a denominator
calculated based on the how
parameter. Valid options include:
FALSE
No normalization is performed; the unnormalized values are returned.
TRUE
Unless infoInBoth
is specified, the information in
each tree is computed using InfoInTree()
, and the two values combined
using Combine()
.
how
is used as the denominator;
the returned value is unnormalized / how
.
Unless infoInBoth
is specified, the information in
each tree is computed using InfoInTree()
, and the two values combined
using how
. NormalizeInfo(how = Func)
is thus equivalent to
NormalizeInfo(how = TRUE, Combine = Func)
.
NormalizeInfo()
returns an object corresponding to the normalized
values of unnormalized
.
Martin R. Smith (martin.smith@durham.ac.uk)
library("TreeTools", quietly = TRUE)
pair1 <- c(BalancedTree(9), StarTree(9))
pair2 <- c(BalancedTree(9), PectinateTree(9))
# We'll let the number of nodes define the total information in a tree
Nnode(pair1)
Nnode(pair2)
# Let's normalize a unit distance
rawDist <- cbind(c(1, 1), c(1, 1))
# With `Combine = "+"`, the maximum distance is the sum of
# the information in each tree
denominator <- outer(Nnode(pair1), Nnode(pair2), "+")
NormalizeInfo(rawDist, pair1, pair2, InfoInTree = ape::Nnode, Combine = "+")
rawDist / denominator
# A denominator can be specified manually using `how`:
NormalizeInfo(rawDist, pair1, pair2, InfoInTree = ape::Nnode, how = 16)
rawDist / 16
# `how` also allows the denominator to be computed from trees:
outer(Nnode(pair1), Nnode(pair2), pmin)
NormalizeInfo(rawDist, pair1, pair2, InfoInTree = ape::Nnode, how = pmin)
rawDist / outer(Nnode(pair1), Nnode(pair2), pmin)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.