Closed dominicev closed 2 years ago
Dear @dominicev,
the function still works, but you used the wrong index:
plot(tree)
nodelabels()
nodes 1:Ntip(tree)
are the tips and Ntip(tree) + 1:Nnode(tree)
are the the internal nodes.
The if you want to collapse the i
-th node label the index is i + Ntip(tree)
E.g.
plot(wasp.trees[[2]])
nodelabels()
{newTree<-collapse.to.star(wasp.trees[[2]], 5+Ntip(wasp.trees[[2]]) )
plot(newTree, show.tip.label = FALSE, show.node.label=TRUE)}
I also have a function called pruneTree
in phangorn, which might be useful in your case.
I improved it a bit, so you want to install the development version:
remotes::install_github("KlausVigo/phangorn")
library(phangorn)
tree2 <- tree
tree2$node.label[tree2$node.label == ""] <- "0"
tree2$node.label[1] <- ""
tree2 <- pruneTree(tree2, 70)
plot(tree2, show.node.label=TRUE)
Thanks @KlausVigo.
Had some code to collapse branches based on node values which was working fine a few months ago but no longer. No error codes or anything but it simply doesn't return the tree with any of the corresponding nodes collapsed.
Tried updating R and all packages and still, same issue.
Below is an example where the resulting tree has no collapsed nodes.
Even the simple example below doesn't seem to do anything