Tuesday, November 29, 2016

Some updates to phytools

I just pushed a series of updates (1, 2, 3, 4) to fix some issues raised by the authors of ape and phangorn in advance of the submission of new CRAN versions of those two packages.

The first was that I had inadvertently corrupted an S3 method multi2di of ape when I created the function multi2di.simmap without exporting a method to the namespace. The other issues came up in R CMD check and included such things as failing to import various functions from dependencies, other problems with the namespace, errors in documenting various variables, the absence of a manual page for one function (likSurface.rateshift) that is exported by phytools, and a few problems with the R code of some new functions.

I too hope to update the version of phytools on CRAN as the current version dates to June.

The latest phytools version can be installed from GitHub using devtools as follows:

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

Since both phangorn & ape are in the process of being updated, but phytools depends on the latest version of neither, you may need to do:

install_github("liamrevell/phytools",upgrade_dependencies=FALSE)

That's it.

Friday, November 18, 2016

Updates to permit user control of line end types in plotSimmap

I recently made a couple of small updates to plotSimmap - firstly, to allow user control of the line end type (lend, as in par); and secondly, for type="fan", to plot the two edges originating from the root as a single segmented line.

Here is a quick example using the latest version of phytools on GitHub:

library(phytools)
packageVersion("phytools")
## [1] '0.5.59'
data(anoletree)
plot(anoletree,lwd=5,ftype="i",fsize=0.5)
## no colors provided. using the following legend:
##        CG        GB        TC        TG        Tr        Tw 
##   "black"     "red"  "green3"    "blue"    "cyan" "magenta"

plot of chunk unnamed-chunk-1

plot(anoletree,lwd=5,ftype="i",fsize=0.5,lend=0) ## curved
## no colors provided. using the following legend:
##        CG        GB        TC        TG        Tr        Tw 
##   "black"     "red"  "green3"    "blue"    "cyan" "magenta"

plot of chunk unnamed-chunk-1

plot(anoletree,lwd=5,ftype="i",fsize=0.5,lend=1) ## mitered
## no colors provided. using the following legend:
##        CG        GB        TC        TG        Tr        Tw 
##   "black"     "red"  "green3"    "blue"    "cyan" "magenta"

plot of chunk unnamed-chunk-1

Or as type="fan"

plot(anoletree,lwd=5,ftype="i",fsize=0.8,lend=1,type="fan")
## no colors provided. using the following legend:
##        CG        GB        TC        TG        Tr        Tw 
##   "black"     "red"  "green3"    "blue"    "cyan" "magenta"
cols<-setNames(palette()[1:length(unique(getStates(anoletree,
    "tips")))],
    sort(unique(getStates(anoletree,"tips"))))
add.simmap.legend(colors=cols,x=0.9*par()$usr[1],
    y=0.9*par()$usr[4],prompt=FALSE,fsize=0.9)

plot of chunk unnamed-chunk-2

Note that the 'pixelation' (aka. aliasing) is just an effect of the rendering and disappears if the plot is rendered as a PDF, e.g.:

Finally, the purpose of plotting the two lines originating at the root as a single segmented line is the eliminate what can be an ugly overlap of the two daughter edges when plotted separately:

plotTree(tree,type="fan",lwd=4,part=0.5,lend=1,fsize=0.5)

plot of chunk unnamed-chunk-3

or:

(rendered more nicely).

That's it.