Pages

Tuesday, June 28, 2016

Not long after submitting a new version of phytools (phytools 0.5-38) to CRAN,
which has been accepted, I discovered a weird bug in the interactive function
collapseTree. collapseTree is interactive, so it
is kind of hard to demo; however, a video of it's use can be seen
here.

The bug is due to the plotrix function draw.circle either no longer
being vectorized or not being correctly vectorized. I essentially fixed this
by substituting:

Finally, a new interactive version of phylo.toBackbone to permit a backbone
tree with subtrees plotted as triangles to be created interactively, rather than via a
static translation table
(here).

These updates are already on CRAN - but it will probably take a couple of days for binaries to be
built and percolate through the mirror repositories. In the meantime, as always, phytools can be
installed from GitHub. Enjoy!

I just created a new interactive version of the phytools function
phylo.toBackbone, which creates a backbone phylogeny in which some
clades are represented as triangles. This tree can then we plotted with an
S3 plot method for the object class "backbonePhylo".
Most of the code changes can be seen
here.
The updates are kind of hacky - principally because the original version of this
appears to have been coded by me in 2013.

In previous versions of this function (e.g.,
1,
2)
the user had to supply the backbone tree as input along with a translation
table. This is still possible, or course; however the current version allows
the user to collapse clades into triangles by clicking on the fully plotted
tree. This should be a nice feature for some users.

Obviously, interactive mode is kind of difficult to demonstrate - consequently
I have embedded a screenshot video of a demo at the bottom. The following
is just an illustration of the product. Remember for publication to save to
PDF (or another line art format) to avoid aliasing, particularly on the edges
of the triangles.

Saturday, June 11, 2016

I just
pushed
a small update to roundPhylogram that permits different line
types (lty) and line widths (lwd) to be specified
for different branches of the tree. This will be done whenever either
argument is supplied as a vector instead of as a single scalar value or
(in the case of lty) as a character string.

I did this so that I could plot taxa with ambiguous phylogenetic placement
(say) using a dotted line. Note that it would also be straightforward to
do this in functions using plotSimmap or the internal function
phylogram, but this does not yet exist. It may exist in
the generic S3 plot method for objects of class
"phylo". I don't know, but I wouldn't be surprised.

Tuesday, June 7, 2016

A phytools user, Bruno Vilela,
recently reported the bug that the phytools function contMap
can fail for very short internal edges. This tends to be the case when
an edge has a length that is less than 1/res × the tree
height, in which res is an argument of contMap
specifying the graininess of the color gradient to be plotted along edges.

[Actually, I believe I already fixed this bug except for edges descended
from the root node. This is because for those edges the function will
attempt to create a list of mappings along edges, but create a vector instead.
Silly!]

I have previously suggested collapsing very short internal edges or increasing
res; however Bruno did one better by providing an incredibly
simple solution, which was to create a list of mappings along edges before
iterating across the edges of the tree to compute the mappings. Perhaps
obvious in retrospect, please keep in mind that I wrote the first version of
this function in 2012 when I was quite an R programming novice. (I'm not sure
what I'd call myself now. Slightly more than an a novice? I guess in an era
when
Donald
Trump is running for present I'm a world-class R programming expert!)

Here's a quick demo of the problem, along with a demonstration that
Bruno's
fix
does indeed restore function:

This fix also allows us to set the value of res to any
arbitrarily low value. Although the resultant plot is grainier, this might
nonetheless be useful for users working with very large trees where
computation is an issue.

About this blog

This web-log chronicles the development of new tools for phylogenetic analyses in the phytools R package. Unless you a reading a very recent page of the blog, I recommend that you install the latest CRAN version of phytools (or latest beta release) before attempting to replicate any of the analyses of this site. That is because the linked functions may be archived, and very likely have been replaced by newer versions.