YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/contribution-tree-data/
838 stars 173 forks source link

geom_cladelab doesn't facet #603

Open dansmith01 opened 7 months ago

dansmith01 commented 7 months ago
# Create two trees of different sizes; label nodes that aren't common to both.
set.seed(0)
lg  <- full_join(by = "node", rtree(5), data.frame(node = c(7, 9), clade = c("A", "B")))
sm  <- full_join(by = "node", rtree(3), data.frame(node = 5, clade = "C"))
trs <- structure(list(lg = lg, sm = sm), class = "treedataList")

# Internal clade labels with geom_label() works fine.
ggtree(trs) + 
  geom_label(data = td_filter(!is.na(clade)), mapping = aes(label = clade)) + 
  facet_wrap(~.id)

Rplot03

# External clade label with geom_cladelab() doesn't work:
ggtree(trs) + 
  geom_cladelab(data = td_filter(!is.na(clade)), mapping = aes(node = node, label = clade)) + 
  facet_wrap(~.id)

> Warning message:
> In x$node != rn :
>   longer object length is not a multiple of shorter object length

Note that the warning message only shows up after force-quitting the process, which seems to be in a CPU-heavy infinite loop.