You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using the resolveTreeChar() function with orderedChar = TRUE and stateBias = 'primitive'. Most of the time it works perfectly but every once in a while I get an error. Here's the error from the example below:
Error in testEdgeMat(tree) :
Some elements of edge are numbered greater than 9
calculated from Nnode+length(tree$tip.label)
Check these: 10
I understand what the error is saying, but I'm having difficulty figuring out how to troubleshoot. I can't find a consistent pattern of when it throws an error and when it doesn't. I'm using this function on many trees, so it would be difficult to manually go through and troubleshoot individual ones to make them work (assuming that's even a good idea).
Do you have any thoughts on how to fix this error?
Here is an example where it throws an error with orderedChar = TRUE, but not orderedChar = FALSE (I haven't found an instance where it throws an error with orderedChar = FALSE, but I also haven't tried that hard). And if you change the tips labeled "74" to "31", then it works for both.
library(paleotree)
# example tree that doesn't work for orderedChar = TRUE
example_tree <- structure(list(edge = structure(c(6L, 6L, 6L, 6L, 6L, 1L, 2L, 3L, 4L, 5L), dim = c(5L, 2L)),
edge.length = c(0.0019837977, 0.012936646, 0.0265849463, 0.0033293995, 0.0053513114),
Nnode = 1L, node.label = "", tip.label = c("74", "458", "807", "74", "262")),
class = "phylo", order = "cladewise")
example_trait <- factor(example_tree$tip.label, levels = sort(unique(as.numeric(example_tree$tip.label))))
names(example_trait) <- example_tree$tip.label
# works with orderedChar = FALSE
example_tree_resolved_unordered <- resolveTreeChar(example_tree, example_trait, orderedChar = FALSE)
# doesn't work with orderedChar = TRUE regardless of stateBias. For my use case, I'd like to use stateBias = 'primitive'.
example_tree_resolved_ordered <- resolveTreeChar(example_tree, example_trait, orderedChar = TRUE)
# changing the "74" tip labels to "31" fixes the problem:
example_tree2 <- example_tree
example_tree2$tip.label[example_tree2$tip.label == "74"] <- "31"
example_trait2 <- factor(example_tree2$tip.label, levels = sort(unique(as.numeric(example_tree2$tip.label))))
names(example_trait2) <- example_tree2$tip.label
example_tree_resolved_unordered2 <- resolveTreeChar(example_tree2, example_trait2, orderedChar = FALSE)
example_tree_resolved_ordered2 <- resolveTreeChar(example_tree2, example_trait2, orderedChar = TRUE)
I've been using the
resolveTreeChar()
function withorderedChar = TRUE
andstateBias = 'primitive'
. Most of the time it works perfectly but every once in a while I get an error. Here's the error from the example below:I understand what the error is saying, but I'm having difficulty figuring out how to troubleshoot. I can't find a consistent pattern of when it throws an error and when it doesn't. I'm using this function on many trees, so it would be difficult to manually go through and troubleshoot individual ones to make them work (assuming that's even a good idea).
Do you have any thoughts on how to fix this error?
Here is an example where it throws an error with
orderedChar = TRUE
, but notorderedChar = FALSE
(I haven't found an instance where it throws an error withorderedChar = FALSE
, but I also haven't tried that hard). And if you change the tips labeled "74" to "31", then it works for both.Session info:
The text was updated successfully, but these errors were encountered: