Friday, June 23, 2017

Fix to read.newick for cases in which some but not all nodes are labeled

It was recently reported that there can be a mismatch between the number of nodes & the length of the node label vector in an object class "phylo" produced by the function read.newick in phytools. This appears to be a bug that is produced when some nodes have labels, but the node with the largest-valued index does not have a label. I just pushed a fix to GitHub & it appears to work. Here's a demo using the case submitted on R-sig-phylo:

library(phytools)
## Loading required package: ape
## Loading required package: maps
packageVersion("phytools")
## [1] '0.6.17'
tree<-read.newick(text='((((((a))A),(((b),(b1)))B)))C;')
tree$edge.length<-rep(1,nrow(tree$edge))
plotTree.singletons(tree)
nodelabels(tree$node.label)

plot of chunk unnamed-chunk-1

That's it.

No comments:

Post a Comment