A phytools user correctly reports that the phytools function
plotTree.singletons
(which, as the function name suggests,
plots trees containing singleton nodes) breaks if more than two edges
emerge from a single node.
For instance:
library(phytools)
text<-"(A:0.1,(S:0.3)B:0.2,(C:0.3,D:0.4)E:0.5)F;"
tree<-read.tree(text=text)
tree ## doesn't work at all
##
## Phylogenetic tree with 4 tips and 3 internal nodes.
##
## Tip labels:
## [1] "A" "S" "B" ""
## Node labels:
## [1] "" "D" "C"
##
## Rooted; includes branch lengths.
tree<-read.newick(text=text)
tree ## read in correctly
##
## Phylogenetic tree with 4 tips and 3 internal nodes.
##
## Tip labels:
## [1] "A" "S" "C" "D"
## Node labels:
## [1] "F" "B" "E"
##
## Unrooted; includes branch lengths.
plotTree.singletons(tree)
## Error in xy.coords(x, y): 'x' and 'y' lengths differ
Ok, the user very helpfully identified a fix in the code to address this issue. I also seem to have found a simpler fix. The code is available here and will also be in the next version of phytools.
Let's plot with the fixed code:
source("map.to.singleton.R")
plotTree.singletons(tree)
OK, that's it.
A most helpful post....thank you!
ReplyDelete