From 629a2c1eb681985ab7dc7a2d7d9f96b1a4e69d0d Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 09:24:25 +0000
Subject: [PATCH 01/26] 9006: Statement of intent (#179)
---
DESCRIPTION | 2 +-
NEWS.md | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index bf99b9165..929fe0c13 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: TreeSearch
Title: Phylogenetic Analysis with Discrete Character Data
-Version: 1.5.1.9005
+Version: 1.5.1.9006
Authors@R: c(
person(
"Martin R.", 'Smith',
diff --git a/NEWS.md b/NEWS.md
index 4b8fa9af3..e598f405d 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,8 @@
+# TreeSearch 1.5.1.9006 (2025-02)
+
+- `PlotCharacter()` performs ancestral state reconstruction on consensus trees
+ [#179](https://github.com/ms609/TreeSearch/issues/179)
+
# TreeSearch 1.5.1.9005 (2025-02)
- Support for ordered (additive) characters
From 54dd0bee91ef0d26bbcca3e964ff0aa15be1550e Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 09:31:33 +0000
Subject: [PATCH 02/26] Register methods
---
NAMESPACE | 3 ++
R/PlotCharacter.R | 68 ++++++++++++++++++++++-------
man/PlotCharacter.Rd | 54 +++++++++++++++++++++++
tests/testthat/test-PlotCharacter.R | 7 ++-
4 files changed, 116 insertions(+), 16 deletions(-)
diff --git a/NAMESPACE b/NAMESPACE
index 98ce38262..106976d6e 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -6,6 +6,9 @@ S3method(MaximumLength,phyDat)
S3method(MinimumLength,character)
S3method(MinimumLength,numeric)
S3method(MinimumLength,phyDat)
+S3method(PlotCharacter,list)
+S3method(PlotCharacter,multiPhylo)
+S3method(PlotCharacter,phylo)
S3method(SPRMoves,matrix)
S3method(SPRMoves,phylo)
S3method(TBRMoves,matrix)
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index 8eae2fdb7..89606ae98 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -48,21 +48,31 @@
#' @importFrom graphics par
#' @importFrom TreeTools PostorderOrder
#' @export
-PlotCharacter <- function (tree, dataset, char = 1L,
- updateTips = FALSE,
- plot = TRUE,
-
- tokenCol = NULL,
- ambigCol = "grey",
- inappCol = "lightgrey",
-
- ambigLty = "dotted",
- inappLty = "dashed",
- plainLty = par("lty"),
-
- tipOffset = 1,
- unitEdge = FALSE,
- ...) {
+PlotCharacter <- function(tree, dataset, char = 1L,
+ updateTips = FALSE,
+ plot = TRUE,
+
+ tokenCol = NULL,
+ ambigCol = "grey",
+ inappCol = "lightgrey",
+
+ ambigLty = "dotted",
+ inappLty = "dashed",
+ plainLty = par("lty"),
+
+ tipOffset = 1,
+ unitEdge = FALSE,
+ ...
+) {
+ UseMethod("PlotCharacter")
+}
+
+#' @rdname PlotCharacter
+#' @export
+PlotCharacter.phylo <- function(tree, dataset, char, updateTips, plot,
+ tokenCol, ambigCol, inappCol,
+ ambigLty, inappLty, plainLty,
+ tipOffset, unitEdge, ...) {
# Reconcile labels
datasetTaxa <- names(dataset)
@@ -399,3 +409,31 @@ PlotCharacter <- function (tree, dataset, char = 1L,
# Return:
invisible(slimState)
}
+
+
+#' @rdname PlotCharacter
+#' @export
+PlotCharacter.multiPhylo <- function(tree, dataset, char, updateTips, plot,
+ tokenCol, ambigCol, inappCol,
+ ambigLty, inappLty, plainLty,
+ tipOffset, unitEdge, ...) {
+ reconstructions <- lapply(tree, PlotCharacter, dataset = dataset, char = char,
+ updateTips = updateTips, plot = FALSE, ...)
+
+}
+
+#' @rdname PlotCharacter
+#' @export
+PlotCharacter.list <- function(tree, dataset, char, updateTips, plot,
+ tokenCol, ambigCol, inappCol,
+ ambigLty, inappLty, plainLty,
+ tipOffset, unitEdge, ...) {
+ if (all(vapply(tree, inherits, logical(1), "phylo"))) {
+ PlotCharacter.multiPhylo(tree, dataset, char, updateTips, plot,
+ tokenCol, ambigCol, inappCol,
+ ambigLty, inappLty, plainLty,
+ tipOffset, unitEdge, ...)
+ } else {
+ stop("Elements of `tree` must be of class `phylo`")
+ }
+}
diff --git a/man/PlotCharacter.Rd b/man/PlotCharacter.Rd
index 094859f81..65e7c6155 100644
--- a/man/PlotCharacter.Rd
+++ b/man/PlotCharacter.Rd
@@ -2,6 +2,9 @@
% Please edit documentation in R/PlotCharacter.R
\name{PlotCharacter}
\alias{PlotCharacter}
+\alias{PlotCharacter.phylo}
+\alias{PlotCharacter.multiPhylo}
+\alias{PlotCharacter.list}
\title{Plot the distribution of a character on a tree}
\usage{
PlotCharacter(
@@ -20,6 +23,57 @@ PlotCharacter(
unitEdge = FALSE,
...
)
+
+\method{PlotCharacter}{phylo}(
+ tree,
+ dataset,
+ char,
+ updateTips,
+ plot,
+ tokenCol,
+ ambigCol,
+ inappCol,
+ ambigLty,
+ inappLty,
+ plainLty,
+ tipOffset,
+ unitEdge,
+ ...
+)
+
+\method{PlotCharacter}{multiPhylo}(
+ tree,
+ dataset,
+ char,
+ updateTips,
+ plot,
+ tokenCol,
+ ambigCol,
+ inappCol,
+ ambigLty,
+ inappLty,
+ plainLty,
+ tipOffset,
+ unitEdge,
+ ...
+)
+
+\method{PlotCharacter}{list}(
+ tree,
+ dataset,
+ char,
+ updateTips,
+ plot,
+ tokenCol,
+ ambigCol,
+ inappCol,
+ ambigLty,
+ inappLty,
+ plainLty,
+ tipOffset,
+ unitEdge,
+ ...
+)
}
\arguments{
\item{tree}{A tree of class \code{\link{phylo}}.}
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index 90cb6e223..4e8e425f0 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -1,4 +1,4 @@
-test_that("PlotCharacter()", {
+test_that("PlotCharacter.phylo()", {
dataset <- TreeTools::StringToPhyDat("1111 1111 0000", tips = 12)
expect_error(PlotCharacter(TreeTools::BalancedTree(14), dataset),
@@ -131,3 +131,8 @@ test_that("Out-of-sequence works", {
)}
)
})
+
+test_that("PlotCharacter.multi()", {
+ expect_error(PlotCharacter(list(BalancedTree(8), 9), "dataset"),
+ "class `phylo`")
+})
From 5dbc2cf9b0927c26d077fc52c40e59df10911945 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 09:41:53 +0000
Subject: [PATCH 03/26] Document intent
and err accordingly
---
R/PlotCharacter.R | 69 +++++++++++++++++++++++------
tests/testthat/test-PlotCharacter.R | 2 +
2 files changed, 58 insertions(+), 13 deletions(-)
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index 89606ae98..096c350de 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -4,7 +4,8 @@
#' modified Fitch algorithm presented in
#' \insertCite{Brazeau2019;textual}{TreeSearch}.
#'
-#' @template treeParam
+#' @param tree A bifurcating tree of class `phylo`, or a list or `multiPhylo`
+#' object containing such trees.
#' @template datasetParam
#' @param char Index of character to plot.
#' @param updateTips Logical; if `FALSE`, tips will be labelled with their
@@ -23,6 +24,9 @@
#' corresponds to a numbered tip or node of `tree`, and each column corresponds
#' to a token; the tokens that might parsimoniously be present at each point
#' on a tree are denoted with `TRUE`.
+#' If multiple trees are supplied, the strict consensus of all trees and
+#' reconstructions will be returned; i.e. if a node is reconstructed as $0$
+#' in one tree, and $2$ in another, it will be labelled $(02)$.
#'
#' @references
#' \insertAllCited{}
@@ -69,10 +73,22 @@ PlotCharacter <- function(tree, dataset, char = 1L,
#' @rdname PlotCharacter
#' @export
-PlotCharacter.phylo <- function(tree, dataset, char, updateTips, plot,
- tokenCol, ambigCol, inappCol,
- ambigLty, inappLty, plainLty,
- tipOffset, unitEdge, ...) {
+PlotCharacter.phylo <- function(tree, dataset, char = 1L,
+ updateTips = FALSE,
+ plot = TRUE,
+
+ tokenCol = NULL,
+ ambigCol = "grey",
+ inappCol = "lightgrey",
+
+ ambigLty = "dotted",
+ inappLty = "dashed",
+ plainLty = par("lty"),
+
+ tipOffset = 1,
+ unitEdge = FALSE,
+ ...
+) {
# Reconcile labels
datasetTaxa <- names(dataset)
@@ -91,6 +107,9 @@ PlotCharacter.phylo <- function(tree, dataset, char, updateTips, plot,
}
nNode <- tree[["Nnode"]]
nTip <- NTip(tree)
+ if (nNode == 2 * nTip - 1) {
+ stop("`tree` must be bifurcating. Try TreeTools::MakeTreeBinary(tree).")
+ }
edge <- tree[["edge"]][postorder, ]
parent <- edge[, 1]
child <- edge[, 2]
@@ -413,10 +432,22 @@ PlotCharacter.phylo <- function(tree, dataset, char, updateTips, plot,
#' @rdname PlotCharacter
#' @export
-PlotCharacter.multiPhylo <- function(tree, dataset, char, updateTips, plot,
- tokenCol, ambigCol, inappCol,
- ambigLty, inappLty, plainLty,
- tipOffset, unitEdge, ...) {
+PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
+ updateTips = FALSE,
+ plot = TRUE,
+
+ tokenCol = NULL,
+ ambigCol = "grey",
+ inappCol = "lightgrey",
+
+ ambigLty = "dotted",
+ inappLty = "dashed",
+ plainLty = par("lty"),
+
+ tipOffset = 1,
+ unitEdge = FALSE,
+ ...
+) {
reconstructions <- lapply(tree, PlotCharacter, dataset = dataset, char = char,
updateTips = updateTips, plot = FALSE, ...)
@@ -424,10 +455,22 @@ PlotCharacter.multiPhylo <- function(tree, dataset, char, updateTips, plot,
#' @rdname PlotCharacter
#' @export
-PlotCharacter.list <- function(tree, dataset, char, updateTips, plot,
- tokenCol, ambigCol, inappCol,
- ambigLty, inappLty, plainLty,
- tipOffset, unitEdge, ...) {
+PlotCharacter.list <- function(tree, dataset, char = 1L,
+ updateTips = FALSE,
+ plot = TRUE,
+
+ tokenCol = NULL,
+ ambigCol = "grey",
+ inappCol = "lightgrey",
+
+ ambigLty = "dotted",
+ inappLty = "dashed",
+ plainLty = par("lty"),
+
+ tipOffset = 1,
+ unitEdge = FALSE,
+ ...
+) {
if (all(vapply(tree, inherits, logical(1), "phylo"))) {
PlotCharacter.multiPhylo(tree, dataset, char, updateTips, plot,
tokenCol, ambigCol, inappCol,
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index 4e8e425f0..bacfbdfe2 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -3,6 +3,8 @@ test_that("PlotCharacter.phylo()", {
dataset <- TreeTools::StringToPhyDat("1111 1111 0000", tips = 12)
expect_error(PlotCharacter(TreeTools::BalancedTree(14), dataset),
"Taxa in tree missing from dataset:\\s*t13, t14$")
+ expect_error(PlotCharacter(TreeTools::StarTree(12), dataset),
+ "bifurcating")
Character <- function (str, plot = FALSE, edges = FALSE, ...) {
tree <- ape::read.tree(text =
From 573e6906fc9a686d5df47ba162256bf30ca73679 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 09:42:07 +0000
Subject: [PATCH 04/26] Update SiteConcordance.Rd
---
man/SiteConcordance.Rd | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/man/SiteConcordance.Rd b/man/SiteConcordance.Rd
index 85e38d090..fc78c6792 100644
--- a/man/SiteConcordance.Rd
+++ b/man/SiteConcordance.Rd
@@ -23,7 +23,8 @@ SharedPhylogeneticConcordance(tree, dataset)
\item{tree}{A tree of class \code{\link{phylo}}.}
\item{dataset}{A phylogenetic data matrix of \pkg{phangorn} class
-\code{phyDat}, whose names correspond to the labels of any accompanying tree.}
+\code{phyDat}, whose names correspond to the labels of any accompanying tree.
+Perhaps load into R using \code{\link[TreeTools]{ReadCharacters}}.}
\item{weight}{Logical specifying whether to weight sites according to the
number of quartets they are decisive for.}
From c00cb3785d5fe4537fc5ee717facfc34a61abd83 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 09:45:24 +0000
Subject: [PATCH 05/26] tests
---
R/PlotCharacter.R | 2 +-
man/PlotCharacter.Rd | 72 +++++++++++++++--------------
tests/testthat/test-PlotCharacter.R | 2 +-
3 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index 096c350de..2780a445f 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -107,7 +107,7 @@ PlotCharacter.phylo <- function(tree, dataset, char = 1L,
}
nNode <- tree[["Nnode"]]
nTip <- NTip(tree)
- if (nNode == 2 * nTip - 1) {
+ if (nNode != nTip - 1) {
stop("`tree` must be bifurcating. Try TreeTools::MakeTreeBinary(tree).")
}
edge <- tree[["edge"]][postorder, ]
diff --git a/man/PlotCharacter.Rd b/man/PlotCharacter.Rd
index 65e7c6155..48652e11b 100644
--- a/man/PlotCharacter.Rd
+++ b/man/PlotCharacter.Rd
@@ -27,56 +27,57 @@ PlotCharacter(
\method{PlotCharacter}{phylo}(
tree,
dataset,
- char,
- updateTips,
- plot,
- tokenCol,
- ambigCol,
- inappCol,
- ambigLty,
- inappLty,
- plainLty,
- tipOffset,
- unitEdge,
+ char = 1L,
+ updateTips = FALSE,
+ plot = TRUE,
+ tokenCol = NULL,
+ ambigCol = "grey",
+ inappCol = "lightgrey",
+ ambigLty = "dotted",
+ inappLty = "dashed",
+ plainLty = par("lty"),
+ tipOffset = 1,
+ unitEdge = FALSE,
...
)
\method{PlotCharacter}{multiPhylo}(
tree,
dataset,
- char,
- updateTips,
- plot,
- tokenCol,
- ambigCol,
- inappCol,
- ambigLty,
- inappLty,
- plainLty,
- tipOffset,
- unitEdge,
+ char = 1L,
+ updateTips = FALSE,
+ plot = TRUE,
+ tokenCol = NULL,
+ ambigCol = "grey",
+ inappCol = "lightgrey",
+ ambigLty = "dotted",
+ inappLty = "dashed",
+ plainLty = par("lty"),
+ tipOffset = 1,
+ unitEdge = FALSE,
...
)
\method{PlotCharacter}{list}(
tree,
dataset,
- char,
- updateTips,
- plot,
- tokenCol,
- ambigCol,
- inappCol,
- ambigLty,
- inappLty,
- plainLty,
- tipOffset,
- unitEdge,
+ char = 1L,
+ updateTips = FALSE,
+ plot = TRUE,
+ tokenCol = NULL,
+ ambigCol = "grey",
+ inappCol = "lightgrey",
+ ambigLty = "dotted",
+ inappLty = "dashed",
+ plainLty = par("lty"),
+ tipOffset = 1,
+ unitEdge = FALSE,
...
)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A bifurcating tree of class \code{phylo}, or a list or \code{multiPhylo}
+object containing such trees.}
\item{dataset}{A phylogenetic data matrix of \pkg{phangorn} class
\code{phyDat}, whose names correspond to the labels of any accompanying tree.
@@ -107,6 +108,9 @@ to apply to ambiguous, inapplicable and applicable tokens. See the \code{lty}
corresponds to a numbered tip or node of \code{tree}, and each column corresponds
to a token; the tokens that might parsimoniously be present at each point
on a tree are denoted with \code{TRUE}.
+If multiple trees are supplied, the strict consensus of all trees and
+reconstructions will be returned; i.e. if a node is reconstructed as $0$
+in one tree, and $2$ in another, it will be labelled $(02)$.
}
\description{
Reconstructs the distribution of a character on a tree topology using the
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index bacfbdfe2..43ee91302 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -135,6 +135,6 @@ test_that("Out-of-sequence works", {
})
test_that("PlotCharacter.multi()", {
- expect_error(PlotCharacter(list(BalancedTree(8), 9), "dataset"),
+ expect_error(PlotCharacter(list(ape::rtree(8), 9), "dataset"),
"class `phylo`")
})
From 288cb2dfa76529744b16a3a5c606dda2a562d13e Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 10:22:26 +0000
Subject: [PATCH 06/26] Plotting (incorrectly)
---
NAMESPACE | 1 +
R/PlotCharacter.R | 180 ++++++++++++++++++----------
tests/testthat/test-PlotCharacter.R | 23 +++-
3 files changed, 138 insertions(+), 66 deletions(-)
diff --git a/NAMESPACE b/NAMESPACE
index 106976d6e..5353326a8 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -143,6 +143,7 @@ importFrom(TreeTools,AddUnconstrained)
importFrom(TreeTools,CharacterInformation)
importFrom(TreeTools,CladisticInfo)
importFrom(TreeTools,CompatibleSplits)
+importFrom(TreeTools,Consensus)
importFrom(TreeTools,ConstrainedNJ)
importFrom(TreeTools,DescendantEdges)
importFrom(TreeTools,DoubleFactorial)
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index 2780a445f..675666931 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -375,82 +375,134 @@ PlotCharacter.phylo <- function(tree, dataset, char = 1L,
}
anywhere <- as.logical(colSums(state[hasToken, , drop = FALSE]))
slimState <- state[, anywhere, drop = FALSE]
- if (plot) {
- tokens <- colnames(slimState)
- if (is.null(tokenCol)) {
- tokenCol <- tokens
- tokenCol[tokens != "-"] <- c("#00bfc6",
- "#ffd46f",
- "#ffbcc5",
- "#c8a500",
- "#ffcaf5",
- "#d5fb8d",
- "#e082b4",
- "#25ffd3",
- "#a6aaff",
- "#e6f3cc",
- "#67c4ff",
- "#9ba75c",
- "#60b17f")[seq_along(setdiff(tokens, "-"))]
- tokenCol[tokens == "-"] <- inappCol
- }
- nodeStyle <- apply(slimState, 1, function (tkn) {
- if (length(tkn) == 0) {
- c(col = ambigCol, lty = ambigLty)
- } else if (sum(tkn) > 1L) {
- c(col = ambigCol, lty = ambigLty)
- } else {
- c(col = tokenCol[tkn],
- lty = ifelse(tokens[tkn] == "-", inappLty, plainLty))
- }
- })
- if (unitEdge) {
- tree[["edge.length"]] <- rep_len(1, dim(tree[["edge"]])[1])
- }
- plot.phylo(tree,
- node.color = nodeStyle["col", , drop = FALSE],
- node.lty = nodeStyle["lty", , drop = FALSE],
- label.offset = tipOffset,
- ...)
-
- NodeText <- function (n) {
- if (length(n) == 0 || (
- sum(n) > 1L && all(n[anywhere & names(n) != "-"]))) {
- "?"
- } else {
- paste0(levels[n], collapse = "")
- }
- }
- nodelabels(apply(state, 1, NodeText),
- seq_len(nTip + nNode), bg = nodeStyle["col", , drop = FALSE])
+
+ if (isTRUE(plot)) {
+ .PlotCharacter(tree, nTip, state, levels, tokenCol, ambigCol, inappCol,
+ ambigLty, inappLty, plainLty, tipOffset, unitEdge, ...)
}
# Return:
invisible(slimState)
}
+.PlotCharacter <- function(tree, nTip, state, tokens,
+ tokenCol, ambigCol, inappCol,
+ ambigLty, inappLty, plainLty,
+ tipOffset, unitEdge, ...) {
+ tokens <- colnames(state)
+
+ hasToken <- if (length(setdiff(colnames(state), "-")) > 1L) {
+ as.logical(rowSums(!state[, colnames(state) != "-", drop = FALSE]))
+ } else {
+ !logical(nrow(state))
+ }
+ anywhere <- as.logical(colSums(state[hasToken, , drop = FALSE]))
+ slimState <- state[, anywhere, drop = FALSE]
+
+ if (is.null(tokenCol)) {
+ tokenCol <- tokens
+ tokenCol[tokens != "-"] <- c("#00bfc6",
+ "#ffd46f",
+ "#ffbcc5",
+ "#c8a500",
+ "#ffcaf5",
+ "#d5fb8d",
+ "#e082b4",
+ "#25ffd3",
+ "#a6aaff",
+ "#e6f3cc",
+ "#67c4ff",
+ "#9ba75c",
+ "#60b17f")[seq_along(setdiff(tokens, "-"))]
+ tokenCol[tokens == "-"] <- inappCol
+ }
+ nodeStyle <- apply(state, 1, function (tkn) {
+ if (length(tkn) == 0) {
+ c(col = ambigCol, lty = ambigLty)
+ } else if (sum(tkn) > 1L) {
+ c(col = ambigCol, lty = ambigLty)
+ } else {
+ c(col = tokenCol[tkn],
+ lty = ifelse(tokens[tkn] == "-", inappLty, plainLty))
+ }
+ })
+ if (unitEdge) {
+ tree[["edge.length"]] <- rep_len(1, dim(tree[["edge"]])[1])
+ }
+ plot.phylo(tree,
+ node.color = nodeStyle["col", , drop = FALSE],
+ node.lty = nodeStyle["lty", , drop = FALSE],
+ label.offset = tipOffset,
+ ...)
+
+ .NodeText <- function (n) {
+ if (length(n) == 0 || (
+ sum(n) > 1L && all(n[anywhere & names(n) != "-"]))) {
+ "?"
+ } else {
+ paste0(tokens[n], collapse = "")
+ }
+ }
+ nodelabels(apply(state, 1, .NodeText),
+ seq_len(nTip + tree[["Nnode"]]),
+ bg = nodeStyle["col", , drop = FALSE])
+}
#' @rdname PlotCharacter
+#' @importFrom TreeTools as.Splits Consensus
#' @export
PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
- updateTips = FALSE,
- plot = TRUE,
-
- tokenCol = NULL,
- ambigCol = "grey",
- inappCol = "lightgrey",
-
- ambigLty = "dotted",
- inappLty = "dashed",
- plainLty = par("lty"),
-
- tipOffset = 1,
- unitEdge = FALSE,
- ...
-) {
- reconstructions <- lapply(tree, PlotCharacter, dataset = dataset, char = char,
+ updateTips = FALSE,
+ plot = TRUE,
+
+ tokenCol = NULL,
+ ambigCol = "grey",
+ inappCol = "lightgrey",
+
+ ambigLty = "dotted",
+ inappLty = "dashed",
+ plainLty = par("lty"),
+
+ tipOffset = 1,
+ unitEdge = FALSE,
+ ...) {
+
+ if (length(tree) == 1) {
+ return(PlotCharacter(tree[[1]], dataset, char, updateTips, plot,
+ tokenCol, ambigCol, inappCol,
+ ambigLty, inappLty, plainLty,
+ tipOffset, unitEdge, ...))
+ }
+
+ tipLabels <- unique(lapply(lapply(tree, TipLabels), sort))
+ if (length(tipLabels) != 1) {
+ stop("All trees must have the same tip labels")
+ }
+ tipLabels <- tipLabels[[1]]
+ nTip <- length(tipLabels)
+ tokens <- attr(dataset, "levels")
+ reconstructions <- vapply(tree, PlotCharacter,
+ matrix(FALSE, nTip * 2 - 1, length(tokens)),
+ dataset = dataset, char = char,
updateTips = updateTips, plot = FALSE, ...)
+ consTree <- Consensus(tree, p = 1, check.labels = FALSE)
+ consSplits <- as.Splits(consTree)
+ splits <- as.Splits(trees)
+ .Recon <- function(i) {
+ reconstructions[
+ c(seq_len(nTip), nTip + match(consSplits, splits[[i]])), , 1]
+ }
+ recon <- .Recon(1)
+ for (i in seq_along(trees)[-1]) {
+ recon <- recon | .Recon(i)
+ }
+
+ if (isTRUE(plot)) {
+ .PlotCharacter(consTree, nTip, recon, tokens, tokenCol, ambigCol, inappCol,
+ ambigLty, inappLty, plainLty, tipOffset, unitEdge, ...)
+ }
+ invisible(recon)
}
#' @rdname PlotCharacter
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index 43ee91302..5ffaaf62a 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -135,6 +135,25 @@ test_that("Out-of-sequence works", {
})
test_that("PlotCharacter.multi()", {
- expect_error(PlotCharacter(list(ape::rtree(8), 9), "dataset"),
- "class `phylo`")
+ Bal <- TreeTools::BalancedTree
+ expect_error(PlotCharacter(list(Bal(8), 9), "dataset"), "class `phylo`")
+ expect_error(PlotCharacter(list(Bal(8), Bal(9)), "dataset"),
+ "same tip labels")
+ expect_error(PlotCharacter(list(Bal(8), Bal(letters[1:8])), "dataset"),
+ "same tip labels")
+
+ trees <- ape::read.tree(text = c("(a, (b, (c, (d, ((e, f), (g, h))))));",
+ "(a, (b, (c, ((d, e), (f, (g, h))))));"))
+
+
+ str <- "00011011"
+ dat <- TreeTools::StringToPhyDat(str, tips = letters[1:8])
+ expect_equal(PlotCharacter(trees[1], dat, plot = FALSE),
+ PlotCharacter(trees[[1]], dat, plot = FALSE))
+
+
+ PlotCharacter(trees[[1]], dat)
+ PlotCharacter(trees[[2]], dat)
+ PlotCharacter(trees, dat)
+
})
From 8eebb5eb3ab38b48315c0ccf7a8ba5b103abe905 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 10:55:37 +0000
Subject: [PATCH 07/26] Simple case working
---
NAMESPACE | 1 +
R/PlotCharacter.R | 17 ++++++++++++-----
tests/testthat/test-PlotCharacter.R | 14 ++++++++++----
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/NAMESPACE b/NAMESPACE
index 5353326a8..4c658dfc7 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -146,6 +146,7 @@ importFrom(TreeTools,CompatibleSplits)
importFrom(TreeTools,Consensus)
importFrom(TreeTools,ConstrainedNJ)
importFrom(TreeTools,DescendantEdges)
+importFrom(TreeTools,DescendantTips)
importFrom(TreeTools,DoubleFactorial)
importFrom(TreeTools,DropTip)
importFrom(TreeTools,EdgeAncestry)
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index 675666931..0b08c8e64 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -449,7 +449,7 @@ PlotCharacter.phylo <- function(tree, dataset, char = 1L,
}
#' @rdname PlotCharacter
-#' @importFrom TreeTools as.Splits Consensus
+#' @importFrom TreeTools as.Splits Consensus DescendantTips TipLabels
#' @export
PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
updateTips = FALSE,
@@ -486,11 +486,18 @@ PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
dataset = dataset, char = char,
updateTips = updateTips, plot = FALSE, ...)
consTree <- Consensus(tree, p = 1, check.labels = FALSE)
- consSplits <- as.Splits(consTree)
- splits <- as.Splits(trees)
+ .TreeClades <- function(tr) {
+ ed <- tr[["edge"]]
+ lab <- TipLabels(tr)
+ apply(DescendantTips(ed[, 1], ed[, 2],
+ node = seq_len(nTip + tr[["Nnode"]])),
+ 1, function (tips) {
+ paste0(sort(lab[tips]), collapse = " @||@ ")
+ })
+ }
+ consClades <- .TreeClades(consTree)
.Recon <- function(i) {
- reconstructions[
- c(seq_len(nTip), nTip + match(consSplits, splits[[i]])), , 1]
+ reconstructions[match(consClades, .TreeClades(tree[[i]])), , i]
}
recon <- .Recon(1)
for (i in seq_along(trees)[-1]) {
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index 5ffaaf62a..92ea551fd 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -142,7 +142,7 @@ test_that("PlotCharacter.multi()", {
expect_error(PlotCharacter(list(Bal(8), Bal(letters[1:8])), "dataset"),
"same tip labels")
- trees <- ape::read.tree(text = c("(a, (b, (c, (d, ((e, f), (g, h))))));",
+ trees <- ape::read.tree(text = c("(a, (b, (c, (d, ((g, h), (e, f))))));",
"(a, (b, (c, ((d, e), (f, (g, h))))));"))
@@ -152,8 +152,14 @@ test_that("PlotCharacter.multi()", {
PlotCharacter(trees[[1]], dat, plot = FALSE))
- PlotCharacter(trees[[1]], dat)
- PlotCharacter(trees[[2]], dat)
- PlotCharacter(trees, dat)
+ state1 <- PlotCharacter(trees[[1]], dat, plot = FALSE)
+ state2 <- PlotCharacter(trees[[2]], dat, plot = FALSE)
+ stateCons <- PlotCharacter(trees, dat, plot = FALSE)
+ expect_equal(stateCons, state1[-(13:14), ] | state2[-(13:14), ])
+ skip_if_not_installed("vdiffr")
+ vdiffr::expect_doppelganger("PlotChar_consensus", function () {
+ PlotCharacter(trees, dat, plot = FALSE)
+ }
+ )
})
From 053c5b37e5a12c0e7d598238952061ab34f3a699 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 11:04:57 +0000
Subject: [PATCH 08/26] Check labels
---
R/PlotCharacter.R | 3 ++-
tests/testthat/test-PlotCharacter.R | 12 +++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index 0b08c8e64..dd54d5fe2 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -485,7 +485,8 @@ PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
matrix(FALSE, nTip * 2 - 1, length(tokens)),
dataset = dataset, char = char,
updateTips = updateTips, plot = FALSE, ...)
- consTree <- Consensus(tree, p = 1, check.labels = FALSE)
+ # Check labels: definitely identical, possibly in different sequence
+ consTree <- Consensus(tree, p = 1, check.labels = TRUE)
.TreeClades <- function(tr) {
ed <- tr[["edge"]]
lab <- TipLabels(tr)
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index 92ea551fd..b7346a8ee 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -152,14 +152,16 @@ test_that("PlotCharacter.multi()", {
PlotCharacter(trees[[1]], dat, plot = FALSE))
- state1 <- PlotCharacter(trees[[1]], dat, plot = FALSE)
- state2 <- PlotCharacter(trees[[2]], dat, plot = FALSE)
- stateCons <- PlotCharacter(trees, dat, plot = FALSE)
- expect_equal(stateCons, state1[-(13:14), ] | state2[-(13:14), ])
+ state1 <- PlotCharacter(trees[[1]], dat)
+ state2 <- PlotCharacter(trees[[2]], dat)
+ stateCons <- PlotCharacter(trees, dat)
+ expect_equal(stateCons, state1[-c(13, 15), ] |
+ state2[c(match(TipLabels(trees[[1]]), TipLabels(trees[[2]])),
+ 9:12, 15), ])
skip_if_not_installed("vdiffr")
vdiffr::expect_doppelganger("PlotChar_consensus", function () {
- PlotCharacter(trees, dat, plot = FALSE)
+ PlotCharacter(trees, dat)
}
)
})
From 38a6fdb432d780bf5bda1653f13e3dcb1d06ebdb Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 11:07:14 +0000
Subject: [PATCH 09/26] sp
---
R/PlotCharacter.R | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index dd54d5fe2..6a0e9452f 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -501,7 +501,7 @@ PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
reconstructions[match(consClades, .TreeClades(tree[[i]])), , i]
}
recon <- .Recon(1)
- for (i in seq_along(trees)[-1]) {
+ for (i in seq_along(tree)[-1]) {
recon <- recon | .Recon(i)
}
From 469ba3f4b48fbf68c175007b8a373b92b26621dc Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 11:07:28 +0000
Subject: [PATCH 10/26] Create plotchar-consensus.svg
---
.../PlotCharacter/plotchar-consensus.svg | 80 +++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100644 tests/testthat/_snaps/PlotCharacter/plotchar-consensus.svg
diff --git a/tests/testthat/_snaps/PlotCharacter/plotchar-consensus.svg b/tests/testthat/_snaps/PlotCharacter/plotchar-consensus.svg
new file mode 100644
index 000000000..98a79de57
--- /dev/null
+++ b/tests/testthat/_snaps/PlotCharacter/plotchar-consensus.svg
@@ -0,0 +1,80 @@
+
+
From 5f6a6d79e6fc3d7e450328d069ff72d9f64a1e4b Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 11:08:03 +0000
Subject: [PATCH 11/26] don't plot
---
tests/testthat/test-PlotCharacter.R | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index b7346a8ee..a0ebe9db9 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -152,9 +152,9 @@ test_that("PlotCharacter.multi()", {
PlotCharacter(trees[[1]], dat, plot = FALSE))
- state1 <- PlotCharacter(trees[[1]], dat)
- state2 <- PlotCharacter(trees[[2]], dat)
- stateCons <- PlotCharacter(trees, dat)
+ state1 <- PlotCharacter(trees[[1]], dat, plot = FALSE)
+ state2 <- PlotCharacter(trees[[2]], dat, plot = FALSE)
+ stateCons <- PlotCharacter(trees, dat, plot = FALSE)
expect_equal(stateCons, state1[-c(13, 15), ] |
state2[c(match(TipLabels(trees[[1]]), TipLabels(trees[[2]])),
9:12, 15), ])
From c99979754918e7eb204a09af1749208066e6efed Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 11:16:27 +0000
Subject: [PATCH 12/26] Explicit ape link
---
man-roxygen/treeParam.r | 2 +-
man/CharacterLength.Rd | 2 +-
man/ConcordantInformation.Rd | 2 +-
man/Consistency.Rd | 2 +-
man/JackLabels.Rd | 2 +-
man/Jackknife.Rd | 2 +-
man/NNI.Rd | 2 +-
man/Ratchet.Rd | 2 +-
man/SPR.Rd | 2 +-
man/SiteConcordance.Rd | 2 +-
man/SuccessiveApproximations.Rd | 2 +-
man/cSPR.Rd | 2 +-
12 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/man-roxygen/treeParam.r b/man-roxygen/treeParam.r
index e4b0c68b4..7b04ba8a5 100644
--- a/man-roxygen/treeParam.r
+++ b/man-roxygen/treeParam.r
@@ -1,2 +1,2 @@
-#' @param tree A tree of class \code{\link{phylo}}.
+#' @param tree A tree of class \code{\link[ape]{phylo}}.
# Defined in TreeTools. Please propagate any changes there.
diff --git a/man/CharacterLength.Rd b/man/CharacterLength.Rd
index 5f217f6c5..5d60f8ecf 100644
--- a/man/CharacterLength.Rd
+++ b/man/CharacterLength.Rd
@@ -13,7 +13,7 @@ FitchSteps(tree, dataset)
FastCharacterLength(tree, dataset)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{dataset}{A phylogenetic data matrix of \pkg{phangorn} class
\code{phyDat}, whose names correspond to the labels of any accompanying tree.
diff --git a/man/ConcordantInformation.Rd b/man/ConcordantInformation.Rd
index b1d10935d..2dd4cafc5 100644
--- a/man/ConcordantInformation.Rd
+++ b/man/ConcordantInformation.Rd
@@ -13,7 +13,7 @@ Evaluate(tree, dataset)
ConcordantInfo(tree, dataset)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{dataset}{A phylogenetic data matrix of \pkg{phangorn} class
\code{phyDat}, whose names correspond to the labels of any accompanying tree.
diff --git a/man/Consistency.Rd b/man/Consistency.Rd
index 2af757710..1266c8b24 100644
--- a/man/Consistency.Rd
+++ b/man/Consistency.Rd
@@ -11,7 +11,7 @@ Consistency(dataset, tree, compress = FALSE)
\code{phyDat}, whose names correspond to the labels of any accompanying tree.
Perhaps load into R using \code{\link[TreeTools]{ReadCharacters}}.}
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{compress}{Logical specifying whether to retain the compression of a
\code{phyDat} object or to return a vector specifying to each individual
diff --git a/man/JackLabels.Rd b/man/JackLabels.Rd
index f71912677..731c39b36 100644
--- a/man/JackLabels.Rd
+++ b/man/JackLabels.Rd
@@ -17,7 +17,7 @@ JackLabels(
)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{jackTrees}{A list or \code{multiPhylo} object containing trees generated
by \code{\link[=Jackknife]{Jackknife()}}.}
diff --git a/man/Jackknife.Rd b/man/Jackknife.Rd
index 562ec3caf..49f7f2fcd 100644
--- a/man/Jackknife.Rd
+++ b/man/Jackknife.Rd
@@ -20,7 +20,7 @@ Jackknife(
)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{dataset}{a dataset in the format required by \code{TreeScorer()}.}
diff --git a/man/NNI.Rd b/man/NNI.Rd
index 732fe13d4..d1e904e7c 100644
--- a/man/NNI.Rd
+++ b/man/NNI.Rd
@@ -24,7 +24,7 @@ RootedNNISwap(
)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{edgeToBreak}{In (\code{Rooted})\code{NNI()}, an optional integer specifying the
index of an edge to bisect/prune, generated randomly if not specified.
diff --git a/man/Ratchet.Rd b/man/Ratchet.Rd
index 3f68fd0e9..d1d92a7d0 100644
--- a/man/Ratchet.Rd
+++ b/man/Ratchet.Rd
@@ -105,7 +105,7 @@ by \code{attr(FunctionName, "stopAtPlateau") <- TRUE}.}
\item{\dots}{further arguments to pass to \code{TreeScorer()}, e.g. \verb{dataset = }.}
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{dataset}{a dataset in the format required by \code{TreeScorer()}.}
diff --git a/man/SPR.Rd b/man/SPR.Rd
index 85261937c..1e892560b 100644
--- a/man/SPR.Rd
+++ b/man/SPR.Rd
@@ -39,7 +39,7 @@ RootedSPRSwap(
)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{edgeToBreak}{the index of an edge to bisect, generated randomly if not specified.}
diff --git a/man/SiteConcordance.Rd b/man/SiteConcordance.Rd
index fc78c6792..422dec8fe 100644
--- a/man/SiteConcordance.Rd
+++ b/man/SiteConcordance.Rd
@@ -20,7 +20,7 @@ MutualClusteringConcordance(tree, dataset)
SharedPhylogeneticConcordance(tree, dataset)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{dataset}{A phylogenetic data matrix of \pkg{phangorn} class
\code{phyDat}, whose names correspond to the labels of any accompanying tree.
diff --git a/man/SuccessiveApproximations.Rd b/man/SuccessiveApproximations.Rd
index 774dc45b7..275ec3061 100644
--- a/man/SuccessiveApproximations.Rd
+++ b/man/SuccessiveApproximations.Rd
@@ -22,7 +22,7 @@ SuccessiveApproximations(
SuccessiveWeights(tree, dataset)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{dataset}{A phylogenetic data matrix of \pkg{phangorn} class
\code{phyDat}, whose names correspond to the labels of any accompanying tree.
diff --git a/man/cSPR.Rd b/man/cSPR.Rd
index b0467e389..496fb5947 100644
--- a/man/cSPR.Rd
+++ b/man/cSPR.Rd
@@ -7,7 +7,7 @@
cSPR(tree, whichMove = NULL)
}
\arguments{
-\item{tree}{A tree of class \code{\link{phylo}}.}
+\item{tree}{A tree of class \code{\link[ape]{phylo}}.}
\item{whichMove}{Integer specifying which SPR move index to perform.}
}
From e3b140f06dfcfc37b02e35e7878ca7d1d3726726 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 11:19:49 +0000
Subject: [PATCH 13/26] Link [ape]
---
R/CustomSearch.R | 2 +-
R/MaximizeParsimony.R | 2 +-
R/TBR.R | 2 +-
R/mpl_visualise.R | 2 +-
man-roxygen/treeChild.R | 2 +-
man-roxygen/treeNEdge.R | 2 +-
man-roxygen/treeNEdgeOptional.R | 2 +-
man-roxygen/treeParent.r | 2 +-
man/AllSPR.Rd | 6 +++---
man/DoubleNNI.Rd | 4 ++--
man/MaximizeParsimony.Rd | 2 +-
man/MorphyTreeLength.Rd | 4 ++--
man/NNI.Rd | 4 ++--
man/RearrangeEdges.Rd | 4 ++--
man/SPR.Rd | 6 +++---
man/StopUnlessBifurcating.Rd | 2 +-
man/TBR.Rd | 6 +++---
man/TBRWarning.Rd | 4 ++--
man/TreeSearch.Rd | 2 +-
man/dot-NonDuplicateRoot.Rd | 6 +++---
20 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/R/CustomSearch.R b/R/CustomSearch.R
index c680d3dba..272776403 100644
--- a/R/CustomSearch.R
+++ b/R/CustomSearch.R
@@ -99,7 +99,7 @@ EdgeListSearch <- function (edgeList, dataset,
#' configuring tree search, see the
#' [package documentation](https://ms609.github.io/TreeSearch/).
#'
-#' @param tree A fully-resolved starting tree in \code{\link{phylo}} format,
+#' @param tree A fully-resolved starting tree in \code{\link[ape]{phylo}} format,
#' with the desired outgroup.
#' Edge lengths are not supported and will be removed.
#' @template datasetParam
diff --git a/R/MaximizeParsimony.R b/R/MaximizeParsimony.R
index c1c0f4fd0..bad5cefb4 100644
--- a/R/MaximizeParsimony.R
+++ b/R/MaximizeParsimony.R
@@ -30,7 +30,7 @@
#'
#'
#' @template datasetParam
-#' @param tree (optional) A bifurcating tree of class \code{\link{phylo}},
+#' @param tree (optional) A bifurcating tree of class \code{\link[ape]{phylo}},
#' containing only the tips listed in `dataset`, from which the search
#' should begin.
#' If unspecified, an [addition tree][AdditionTree()] will be generated from
diff --git a/R/TBR.R b/R/TBR.R
index d4374be58..206f0894f 100644
--- a/R/TBR.R
+++ b/R/TBR.R
@@ -27,7 +27,7 @@ TBRWarning <- function (parent, child, error) {
#' All nodes in a tree must be bifurcating; [ape::collapse.singles] and
#' [ape::multi2di] may help.
#'
-#' @param tree A bifurcating tree of class \code{\link{phylo}}, with all nodes resolved;
+#' @param tree A bifurcating tree of class \code{\link[ape]{phylo}}, with all nodes resolved;
#' @template edgeToBreakParam
#' @template mergeEdgesParam
#'
diff --git a/R/mpl_visualise.R b/R/mpl_visualise.R
index e9caafb0b..3ab490068 100644
--- a/R/mpl_visualise.R
+++ b/R/mpl_visualise.R
@@ -24,7 +24,7 @@
### #' @description Determine and depict the possible states for a character on a tree under the most parsimonious conditions
### #' @usage VisualiseCharacter(tree, dataset, char.no, plot.fun = plot)
### #'
-### #' @param tree a fully-resolved tree in \code{\link{phylo}} format, with the desired outgroup; edge lengths are not supported and will be deleted;
+### #' @param tree a fully-resolved tree in \code{\link[ape]{phylo}} format, with the desired outgroup; edge lengths are not supported and will be deleted;
### #' @template datasetParam
### #' @param char.no number of the character to be displayed;
### #' @param plot.fun a function that plots a tree, \code{\link{plot}} by default.
diff --git a/man-roxygen/treeChild.R b/man-roxygen/treeChild.R
index 043545d9d..9a950b8ce 100644
--- a/man-roxygen/treeChild.R
+++ b/man-roxygen/treeChild.R
@@ -1,3 +1,3 @@
#' @param child Integer vector corresponding to the second column of the edge
-#' matrix of a tree of class \code{\link{phylo}}, i.e. `tree$edge[, 2]`.
+#' matrix of a tree of class \code{\link[ape]{phylo}}, i.e. `tree$edge[, 2]`.
# Defined in TreeTools. Please propagate any changes there.
diff --git a/man-roxygen/treeNEdge.R b/man-roxygen/treeNEdge.R
index 624d39af2..1170799e0 100644
--- a/man-roxygen/treeNEdge.R
+++ b/man-roxygen/treeNEdge.R
@@ -1 +1 @@
-#' @param nEdge integer specifying the number of edges of a tree of class \code{\link{phylo}}, i.e. \code{dim(tree$edge)[1]}
+#' @param nEdge integer specifying the number of edges of a tree of class \code{\link[ape]{phylo}}, i.e. \code{dim(tree$edge)[1]}
diff --git a/man-roxygen/treeNEdgeOptional.R b/man-roxygen/treeNEdgeOptional.R
index f5951842b..f64c9fdec 100644
--- a/man-roxygen/treeNEdgeOptional.R
+++ b/man-roxygen/treeNEdgeOptional.R
@@ -1,3 +1,3 @@
#' @param nEdge (optional) integer specifying the number of edges of a tree of
-#' class \code{\link{phylo}}, i.e. \code{dim(tree$edge)[1]}
+#' class \code{\link[ape]{phylo}}, i.e. \code{dim(tree$edge)[1]}
# Defined in TreeTools. Please propagate any changes there.
diff --git a/man-roxygen/treeParent.r b/man-roxygen/treeParent.r
index 7dc054508..77609f2ea 100644
--- a/man-roxygen/treeParent.r
+++ b/man-roxygen/treeParent.r
@@ -1,3 +1,3 @@
#' @param parent Integer vector corresponding to the first column of the edge
-#' matrix of a tree of class \code{\link{phylo}}, i.e. `tree$edge[, 1]`.
+#' matrix of a tree of class \code{\link[ape]{phylo}}, i.e. `tree$edge[, 1]`.
# Defined in TreeTools. Please propagate any changes there.
diff --git a/man/AllSPR.Rd b/man/AllSPR.Rd
index cbc891ca1..ac718a30f 100644
--- a/man/AllSPR.Rd
+++ b/man/AllSPR.Rd
@@ -8,12 +8,12 @@ AllSPR(parent, child, nEdge, notDuplicateRoot, edgeToBreak)
}
\arguments{
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
-\item{nEdge}{integer specifying the number of edges of a tree of class \code{\link{phylo}}, i.e. \code{dim(tree$edge)[1]}}
+\item{nEdge}{integer specifying the number of edges of a tree of class \code{\link[ape]{phylo}}, i.e. \code{dim(tree$edge)[1]}}
\item{notDuplicateRoot}{logical vector of length \code{nEdge}, specifying for each
edge whether it is the second edge leading to the root (in which case
diff --git a/man/DoubleNNI.Rd b/man/DoubleNNI.Rd
index 0a286a3aa..22ba4bcfe 100644
--- a/man/DoubleNNI.Rd
+++ b/man/DoubleNNI.Rd
@@ -8,10 +8,10 @@ DoubleNNI(parent, child, edgeToBreak)
}
\arguments{
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
\item{edgeToBreak}{(optional) integer specifying the index of an edge to bisect/prune,
generated randomly if not specified.
diff --git a/man/MaximizeParsimony.Rd b/man/MaximizeParsimony.Rd
index 8de3f5d24..e4c65f8c6 100644
--- a/man/MaximizeParsimony.Rd
+++ b/man/MaximizeParsimony.Rd
@@ -50,7 +50,7 @@ EasyTreesy()
\code{phyDat}, whose names correspond to the labels of any accompanying tree.
Perhaps load into R using \code{\link[TreeTools]{ReadCharacters}}.}
-\item{tree}{(optional) A bifurcating tree of class \code{\link{phylo}},
+\item{tree}{(optional) A bifurcating tree of class \code{\link[ape]{phylo}},
containing only the tips listed in \code{dataset}, from which the search
should begin.
If unspecified, an \link[=AdditionTree]{addition tree} will be generated from
diff --git a/man/MorphyTreeLength.Rd b/man/MorphyTreeLength.Rd
index e23f42be8..c57e29ac3 100644
--- a/man/MorphyTreeLength.Rd
+++ b/man/MorphyTreeLength.Rd
@@ -30,10 +30,10 @@ in the corresponding Morphy object.}
\code{\link[=PhyDat2Morphy]{PhyDat2Morphy()}}.}
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
\item{parentOf}{For each node, numbered in postorder, the number of its parent node.}
diff --git a/man/NNI.Rd b/man/NNI.Rd
index d1e904e7c..3ba669d06 100644
--- a/man/NNI.Rd
+++ b/man/NNI.Rd
@@ -37,10 +37,10 @@ specifying which internal edge to break.}
the broken internal edge.}
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
\item{nTips}{(optional) Number of tips.}
}
diff --git a/man/RearrangeEdges.Rd b/man/RearrangeEdges.Rd
index ea22701ba..550b82328 100644
--- a/man/RearrangeEdges.Rd
+++ b/man/RearrangeEdges.Rd
@@ -19,10 +19,10 @@ RearrangeEdges(
}
\arguments{
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
\item{dataset}{Third argument to pass to \code{TreeScorer}.}
diff --git a/man/SPR.Rd b/man/SPR.Rd
index 1e892560b..cddf63a4a 100644
--- a/man/SPR.Rd
+++ b/man/SPR.Rd
@@ -46,13 +46,13 @@ RootedSPRSwap(
\item{mergeEdge}{the index of an edge on which to merge the broken edge.}
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
\item{nEdge}{(optional) integer specifying the number of edges of a tree of
-class \code{\link{phylo}}, i.e. \code{dim(tree$edge)[1]}}
+class \code{\link[ape]{phylo}}, i.e. \code{dim(tree$edge)[1]}}
\item{nNode}{(optional) Number of nodes.}
}
diff --git a/man/StopUnlessBifurcating.Rd b/man/StopUnlessBifurcating.Rd
index 5130c7627..73f8e6ec4 100644
--- a/man/StopUnlessBifurcating.Rd
+++ b/man/StopUnlessBifurcating.Rd
@@ -8,7 +8,7 @@ StopUnlessBifurcating(parent)
}
\arguments{
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
}
\value{
Returns \code{NULL}, but will \code{stop} with an error message if a tree
diff --git a/man/TBR.Rd b/man/TBR.Rd
index 7daa03992..8843e8754 100644
--- a/man/TBR.Rd
+++ b/man/TBR.Rd
@@ -37,7 +37,7 @@ RootedTBRSwap(
)
}
\arguments{
-\item{tree}{A bifurcating tree of class \code{\link{phylo}}, with all nodes resolved;}
+\item{tree}{A bifurcating tree of class \code{\link[ape]{phylo}}, with all nodes resolved;}
\item{edgeToBreak}{(optional) integer specifying the index of an edge to bisect/prune,
generated randomly if not specified.
@@ -51,10 +51,10 @@ sides of \code{edgeToBreak}); if only a single edge is specified,
the second will be chosen at random}
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
\item{nEdge}{(optional) Number of edges.}
}
diff --git a/man/TBRWarning.Rd b/man/TBRWarning.Rd
index a6d271822..44532e4fc 100644
--- a/man/TBRWarning.Rd
+++ b/man/TBRWarning.Rd
@@ -12,10 +12,10 @@ TBRWarning(parent, child, error)
}
\arguments{
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
\item{error}{error message to report}
}
diff --git a/man/TreeSearch.Rd b/man/TreeSearch.Rd
index 33b0658ff..31a148938 100644
--- a/man/TreeSearch.Rd
+++ b/man/TreeSearch.Rd
@@ -86,7 +86,7 @@ larger numbers provide more verbose feedback to the user.}
\item{\dots}{further arguments to pass to \code{TreeScorer()}, e.g. \verb{dataset = }.}
-\item{tree}{A fully-resolved starting tree in \code{\link{phylo}} format,
+\item{tree}{A fully-resolved starting tree in \code{\link[ape]{phylo}} format,
with the desired outgroup.
Edge lengths are not supported and will be removed.}
diff --git a/man/dot-NonDuplicateRoot.Rd b/man/dot-NonDuplicateRoot.Rd
index 198eefeb1..1f7d7e089 100644
--- a/man/dot-NonDuplicateRoot.Rd
+++ b/man/dot-NonDuplicateRoot.Rd
@@ -8,13 +8,13 @@
}
\arguments{
\item{parent}{Integer vector corresponding to the first column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 1]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 1]}.}
\item{child}{Integer vector corresponding to the second column of the edge
-matrix of a tree of class \code{\link{phylo}}, i.e. \code{tree$edge[, 2]}.}
+matrix of a tree of class \code{\link[ape]{phylo}}, i.e. \code{tree$edge[, 2]}.}
\item{nEdge}{(optional) integer specifying the number of edges of a tree of
-class \code{\link{phylo}}, i.e. \code{dim(tree$edge)[1]}}
+class \code{\link[ape]{phylo}}, i.e. \code{dim(tree$edge)[1]}}
}
\value{
\code{.NonDuplicateRoot()} returns a logical vector of length \code{nEdge},
From d7222e2b86f28de76e2a971a5110311373450df4 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 11:29:32 +0000
Subject: [PATCH 14/26] Link package functions
---
R/MaximizeParsimony.R | 2 +-
R/TaxonInfluence.R | 2 +-
man-roxygen/labelledTreeParam.R | 6 +++---
man/AdditionTree.Rd | 2 +-
man/MaximizeParsimony.Rd | 2 +-
man/MorphyTreeLength.Rd | 6 +++---
man/TaxonInfluence.Rd | 2 +-
7 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/R/MaximizeParsimony.R b/R/MaximizeParsimony.R
index bad5cefb4..9f8178ee6 100644
--- a/R/MaximizeParsimony.R
+++ b/R/MaximizeParsimony.R
@@ -79,7 +79,7 @@
#' returned trees will be perfectly compatible with each character in
#' `constraint`; or a tree of class `phylo`, all of whose nodes will occur
#' in any output tree.
-#' See [`ImposeConstraint()`] and
+#' See \link[TreeTools:ImposeConstraint]{`ImposeConstraint()`} and
#' [vignette](https://ms609.github.io/TreeSearch/articles/tree-search.html)
#' for further examples.
#' @param verbosity Integer specifying level of messaging; higher values give
diff --git a/R/TaxonInfluence.R b/R/TaxonInfluence.R
index 8e601f317..6451ac4fc 100644
--- a/R/TaxonInfluence.R
+++ b/R/TaxonInfluence.R
@@ -52,7 +52,7 @@
#' `paste0(savePath, droppedTaxonName, ".nex")`; `savePath` should thus contain
#' a trailing `/` if writing to a directory, which will be created if it does
#' not exist. Special characters will be removed from leaf labels when
-#' creating the file path (using [`path_sanitize()`]).
+#' creating the file path (using \link[fs:path_sanitize]{`path_sanitize()`}).
#' If `NULL`, computed trees will not be saved.
#' @param useCache Logical vector; if `TRUE`, previous tree search results will
#' be loaded from the location given by `savePath`, instead of running a fresh
diff --git a/man-roxygen/labelledTreeParam.R b/man-roxygen/labelledTreeParam.R
index ceb56a9c9..b8dbf91a1 100644
--- a/man-roxygen/labelledTreeParam.R
+++ b/man-roxygen/labelledTreeParam.R
@@ -1,3 +1,3 @@
-#' @param tree A tree of class \code{\link[ape:read.tree]{phylo}}, with tip labels in the order generated by
-#' \code{\link{RenumberTips}}, i.e. corresponding to the sequence of taxa
-#' in the corresponding Morphy object.
+#' @param tree A tree of class \code{\link[ape:read.tree]{phylo}}, with tip
+#' labels in the order generated by \code{\link[TreeTools]{RenumberTips}},
+#' i.e. corresponding to the sequence of taxa in the corresponding Morphy object.
diff --git a/man/AdditionTree.Rd b/man/AdditionTree.Rd
index 88fe9b76c..837d76fe7 100644
--- a/man/AdditionTree.Rd
+++ b/man/AdditionTree.Rd
@@ -25,7 +25,7 @@ approaches
returned trees will be perfectly compatible with each character in
\code{constraint}; or a tree of class \code{phylo}, all of whose nodes will occur
in any output tree.
-See \code{\link[=ImposeConstraint]{ImposeConstraint()}} and
+See \link[TreeTools:ImposeConstraint]{\code{ImposeConstraint()}} and
\href{https://ms609.github.io/TreeSearch/articles/tree-search.html}{vignette}
for further examples.}
diff --git a/man/MaximizeParsimony.Rd b/man/MaximizeParsimony.Rd
index e4c65f8c6..5c476c19d 100644
--- a/man/MaximizeParsimony.Rd
+++ b/man/MaximizeParsimony.Rd
@@ -110,7 +110,7 @@ in search results, which may improve the accuracy of the consensus tree
returned trees will be perfectly compatible with each character in
\code{constraint}; or a tree of class \code{phylo}, all of whose nodes will occur
in any output tree.
-See \code{\link[=ImposeConstraint]{ImposeConstraint()}} and
+See \link[TreeTools:ImposeConstraint]{\code{ImposeConstraint()}} and
\href{https://ms609.github.io/TreeSearch/articles/tree-search.html}{vignette}
for further examples.}
diff --git a/man/MorphyTreeLength.Rd b/man/MorphyTreeLength.Rd
index c57e29ac3..1e1816bc0 100644
--- a/man/MorphyTreeLength.Rd
+++ b/man/MorphyTreeLength.Rd
@@ -22,9 +22,9 @@ GetMorphyLength(parentOf, leftChild, rightChild, morphyObj)
C_MorphyLength(parentOf, leftChild, rightChild, morphyObj)
}
\arguments{
-\item{tree}{A tree of class \code{\link[ape:read.tree]{phylo}}, with tip labels in the order generated by
-\code{\link{RenumberTips}}, i.e. corresponding to the sequence of taxa
-in the corresponding Morphy object.}
+\item{tree}{A tree of class \code{\link[ape:read.tree]{phylo}}, with tip
+labels in the order generated by \code{\link[TreeTools]{RenumberTips}},
+i.e. corresponding to the sequence of taxa in the corresponding Morphy object.}
\item{morphyObj}{Object of class \code{morphy}, perhaps created with
\code{\link[=PhyDat2Morphy]{PhyDat2Morphy()}}.}
diff --git a/man/TaxonInfluence.Rd b/man/TaxonInfluence.Rd
index fdfe41d85..a06bfba9f 100644
--- a/man/TaxonInfluence.Rd
+++ b/man/TaxonInfluence.Rd
@@ -37,7 +37,7 @@ saved (with \code{\link[=write.nexus]{write.nexus()}}). File names will follow t
\code{paste0(savePath, droppedTaxonName, ".nex")}; \code{savePath} should thus contain
a trailing \code{/} if writing to a directory, which will be created if it does
not exist. Special characters will be removed from leaf labels when
-creating the file path (using \code{\link[=path_sanitize]{path_sanitize()}}).
+creating the file path (using \link[fs:path_sanitize]{\code{path_sanitize()}}).
If \code{NULL}, computed trees will not be saved.}
\item{useCache}{Logical vector; if \code{TRUE}, previous tree search results will
From f67ca34aea4025354ba46c4fa4edf5b2f5a55930 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 11:36:51 +0000
Subject: [PATCH 15/26] Oustanding package links
---
R/TaxonInfluence.R | 7 ++++---
R/data.R | 3 ++-
man/TaxonInfluence.Rd | 7 ++++---
man/inapplicable.datasets.Rd | 3 ++-
4 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/R/TaxonInfluence.R b/R/TaxonInfluence.R
index 6451ac4fc..1c7bd43a9 100644
--- a/R/TaxonInfluence.R
+++ b/R/TaxonInfluence.R
@@ -44,11 +44,12 @@
#' If `NULL`, an optimal tree will be sought using parsimony search with
#' the parameters provided in \code{\dots}.
#' @param Distance Function to calculate tree distance; default:
-#' [`ClusteringInfoDistance()`].
+#' \link[TreeDist::ClusteringInfoDistance]{`ClusteringInfoDistance()`}.
#' @param calcWeighted Logical specifying whether to compute the
#' distance-weighted mean value.
-#' @param savePath Character giving prefix of path to which reduced trees will be
-#' saved (with [`write.nexus()`]). File names will follow the pattern
+#' @param savePath Character giving prefix of path to which reduced trees will
+#' be saved (with \link[ape:write.nexus]{`write.nexus()`}).
+#' File names will follow the pattern
#' `paste0(savePath, droppedTaxonName, ".nex")`; `savePath` should thus contain
#' a trailing `/` if writing to a directory, which will be created if it does
#' not exist. Special characters will be removed from leaf labels when
diff --git a/R/data.R b/R/data.R
index fe251ab6c..9057d60ea 100644
--- a/R/data.R
+++ b/R/data.R
@@ -6,7 +6,8 @@
#' Datasets are sorted into two subsets, each sorted alphabetically;
#' the first subset comprise simpler datasets with faster processing times.
#' `inapplicable.datasets` provide the data in the matrix format generated by
-#' [`read.nexus.data()`]; `inapplicable.phyData` are in \code{phyDat} format.
+#' \link[ape:read.nexus.data]{`read.nexus.data()`};
+#' `inapplicable.phyData` are in \code{phyDat} format.
#' `inapplicable.trees` lists for each dataset a sample of up to 50 trees
#' obtained by tree search under each inapplicable treatment, named accordingly.
#' `inapplicable.citations` is a named character vector specifying the source of
diff --git a/man/TaxonInfluence.Rd b/man/TaxonInfluence.Rd
index a06bfba9f..5f8d81a0f 100644
--- a/man/TaxonInfluence.Rd
+++ b/man/TaxonInfluence.Rd
@@ -27,13 +27,14 @@ If \code{NULL}, an optimal tree will be sought using parsimony search with
the parameters provided in \code{\dots}.}
\item{Distance}{Function to calculate tree distance; default:
-\code{\link[=ClusteringInfoDistance]{ClusteringInfoDistance()}}.}
+\link[TreeDist::ClusteringInfoDistance]{\code{ClusteringInfoDistance()}}.}
\item{calcWeighted}{Logical specifying whether to compute the
distance-weighted mean value.}
-\item{savePath}{Character giving prefix of path to which reduced trees will be
-saved (with \code{\link[=write.nexus]{write.nexus()}}). File names will follow the pattern
+\item{savePath}{Character giving prefix of path to which reduced trees will
+be saved (with \link[ape:write.nexus]{\code{write.nexus()}}).
+File names will follow the pattern
\code{paste0(savePath, droppedTaxonName, ".nex")}; \code{savePath} should thus contain
a trailing \code{/} if writing to a directory, which will be created if it does
not exist. Special characters will be removed from leaf labels when
diff --git a/man/inapplicable.datasets.Rd b/man/inapplicable.datasets.Rd
index 949a97731..b8383f699 100644
--- a/man/inapplicable.datasets.Rd
+++ b/man/inapplicable.datasets.Rd
@@ -146,7 +146,8 @@ The name of each item corresponds to the datasets listed below.
Datasets are sorted into two subsets, each sorted alphabetically;
the first subset comprise simpler datasets with faster processing times.
\code{inapplicable.datasets} provide the data in the matrix format generated by
-\code{\link[=read.nexus.data]{read.nexus.data()}}; \code{inapplicable.phyData} are in \code{phyDat} format.
+\link[ape:read.nexus.data]{\code{read.nexus.data()}};
+\code{inapplicable.phyData} are in \code{phyDat} format.
\code{inapplicable.trees} lists for each dataset a sample of up to 50 trees
obtained by tree search under each inapplicable treatment, named accordingly.
\code{inapplicable.citations} is a named character vector specifying the source of
From bbefeebd4d723ba8bad4838bf6778eac0e2fa1e8 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 13:03:16 +0000
Subject: [PATCH 16/26] `Display` param
---
R/PlotCharacter.R | 29 +++++++++------
inst/Parsimony/app.R | 67 ++++++++++++++++++++++++----------
inst/Parsimony/log.lg | 84 +++++++++++++++++++++++++++++++++++++++++++
man/PlotCharacter.Rd | 7 ++++
4 files changed, 158 insertions(+), 29 deletions(-)
create mode 100644 inst/Parsimony/log.lg
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index 6a0e9452f..e55bce197 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -18,6 +18,8 @@
#' [graphical parameter] for details of line styles. Overrides `tokenCol`.
#' @param tipOffset Numeric: how much to offset tips from their labels.
#' @param unitEdge Logical: Should all edges be plotted with a unit length?
+#' @param Display Function that takes argument `tree` and returns a tree
+#' of class `phylo`, formatted as it will be plotted.
#' @param \dots Further arguments to pass to `plot.phylo()`.
#'
#' @return `PlotCharacter()` invisibly returns a matrix in which each row
@@ -66,6 +68,7 @@ PlotCharacter <- function(tree, dataset, char = 1L,
tipOffset = 1,
unitEdge = FALSE,
+ Display = function(tree) tree,
...
) {
UseMethod("PlotCharacter")
@@ -87,11 +90,13 @@ PlotCharacter.phylo <- function(tree, dataset, char = 1L,
tipOffset = 1,
unitEdge = FALSE,
+ Display = function(tree) tree,
...
) {
# Reconcile labels
datasetTaxa <- names(dataset)
+ tree <- Display(tree)
treeTaxa <- tree[["tip.label"]]
if(!all(treeTaxa %fin% datasetTaxa)) {
stop("Taxa in tree missing from dataset:\n ",
@@ -465,13 +470,14 @@ PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
tipOffset = 1,
unitEdge = FALSE,
+ Display = function(tree) tree,
...) {
if (length(tree) == 1) {
return(PlotCharacter(tree[[1]], dataset, char, updateTips, plot,
tokenCol, ambigCol, inappCol,
ambigLty, inappLty, plainLty,
- tipOffset, unitEdge, ...))
+ tipOffset, unitEdge, Display, ...))
}
tipLabels <- unique(lapply(lapply(tree, TipLabels), sort))
@@ -481,12 +487,12 @@ PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
tipLabels <- tipLabels[[1]]
nTip <- length(tipLabels)
tokens <- attr(dataset, "levels")
- reconstructions <- vapply(tree, PlotCharacter,
- matrix(FALSE, nTip * 2 - 1, length(tokens)),
+ reconstructions <- lapply(tree, PlotCharacter,
dataset = dataset, char = char,
- updateTips = updateTips, plot = FALSE, ...)
+ updateTips = updateTips, plot = FALSE,
+ Display = function(tree) tree, ...)
# Check labels: definitely identical, possibly in different sequence
- consTree <- Consensus(tree, p = 1, check.labels = TRUE)
+ consTree <- Display(Consensus(tree, p = 1, check.labels = TRUE))
.TreeClades <- function(tr) {
ed <- tr[["edge"]]
lab <- TipLabels(tr)
@@ -498,11 +504,13 @@ PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
}
consClades <- .TreeClades(consTree)
.Recon <- function(i) {
- reconstructions[match(consClades, .TreeClades(tree[[i]])), , i]
+ reconstructions[[i]][match(consClades, .TreeClades(tree[[i]])), ]
}
- recon <- .Recon(1)
- for (i in seq_along(tree)[-1]) {
- recon <- recon | .Recon(i)
+ recon <- matrix(FALSE, nrow = length(consClades), ncol = length(tokens),
+ dimnames = list(NULL, tokens))
+ for (i in seq_along(tree)) {
+ ri <- .Recon(i)
+ recon[, colnames(ri)] <- recon[, colnames(ri)] | ri
}
if (isTRUE(plot)) {
@@ -529,13 +537,14 @@ PlotCharacter.list <- function(tree, dataset, char = 1L,
tipOffset = 1,
unitEdge = FALSE,
+ Display = function(tree) tree,
...
) {
if (all(vapply(tree, inherits, logical(1), "phylo"))) {
PlotCharacter.multiPhylo(tree, dataset, char, updateTips, plot,
tokenCol, ambigCol, inappCol,
ambigLty, inappLty, plainLty,
- tipOffset, unitEdge, ...)
+ tipOffset, unitEdge, Display, ...)
} else {
stop("Elements of `tree` must be of class `phylo`")
}
diff --git a/inst/Parsimony/app.R b/inst/Parsimony/app.R
index 097d1f446..3715ef18d 100644
--- a/inst/Parsimony/app.R
+++ b/inst/Parsimony/app.R
@@ -337,8 +337,8 @@ ui <- fluidPage(
"Tree space" = "space"),
# "ind"),
"cons"),
- hidden(sliderInput("whichTree", "Tree to plot", value = 1L,
- min = 1L, max = 1L, step = 1L)),
+ hidden(sliderInput("whichTree", "Tree to plot", value = 0L,
+ min = 0L, max = 1L, step = 1L)),
hidden(tags$div(id = "treePlotConfig",
selectizeInput("outgroup", "Root on:", multiple = TRUE,
choices = list()),
@@ -1127,8 +1127,8 @@ server <- function(input, output, session) {
}
}
- updateSliderInput(session, "whichTree", min = 1L,
- max = length(r$trees), value = 1L)
+ updateSliderInput(session, "whichTree", min = 0L,
+ max = length(r[["trees"]]), value = 0L)
UpdateKeepNTipsRange() # Updates Rogues()
UpdateDroppedTaxaDisplay()
if (maxProjDim() > 0) {
@@ -1662,8 +1662,8 @@ server <- function(input, output, session) {
attr(r$trees[[1]], "firstHit") <- NULL
}
- updateSliderInput(session, "whichTree", min = 1L,
- max = length(r$trees), value = 1L)
+ updateSliderInput(session, "whichTree", min = 0L,
+ max = length(r[["trees"]]), value = 0L)
updateActionButton(session, "go", "Continue")
updateActionButton(session, "modalGo", "Continue search")
@@ -1684,7 +1684,7 @@ server <- function(input, output, session) {
UserRoot <- function(tree) {
outgroupTips <- intersect(r$outgroup, tree$tip.label)
if (length(outgroupTips)) {
- tr <- deparse(substitute(tree))
+ # DELETE? tr <- deparse(substitute(tree))
RootTree(tree, outgroupTips)
} else {
tree
@@ -1729,18 +1729,25 @@ server <- function(input, output, session) {
PlottedTree <- reactive({
if (length(r$trees) > 0L) {
- plottedTree <- r$trees[[whichTree()]]
+ plottedTree <- if (whichTree() > 0) {
+ r$trees[[whichTree()]]
+ } else {
+ Consensus(r$trees, p = 1)
+ }
plottedTree <- UserRoot(plottedTree)
plottedTree <- SortEdges(plottedTree)
-
if (!("tipsRight" %in% input$mapDisplay)) {
- plottedTree$edge.length <- rep_len(2, dim(plottedTree$edge)[1])
+ plottedTree$edge.length <- rep_len(2, dim(plottedTree[["edge"]])[[1]])
}
plottedTree
}
})
LogPlottedTree <- function() {
- LogCodeP(paste0("plottedTree <- trees[[", whichTree(), "]]"))
+ if (whichTree() > 0) {
+ LogCodeP(paste0("plottedTree <- trees[[", whichTree(), "]]"))
+ } else {
+ LogCodeP("plottedTree <- Consensus(trees, p = 1)")
+ }
LogUserRoot("plottedTree")
if (!("tipsRight" %in% input$mapDisplay)) {
LogCommentP("Set uniform edge length", 0)
@@ -2109,7 +2116,9 @@ server <- function(input, output, session) {
CharacterwisePlot <- function() {
par(mar = rep(0, 4), cex = 0.9)
n <- PlottedChar()
- LogMsg("Plotting PlottedTree(", whichTree(), ", ", n, ")")
+ if (whichTree() > 0) {
+ LogMsg("Plotting PlottedTree(", whichTree(), ", ", n, ")")
+ }
r$plottedTree <- PlottedTree()
if (length(n) && n > 0L) {
pc <- tryCatch({
@@ -2121,10 +2130,21 @@ server <- function(input, output, session) {
(192 * extraLen[r$plottedTree$tip.label] / max(extraLen)) + 1
]
}
- PlotCharacter(r$plottedTree, r$dataset, n,
- edge.width = 2.5,
- updateTips = "updateTips" %in% input$mapDisplay,
- tip.color = roguishness)
+ PlotCharacter(
+ if (whichTree() > 0) r$plottedTree else lapply(r$trees, UserRoot),
+ r$dataset,
+ n,
+ edge.width = 2.5,
+ updateTips = "updateTips" %in% input$mapDisplay,
+ tip.color = roguishness,
+ Display = function(tr) {
+ tr <- UserRoot(tr)
+ if (unitEdge()) {
+ tr$edge.length <- rep.int(1, dim(tr$edge)[[1]])
+ }
+ SortEdges(tr)
+ }
+ )
if (max(extraLen) > 0) {
PlotTools::SpectrumLegend(
"bottomleft", bty = "n",
@@ -2137,6 +2157,8 @@ server <- function(input, output, session) {
}
},
error = function (cond) {
+ message("ASHOGAIH")
+ message(cond)
cli::cli_alert_danger(cond)
Notification(type = "error",
"Could not match dataset to taxa in trees")
@@ -2167,13 +2189,20 @@ server <- function(input, output, session) {
BeginLogP()
LogPar()
n <- PlottedChar()
- LogComment(paste("Select tree", whichTree(), "from tree set"))
+ if (whichTree() > 0) {
+ LogComment(paste("Select tree", whichTree(), "from tree set"))
+ }
LogPlottedTree()
if (length(n) && n > 0L) {
- LogCommentP(paste("Map character", n, "onto tree", whichTree()))
+ if (whichTree() > 0) {
+ LogCommentP(paste("Map character", n, "onto tree", whichTree()))
+ } else {
+ LogCommentP(paste("Map character", n, "onto consensus tree"))
+ }
LogCodeP(
"PlotCharacter(",
- " tree = plottedTree,",
+ if (whichTree() > 0) " tree = plottedTree," else
+ paste0(" tree = RootTree(trees, ", EnC(r$outgroup), "),"),
" dataset = dataset,",
paste0(" char = ", n, ","),
paste0(" updateTips = ", "updateTips" %in% input$mapDisplay, ","),
diff --git a/inst/Parsimony/log.lg b/inst/Parsimony/log.lg
new file mode 100644
index 000000000..2d5135556
--- /dev/null
+++ b/inst/Parsimony/log.lg
@@ -0,0 +1,84 @@
+2025-02-14 13:02:01
+ Started server
+2025-02-14 13:02:02
+ UpdateDroppedTaxaDisplay()
+2025-02-14 13:02:02
+ DroppedTips()
+2025-02-14 13:02:02
+ KeptTips()
+2025-02-14 13:02:02
+ dropSeq()
+2025-02-14 13:02:02
+ UpdateData(): from package
+2025-02-14 13:02:03
+ UpdateAllTrees()
+2025-02-14 13:02:03
+ UpdateTreeRange([1, 1] -> [1, 125])
+2025-02-14 13:02:03
+ UpdateNTree(0 -> 48)
+2025-02-14 13:02:03
+ UpdateActiveTrees()
+2025-02-14 13:02:03
+ DisplayTreeScores()
+2025-02-14 13:02:03
+ scores(): Recalculating scores with k = 10
+2025-02-14 13:02:03
+ UpdateKeepNTipsRange(0 -> 54)
+2025-02-14 13:02:03
+ nNonRogues()
+2025-02-14 13:02:03
+ nNonRogues: 49
+2025-02-14 13:02:03
+ UpdateDroppedTaxaDisplay()
+2025-02-14 13:02:03
+ DroppedTips()
+2025-02-14 13:02:03
+ KeptTips()
+2025-02-14 13:02:03
+ dropSeq()
+2025-02-14 13:02:03
+ UpdateExcludedTipsInput()
+2025-02-14 13:02:03
+ UpdateOutgroupInput()
+2025-02-14 13:02:03
+ /UpdateAllTrees()
+2025-02-14 13:02:03
+ DisplayTreeScores()
+2025-02-14 13:02:03
+ renderUI(branchLegend)
+2025-02-14 13:02:03
+ /renderUI(branchLegend)
+2025-02-14 13:02:03
+ MainPlot()
+2025-02-14 13:02:03
+ ConsensusPlot()
+2025-02-14 13:02:03
+ LabelConcordance()
+2025-02-14 13:02:03
+ /ConsensusPlot()
+2025-02-14 13:02:03
+ renderUI(branchLegend)
+2025-02-14 13:02:03
+ /renderUI(branchLegend)
+2025-02-14 13:02:03
+ MainPlot()
+2025-02-14 13:02:03
+ ConsensusPlot()
+2025-02-14 13:02:03
+ LabelConcordance()
+2025-02-14 13:02:03
+ /ConsensusPlot()
+2025-02-14 13:02:05
+ MainPlot()
+2025-02-14 13:02:06
+ LabelConcordance()
+2025-02-14 13:02:06
+ UpdateDroppedTaxaDisplay()
+2025-02-14 13:02:07
+ MainPlot()
+2025-02-14 13:02:07
+ Plotting PlottedTree(5, 1)
+2025-02-14 13:02:07
+ LabelConcordance()
+2025-02-14 13:02:13
+ Session has ended
diff --git a/man/PlotCharacter.Rd b/man/PlotCharacter.Rd
index 48652e11b..4458c6157 100644
--- a/man/PlotCharacter.Rd
+++ b/man/PlotCharacter.Rd
@@ -21,6 +21,7 @@ PlotCharacter(
plainLty = par("lty"),
tipOffset = 1,
unitEdge = FALSE,
+ Display = function(tree) tree,
...
)
@@ -38,6 +39,7 @@ PlotCharacter(
plainLty = par("lty"),
tipOffset = 1,
unitEdge = FALSE,
+ Display = function(tree) tree,
...
)
@@ -55,6 +57,7 @@ PlotCharacter(
plainLty = par("lty"),
tipOffset = 1,
unitEdge = FALSE,
+ Display = function(tree) tree,
...
)
@@ -72,6 +75,7 @@ PlotCharacter(
plainLty = par("lty"),
tipOffset = 1,
unitEdge = FALSE,
+ Display = function(tree) tree,
...
)
}
@@ -101,6 +105,9 @@ to apply to ambiguous, inapplicable and applicable tokens. See the \code{lty}
\item{unitEdge}{Logical: Should all edges be plotted with a unit length?}
+\item{Display}{Function that takes argument \code{tree} and returns a tree
+of class \code{phylo}, formatted as it will be plotted.}
+
\item{\dots}{Further arguments to pass to \code{plot.phylo()}.}
}
\value{
From 9afd6db3b45e2184985de89460886812014e57eb Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 13:06:45 +0000
Subject: [PATCH 17/26] Log Display()
---
inst/Parsimony/app.R | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/inst/Parsimony/app.R b/inst/Parsimony/app.R
index 3715ef18d..b348e73de 100644
--- a/inst/Parsimony/app.R
+++ b/inst/Parsimony/app.R
@@ -2206,6 +2206,11 @@ server <- function(input, output, session) {
" dataset = dataset,",
paste0(" char = ", n, ","),
paste0(" updateTips = ", "updateTips" %in% input$mapDisplay, ","),
+ " Display = function(tr) {",
+ paste0(" tr <- RootTree(tr, ", EnC(r$outgroup), ")"),
+ " tr$edge.length <- rep.int(2, nrow(tr$edge))",
+ " SortTree(tr)",
+ " },",
" edge.width = 2.5",
")"
)
From 28e39512fed154a43f01bb7971cdf2caa37ce85f Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 13:46:35 +0000
Subject: [PATCH 18/26] =?UTF-8?q?::=E2=86=92:?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
R/TaxonInfluence.R | 2 +-
man/TaxonInfluence.Rd | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/R/TaxonInfluence.R b/R/TaxonInfluence.R
index 1c7bd43a9..d7be0e3e3 100644
--- a/R/TaxonInfluence.R
+++ b/R/TaxonInfluence.R
@@ -44,7 +44,7 @@
#' If `NULL`, an optimal tree will be sought using parsimony search with
#' the parameters provided in \code{\dots}.
#' @param Distance Function to calculate tree distance; default:
-#' \link[TreeDist::ClusteringInfoDistance]{`ClusteringInfoDistance()`}.
+#' \link[TreeDist:ClusteringInfoDistance]{`ClusteringInfoDistance()`}.
#' @param calcWeighted Logical specifying whether to compute the
#' distance-weighted mean value.
#' @param savePath Character giving prefix of path to which reduced trees will
diff --git a/man/TaxonInfluence.Rd b/man/TaxonInfluence.Rd
index 5f8d81a0f..96e708314 100644
--- a/man/TaxonInfluence.Rd
+++ b/man/TaxonInfluence.Rd
@@ -27,7 +27,7 @@ If \code{NULL}, an optimal tree will be sought using parsimony search with
the parameters provided in \code{\dots}.}
\item{Distance}{Function to calculate tree distance; default:
-\link[TreeDist::ClusteringInfoDistance]{\code{ClusteringInfoDistance()}}.}
+\link[TreeDist:ClusteringInfoDistance]{\code{ClusteringInfoDistance()}}.}
\item{calcWeighted}{Logical specifying whether to compute the
distance-weighted mean value.}
From 913a9292821b31db71dd2803c958e44d40ac7ddc Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Fri, 14 Feb 2025 13:57:08 +0000
Subject: [PATCH 19/26] \code{}
---
R/TaxonInfluence.R | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/R/TaxonInfluence.R b/R/TaxonInfluence.R
index d7be0e3e3..5e64c06e6 100644
--- a/R/TaxonInfluence.R
+++ b/R/TaxonInfluence.R
@@ -44,7 +44,7 @@
#' If `NULL`, an optimal tree will be sought using parsimony search with
#' the parameters provided in \code{\dots}.
#' @param Distance Function to calculate tree distance; default:
-#' \link[TreeDist:ClusteringInfoDistance]{`ClusteringInfoDistance()`}.
+#' \link[TreeDist:ClusteringInfoDistance]{\code{ClusteringInfoDistance()}}.
#' @param calcWeighted Logical specifying whether to compute the
#' distance-weighted mean value.
#' @param savePath Character giving prefix of path to which reduced trees will
From d3abc89bb4e7e8d775fa8f3160877499ee8f4aab Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Mon, 17 Feb 2025 10:40:16 +0000
Subject: [PATCH 20/26] Fix all-same-state case
Partially resolves #182
---
R/PlotCharacter.R | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/R/PlotCharacter.R b/R/PlotCharacter.R
index e55bce197..14d31a7ca 100644
--- a/R/PlotCharacter.R
+++ b/R/PlotCharacter.R
@@ -504,7 +504,8 @@ PlotCharacter.multiPhylo <- function(tree, dataset, char = 1L,
}
consClades <- .TreeClades(consTree)
.Recon <- function(i) {
- reconstructions[[i]][match(consClades, .TreeClades(tree[[i]])), ]
+ reconstructions[[i]][
+ match(consClades, .TreeClades(tree[[i]])), , drop = FALSE]
}
recon <- matrix(FALSE, nrow = length(consClades), ncol = length(tokens),
dimnames = list(NULL, tokens))
From 295a3a399dad4566d38dc5a68828255dae7bd41d Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Mon, 17 Feb 2025 10:40:16 +0000
Subject: [PATCH 21/26] Fix all-same-state case
Partially resolves #182
---
tests/testthat/test-PlotCharacter.R | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index a0ebe9db9..3ffabee8c 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -136,18 +136,17 @@ test_that("Out-of-sequence works", {
test_that("PlotCharacter.multi()", {
Bal <- TreeTools::BalancedTree
+ a..h <- letters[1:8]
expect_error(PlotCharacter(list(Bal(8), 9), "dataset"), "class `phylo`")
expect_error(PlotCharacter(list(Bal(8), Bal(9)), "dataset"),
"same tip labels")
- expect_error(PlotCharacter(list(Bal(8), Bal(letters[1:8])), "dataset"),
+ expect_error(PlotCharacter(list(Bal(8), Bal(a..h)), "dataset"),
"same tip labels")
trees <- ape::read.tree(text = c("(a, (b, (c, (d, ((g, h), (e, f))))));",
"(a, (b, (c, ((d, e), (f, (g, h))))));"))
-
- str <- "00011011"
- dat <- TreeTools::StringToPhyDat(str, tips = letters[1:8])
+ dat <- TreeTools::StringToPhyDat("00011011", tips = a..h)
expect_equal(PlotCharacter(trees[1], dat, plot = FALSE),
PlotCharacter(trees[[1]], dat, plot = FALSE))
@@ -159,9 +158,13 @@ test_that("PlotCharacter.multi()", {
state2[c(match(TipLabels(trees[[1]]), TipLabels(trees[[2]])),
9:12, 15), ])
+
skip_if_not_installed("vdiffr")
- vdiffr::expect_doppelganger("PlotChar_consensus", function () {
+ vdiffr::expect_doppelganger("PlotChar_consensus", function() {
+ par(mfrow = c(2, 2), mar = rep(0, 4))
PlotCharacter(trees, dat)
+ inv <- TreeTools::StringToPhyDat("00000000", tips = a..h)
+ PlotCharacter(trees, inv)
}
)
})
From 11119071ebaef5d8971a0a1c9daa336c4f16baad Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Mon, 17 Feb 2025 10:44:28 +0000
Subject: [PATCH 22/26] invariant-ambig case
We expect all states to be mapped to 0, as it's unparsimonious to propose an additional state.
Still feels unsatisfactory though..?
---
.../PlotCharacter/plotchar-invar-ambig.svg | 80 +++++++++++++++++++
.../PlotCharacter/plotchar-invariant.svg | 80 +++++++++++++++++++
tests/testthat/test-PlotCharacter.R | 10 ++-
3 files changed, 167 insertions(+), 3 deletions(-)
create mode 100644 tests/testthat/_snaps/PlotCharacter/plotchar-invar-ambig.svg
create mode 100644 tests/testthat/_snaps/PlotCharacter/plotchar-invariant.svg
diff --git a/tests/testthat/_snaps/PlotCharacter/plotchar-invar-ambig.svg b/tests/testthat/_snaps/PlotCharacter/plotchar-invar-ambig.svg
new file mode 100644
index 000000000..93be3ac5a
--- /dev/null
+++ b/tests/testthat/_snaps/PlotCharacter/plotchar-invar-ambig.svg
@@ -0,0 +1,80 @@
+
+
diff --git a/tests/testthat/_snaps/PlotCharacter/plotchar-invariant.svg b/tests/testthat/_snaps/PlotCharacter/plotchar-invariant.svg
new file mode 100644
index 000000000..93be3ac5a
--- /dev/null
+++ b/tests/testthat/_snaps/PlotCharacter/plotchar-invariant.svg
@@ -0,0 +1,80 @@
+
+
diff --git a/tests/testthat/test-PlotCharacter.R b/tests/testthat/test-PlotCharacter.R
index 3ffabee8c..9f6c4dba6 100644
--- a/tests/testthat/test-PlotCharacter.R
+++ b/tests/testthat/test-PlotCharacter.R
@@ -161,10 +161,14 @@ test_that("PlotCharacter.multi()", {
skip_if_not_installed("vdiffr")
vdiffr::expect_doppelganger("PlotChar_consensus", function() {
- par(mfrow = c(2, 2), mar = rep(0, 4))
PlotCharacter(trees, dat)
+ })
+ vdiffr::expect_doppelganger("PlotChar_invariant", function() {
inv <- TreeTools::StringToPhyDat("00000000", tips = a..h)
PlotCharacter(trees, inv)
- }
- )
+ })
+ vdiffr::expect_doppelganger("PlotChar_invar_ambig", function() {
+ invq <- TreeTools::StringToPhyDat("000?00?{01}", tips = a..h)
+ PlotCharacter(trees, invq)
+ })
})
From cbdc380811c2fd99671e446ba7fdc42af518a646 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Mon, 17 Feb 2025 10:46:51 +0000
Subject: [PATCH 23/26] code-link
---
R/data.R | 2 +-
man/inapplicable.datasets.Rd | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/R/data.R b/R/data.R
index 9057d60ea..5ba9a21db 100644
--- a/R/data.R
+++ b/R/data.R
@@ -6,7 +6,7 @@
#' Datasets are sorted into two subsets, each sorted alphabetically;
#' the first subset comprise simpler datasets with faster processing times.
#' `inapplicable.datasets` provide the data in the matrix format generated by
-#' \link[ape:read.nexus.data]{`read.nexus.data()`};
+#' \code{\link[ape:read.nexus.data]{read.nexus.data()}};
#' `inapplicable.phyData` are in \code{phyDat} format.
#' `inapplicable.trees` lists for each dataset a sample of up to 50 trees
#' obtained by tree search under each inapplicable treatment, named accordingly.
diff --git a/man/inapplicable.datasets.Rd b/man/inapplicable.datasets.Rd
index b8383f699..3357379e7 100644
--- a/man/inapplicable.datasets.Rd
+++ b/man/inapplicable.datasets.Rd
@@ -146,7 +146,7 @@ The name of each item corresponds to the datasets listed below.
Datasets are sorted into two subsets, each sorted alphabetically;
the first subset comprise simpler datasets with faster processing times.
\code{inapplicable.datasets} provide the data in the matrix format generated by
-\link[ape:read.nexus.data]{\code{read.nexus.data()}};
+\code{\link[ape:read.nexus.data]{read.nexus.data()}};
\code{inapplicable.phyData} are in \code{phyDat} format.
\code{inapplicable.trees} lists for each dataset a sample of up to 50 trees
obtained by tree search under each inapplicable treatment, named accordingly.
From 2d1deccaffde97c0610b4cba22ab26bf2e651c5a Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Mon, 17 Feb 2025 10:48:59 +0000
Subject: [PATCH 24/26] code-link
---
R/MaximizeParsimony.R | 2 +-
R/TaxonInfluence.R | 2 +-
man/AdditionTree.Rd | 2 +-
man/MaximizeParsimony.Rd | 2 +-
man/TaxonInfluence.Rd | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/R/MaximizeParsimony.R b/R/MaximizeParsimony.R
index 9f8178ee6..f3af826b3 100644
--- a/R/MaximizeParsimony.R
+++ b/R/MaximizeParsimony.R
@@ -79,7 +79,7 @@
#' returned trees will be perfectly compatible with each character in
#' `constraint`; or a tree of class `phylo`, all of whose nodes will occur
#' in any output tree.
-#' See \link[TreeTools:ImposeConstraint]{`ImposeConstraint()`} and
+#' See \code{\link[TreeTools:ImposeConstraint]{ImposeConstraint()}} and
#' [vignette](https://ms609.github.io/TreeSearch/articles/tree-search.html)
#' for further examples.
#' @param verbosity Integer specifying level of messaging; higher values give
diff --git a/R/TaxonInfluence.R b/R/TaxonInfluence.R
index 5e64c06e6..125b369ed 100644
--- a/R/TaxonInfluence.R
+++ b/R/TaxonInfluence.R
@@ -44,7 +44,7 @@
#' If `NULL`, an optimal tree will be sought using parsimony search with
#' the parameters provided in \code{\dots}.
#' @param Distance Function to calculate tree distance; default:
-#' \link[TreeDist:ClusteringInfoDistance]{\code{ClusteringInfoDistance()}}.
+#' \code{\link[TreeDist:ClusteringInfoDistance]{ClusteringInfoDistance()}}.
#' @param calcWeighted Logical specifying whether to compute the
#' distance-weighted mean value.
#' @param savePath Character giving prefix of path to which reduced trees will
diff --git a/man/AdditionTree.Rd b/man/AdditionTree.Rd
index 837d76fe7..0f211a640 100644
--- a/man/AdditionTree.Rd
+++ b/man/AdditionTree.Rd
@@ -25,7 +25,7 @@ approaches
returned trees will be perfectly compatible with each character in
\code{constraint}; or a tree of class \code{phylo}, all of whose nodes will occur
in any output tree.
-See \link[TreeTools:ImposeConstraint]{\code{ImposeConstraint()}} and
+See \code{\link[TreeTools:ImposeConstraint]{ImposeConstraint()}} and
\href{https://ms609.github.io/TreeSearch/articles/tree-search.html}{vignette}
for further examples.}
diff --git a/man/MaximizeParsimony.Rd b/man/MaximizeParsimony.Rd
index 5c476c19d..9af184e8a 100644
--- a/man/MaximizeParsimony.Rd
+++ b/man/MaximizeParsimony.Rd
@@ -110,7 +110,7 @@ in search results, which may improve the accuracy of the consensus tree
returned trees will be perfectly compatible with each character in
\code{constraint}; or a tree of class \code{phylo}, all of whose nodes will occur
in any output tree.
-See \link[TreeTools:ImposeConstraint]{\code{ImposeConstraint()}} and
+See \code{\link[TreeTools:ImposeConstraint]{ImposeConstraint()}} and
\href{https://ms609.github.io/TreeSearch/articles/tree-search.html}{vignette}
for further examples.}
diff --git a/man/TaxonInfluence.Rd b/man/TaxonInfluence.Rd
index 96e708314..d3add87fd 100644
--- a/man/TaxonInfluence.Rd
+++ b/man/TaxonInfluence.Rd
@@ -27,7 +27,7 @@ If \code{NULL}, an optimal tree will be sought using parsimony search with
the parameters provided in \code{\dots}.}
\item{Distance}{Function to calculate tree distance; default:
-\link[TreeDist:ClusteringInfoDistance]{\code{ClusteringInfoDistance()}}.}
+\code{\link[TreeDist:ClusteringInfoDistance]{ClusteringInfoDistance()}}.}
\item{calcWeighted}{Logical specifying whether to compute the
distance-weighted mean value.}
From df7f4aa7fa9da6ee026b3154fe6cb3c004ff6c45 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Mon, 17 Feb 2025 12:16:30 +0000
Subject: [PATCH 25/26] code-link
---
R/TaxonInfluence.R | 2 +-
man/TaxonInfluence.Rd | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/R/TaxonInfluence.R b/R/TaxonInfluence.R
index 125b369ed..69f7acb86 100644
--- a/R/TaxonInfluence.R
+++ b/R/TaxonInfluence.R
@@ -48,7 +48,7 @@
#' @param calcWeighted Logical specifying whether to compute the
#' distance-weighted mean value.
#' @param savePath Character giving prefix of path to which reduced trees will
-#' be saved (with \link[ape:write.nexus]{`write.nexus()`}).
+#' be saved (with \code{\link[ape:write.nexus]{write.nexus()}}).
#' File names will follow the pattern
#' `paste0(savePath, droppedTaxonName, ".nex")`; `savePath` should thus contain
#' a trailing `/` if writing to a directory, which will be created if it does
diff --git a/man/TaxonInfluence.Rd b/man/TaxonInfluence.Rd
index d3add87fd..c3e36b586 100644
--- a/man/TaxonInfluence.Rd
+++ b/man/TaxonInfluence.Rd
@@ -33,7 +33,7 @@ the parameters provided in \code{\dots}.}
distance-weighted mean value.}
\item{savePath}{Character giving prefix of path to which reduced trees will
-be saved (with \link[ape:write.nexus]{\code{write.nexus()}}).
+be saved (with \code{\link[ape:write.nexus]{write.nexus()}}).
File names will follow the pattern
\code{paste0(savePath, droppedTaxonName, ".nex")}; \code{savePath} should thus contain
a trailing \code{/} if writing to a directory, which will be created if it does
From d52c93bb6e482996dba10f47a2aaa2773716fff1 Mon Sep 17 00:00:00 2001
From: RevBayes analysis <1695515+ms609@users.noreply.github.com>
Date: Mon, 17 Feb 2025 12:29:35 +0000
Subject: [PATCH 26/26] code-link
---
R/TaxonInfluence.R | 3 ++-
man/TaxonInfluence.Rd | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/R/TaxonInfluence.R b/R/TaxonInfluence.R
index 69f7acb86..d4a520226 100644
--- a/R/TaxonInfluence.R
+++ b/R/TaxonInfluence.R
@@ -53,7 +53,8 @@
#' `paste0(savePath, droppedTaxonName, ".nex")`; `savePath` should thus contain
#' a trailing `/` if writing to a directory, which will be created if it does
#' not exist. Special characters will be removed from leaf labels when
-#' creating the file path (using \link[fs:path_sanitize]{`path_sanitize()`}).
+#' creating the file path (using
+#' \code{\link[fs:path_sanitize]{path_sanitize()}}).
#' If `NULL`, computed trees will not be saved.
#' @param useCache Logical vector; if `TRUE`, previous tree search results will
#' be loaded from the location given by `savePath`, instead of running a fresh
diff --git a/man/TaxonInfluence.Rd b/man/TaxonInfluence.Rd
index c3e36b586..6c1875d4f 100644
--- a/man/TaxonInfluence.Rd
+++ b/man/TaxonInfluence.Rd
@@ -38,7 +38,8 @@ File names will follow the pattern
\code{paste0(savePath, droppedTaxonName, ".nex")}; \code{savePath} should thus contain
a trailing \code{/} if writing to a directory, which will be created if it does
not exist. Special characters will be removed from leaf labels when
-creating the file path (using \link[fs:path_sanitize]{\code{path_sanitize()}}).
+creating the file path (using
+\code{\link[fs:path_sanitize]{path_sanitize()}}).
If \code{NULL}, computed trees will not be saved.}
\item{useCache}{Logical vector; if \code{TRUE}, previous tree search results will