Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: TreeTools
Title: Create, Modify and Analyse Phylogenetic Trees
Version: 2.1.0
Version: 2.1.0.9000
Authors@R: c(
person("Martin R.", 'Smith', role = c("aut", "cre", "cph"),
email = "martin.smith@durham.ac.uk",
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ S3method(SortTree,phylo)
S3method(SplitImbalance,"NULL")
S3method(SplitImbalance,Splits)
S3method(SplitImbalance,phylo)
S3method(SplitInformation,Splits)
S3method(SplitInformation,numeric)
S3method(SplitInformation,phylo)
S3method(SplitsInBinaryTree,"NULL")
S3method(SplitsInBinaryTree,Splits)
S3method(SplitsInBinaryTree,default)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# TreeTools 2.1.0.9000 (2026-02-16) #

- Add Splits and phylo methods for `SplitInformation()`


# TreeTools 2.1.0 (2026-02-10) #

- Add method `RenumberTips.Splits()`.
Expand All @@ -12,6 +17,7 @@
- `MatrixToPhyDat()` gains `tipLabels` parameter.
- Document return value for `J1Index()`.


# TreeTools 2.0.0 (2025-09-23) #

## New functionality
Expand Down
20 changes: 20 additions & 0 deletions R/Information.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,29 @@ CharacterInformation <- function(tokens) {
#' @template MRS
#' @export
SplitInformation <- function(A, B = A[1]) {
UseMethod("SplitInformation")
}

#' @rdname SplitInformation
#' @export
SplitInformation.numeric <- function(A, B = A[1]) {
-(Log2TreesMatchingSplit(A, B) - Log2Unrooted.int(A + B))
}

#' @rdname SplitInformation
#' @export
SplitInformation.Splits <- function(A, B) {
nTip <- NTip(A)
tis <- TipsInSplits(A)
Log2Unrooted.int(nTip) - Log2Rooted.int(tis) - Log2Rooted.int(nTip - tis)
}

#' @rdname SplitInformation
#' @export
SplitInformation.phylo <- function(A, B) {
SplitInformation(as.Splits(A))
}

#' @rdname SplitInformation
#' @param partitionSizes Integer vector specifying the number of taxa in each
#' partition of a multi-partition split.
Expand Down
9 changes: 9 additions & 0 deletions man/SplitInformation.Rd

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

8 changes: 8 additions & 0 deletions tests/testthat/test-information.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ test_that("Trees matching splits calculated correctly", {
expect_equal(log(315/10395)/-log(2), SplitInformation(3, 5))
})

test_that("SplitInformation() handles Splits", {
t6 <- BalancedTree(6)
expect_equal(SplitInformation(t6), SplitInformation(as.Splits(t6)))
expect_equal(SplitInformation(t6), c(`8` = SplitInformation(3, 3),
`9` = SplitInformation(2, 4),
`11` = SplitInformation(4, 2)))
})

test_that("UnrootedTreesMatchingSplit() correct", {
expect_equal(NRooted(3) * NRooted(5), UnrootedTreesMatchingSplit(c(3, 5)))
expect_equal(LnRooted(30) + LnRooted(50), LnUnrootedTreesMatchingSplit(30, 50))
Expand Down