Saturday, March 5, 2016

Bug fixes and updates for phytools; new name for density.tree to fix S3 method incompatibility

I'll be trying to get a new version of phytools on CRAN in advance of the workshop I will be teaching with Transmitting Science in Barcelona next week. Consequently, I just pushed a whole bunch of new updates to GitHub. Most of these pertain to minor bugs & fixes, but I also renamed the function density.tree as densityTree to rectify an unidentified (by me) S3 method incompatibility. This makes it even more confusing to distinguish this function from the similarly named, and similarly purposed, phangorn function densiTree. Both allow the user to visualize a posterior density of phylogenies from (say) a Bayesian analysis; however different plotting methods & options are used internally, and my function (now densityTree) can also plot mapped stochastic character histories. For example:

library(phytools)
packageVersion("phytools")
## [1] '0.5.19'
trees
## 100 phylogenetic trees
x
##   A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R 
## "b" "a" "b" "b" "b" "b" "b" "b" "a" "b" "b" "a" "a" "a" "a" "a" "b" "b" 
##   S   T   U   V   W   X   Y   Z 
## "a" "a" "a" "a" "a" "a" "a" "a"
## make stochastic character histories for x on trees
mtrees<-make.simmap(trees,x,message=FALSE)
mtrees
## 100 phylogenetic trees with mapped discrete characters
## plot posterior density using densityTree
colors<-setNames(c("red","blue"),sort(unique(x)))
densityTree(mtrees,colors=colors,nodes="inner",ftype="i",lwd=5,
    method="plotSimmap")
add.simmap.legend(colors=colors,prompt=FALSE,x=par()$usr[1]+0.1,
    y=par()$usr[4]-1)

plot of chunk unnamed-chunk-1

After I submit to CRAN (hopefully soon) I will post a longer note documenting all the updates from the previous CRAN version. This version of phytools can be obtained from GitHub using the devtools package:

library(devtools)
install_github("liamrevell/phytools")

No comments:

Post a Comment

Note: due to the very large amount of spam, all comments are now automatically submitted for moderation.