Skip to content

Commit

Permalink
Improve normalization documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ms609 committed Apr 23, 2024
1 parent 295f038 commit a455b92
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: TreeDist
Type: Package
Title: Calculate and Map Distances Between Phylogenetic Trees
Version: 2.7.0.9001
Version: 2.7.0.9002
Authors@R: c(person("Martin R.", "Smith",
email = "[email protected]",
role = c("aut", "cre", "cph", "prg"),
Expand Down
6 changes: 4 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# TreeDist 2.7.0.9001 (development)
# TreeDist 2.7.0.9002 (development)

- Fix dead links in documentation
- Improve documentation of normalization.

- Fix dead links in documentation.

- Fix `KCDiameter.multiPhylo()` for multiple trees.

Expand Down
14 changes: 10 additions & 4 deletions R/tree_distance_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,16 @@
#' for a compilation of expected values under different metrics for trees with
#' up to 200 leaves.
#'
#' Alternatively, to scale against the information content or entropy of all
#' splits in the most or least informative tree, use `normalize = `[`pmax`] or
#' [`pmin`] respectively.
#' Alternatively, use `normalize = `[`pmax`] or [`pmin`] to scale against the
#' information content or entropy of all splits in the most (`pmax`) or
#' least (`pmin`) informative tree in each pair.
#' To calculate the relative similarity against a reference tree that is known
#' to be "correct", use `normalize = SplitwiseInfo(trueTree)` (SPI, MSI) or
#' `ClusteringEntropy(trueTree)` (MCI).
#' For worked examples, see the internal function [`NormalizeInfo()`], which is
#' called from distance functions with the parameter `how = normalize`.
#' .
#'
#'
#' # Distances between large trees
#'
Expand Down Expand Up @@ -171,7 +175,9 @@
#' SharedPhylogeneticInfo(tree1, tree3) # = 0
#' MutualClusteringInfo(tree1, tree3) # > 0
#'
#' # Converting trees to Splits objects can speed up multiple comparisons
#' # Distance functions internally convert trees to Splits objects.
#' # Pre-conversion can reduce run time if the same trees will feature in
#' # multiple comparisons
#' splits1 <- TreeTools::as.Splits(tree1)
#' splits2 <- TreeTools::as.Splits(tree2)
#'
Expand Down
32 changes: 32 additions & 0 deletions R/tree_distance_utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,38 @@ CompareAll <- function(x, Func, FUN.VALUE = Func(x[[1]], x[[1]], ...),
#' independently (optional)
#' @param how Method for normalization
#' @param \dots Additional parameters to `InfoInTree()` or `how`.
#' @returns `NormalizeInfo()` returns an object corresponding to the normalized
#' values of `unnormalized`.
#' @examples
#' 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)
#'
#' @keywords internal
#' @template MRS
#' @importFrom TreeTools KeepTip TipLabels
Expand Down
35 changes: 35 additions & 0 deletions man/NormalizeInfo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions man/TreeDistance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a455b92

Please sign in to comment.