Sunday, August 10, 2014

Bug fix in read.simmap

A colleague reported the following bug in read.simmap:

library(phytools)

packageVersion("phytools")

## [1] '0.4.28'

tree<-read.simmap(text= 

"((A:{0,0.3:1,0.4:0,0.3},B:{0,1.0}):{0,1.0},(C:{0,0.25:1,0.75},D:{0,1.0}):{0,1.0});")

## Error: object 'trans' not found

Evidently, I introduced this error at some point by setting trans (the translation table) to be NULL when the tree format was "phylip", rather than "nexus", within a logical statement that first checks if the tree is to be read from file. Oops.

Fortunately this bug is pretty easy to fix. I have posted the updated code here, but users will probably have to install a new version of phytools since read.simmap uses various phytools internals that are not in the read.simmap.R source file.

Let's try it:

detach("package:phytools",unload=TRUE)

install.packages("phytools_0.4-29.tar.gz",type="source")

## Installing package into 'C:/Users/Liam/Documents/R/win-library/3.1'

## (as 'lib' is unspecified)

## inferring 'repos = NULL' from the file name

library(phytools)

tree<-read.simmap(text=

"((A:{0,0.3:1,0.4:0,0.3},B:{0,1.0}):{0,1.0},(C:{0,0.25:1,0.75},D:{0,1.0}):{0,1.0});")

tree

## 

## Phylogenetic tree with 4 tips and 3 internal nodes.

## 

## Tip labels:

## [1] "A" "B" "C" "D"

## 

## Rooted; includes branch lengths.

plotSimmap(tree,colors=setNames(c("blue","red"),0:1),lwd=5)

plot of chunk unnamed-chunk-2

That's it.

BTW, for the first time I am today attempting to create my blog posts using knit2html in the knitr package. I already use this package for creating tutorials for my various R phylogenetic classes & workshops, but this is the first time trying it out on the blog.

No comments:

Post a Comment