Monday, August 28, 2017

Bug fix in plot.cophylo for co-phylogenetic plotting

I just fixed a tiny, but nonetheless super-annoying, bug in the S3 plot method for "cophylo" class objects.

The bug was introduced when I added user control of edge colors, and only manifests if the right-side (& thus left-facing) tree has more edges than the left-side tree.

Here is what it looks like:

library(phytools)
t1
## 
## Phylogenetic tree with 20 tips and 19 internal nodes.
## 
## Tip labels:
##  t9, t17, t3, t2, t10, t16, ...
## 
## Rooted; includes branch lengths.
t2
## 
## Phylogenetic tree with 26 tips and 25 internal nodes.
## 
## Tip labels:
##  T, J, P, H, U, W, ...
## 
## Rooted; includes branch lengths.
assoc
##     t1 t2
## 1   t3  K
## 2  t10  A
## 3   t8  Z
## 4  t14  O
## 5  t13  J
## 6   t9  S
## 7  t15  L
## 8   t1  T
## 9  t18  G
## 10  t7  Q
## 11 t14  M
## 12 t18  Y
## 13 t13  B
## 14  t5  V
## 15  t5  X
## 16  t1  U
obj<-cophylo(t1,t2,assoc)
## Rotating nodes to optimize matching...
## Done.
plot(obj,link.type="curved")

plot of chunk unnamed-chunk-1

Obviously, that's no good.

Here I'll load the fix from source, but all users need do is update phytools from GitHub using devtools:

source("https://raw.githubusercontent.com/liamrevell/phytools/master/R/cophylo.R")
plot(obj,link.type="curved")

plot of chunk unnamed-chunk-2

To update phytools from GitHub, one can run the following lines:

library(devtools) ## with devtools installed from CRAN
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.