ArtPoon/ggfree

tree: draw.clade doesn't work for rectangular layout

Closed this issue · 3 comments

This is a tree I reconstructed from some SARS-CoV-2 genomes:

> phy <- read.tree('~/git/covizu/data/timetree.nwk')
> phy

Phylogenetic tree with 263 tips and 177 internal nodes.

Tip labels:
  B.6.1, B.5, B.17, B.4, B.4.1, B.4.2, ...
Node labels:
  NODE_0000002, NODE_0000215, NODE_0000216, NODE_0000217, NODE_0000222, NODE_0000223, ...

Rooted; includes branch lengths.

This works fine for unrooted tree layout:

> tips <- c("B.5", 'B.2.1', 'B.9')
> L <- tree.layout(phy, 'u')
> plot(L)
> draw.clade(L, tips, lwd=2)

Screen Shot 2020-11-17 at 10 40 38 PM

But it messes up for rect layout:

> L <- tree.layout(phy, 'r')
Warning message:
In as.phyloData(phy, unscaled) :
  as.phyloData ignoring attribute root.edge of length 1
> plot(L)
> draw.clade(L, tips, lwd=2)

Screen Shot 2020-11-17 at 10 41 37 PM

Probably has to do with reversal of parent and child ordering with different placement of "root".

This appears to be fixed with resolution of #30

require(ggfree)
set.seed(1)
phy <- rtree(20)
L <- tree.layout(phy, 'u')
plot(L)
draw.clade(L, tips=c('t10', 't20', 't7'), lwd=1.5)

L <- tree.layout(phy, 'r')
plot(L)
draw.clade(L, tips=c('t10', 't20', 't7'), lwd=1.5)

However this function is not drawing vertical line segments

Got this working for circular layouts too:

L <- tree.layout(phy, 'o')
plot(L)
draw.clade(L, tips=c('t10', 't20', 't7'), lwd=1.5)