ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

geom_inset() does not work with layout_dendrogram()

Open gernat opened this issue 1 year ago • 0 comments
trafficstars

Prerequisites

  • [x] Have you read Feedback and follow the guide?
    • [x] make sure your are using the latest release version
    • [x] read the documents
    • [x] google your question/issue

Describe you issue

  • [x] Make a reproducible example (e.g. 1)
  • [x] your code should contain comments to describe the problem (e.g. what expected and actually happened?)

Ask in right place

  • [x] for bugs or feature requests, post here (github issue)
  • [x] for questions, please post to google group

Many thanks for developing and maintaining such a useful package! When I try to plot pie charts on top of the nodes of a dendrogram, only one chart is shown. Something similar also happens when I use scale_x_reverse() or scale_y_reverse(), but with coord_flip() I get the expected result.

MRE:

# create a random tree with 5 nodes
library(ggtree)
set.seed(1)
tree <- rtree(3)

# create a pie chart for each node
data <- data.frame(node = 1:5, a = sample(1:100, 5), b = sample(1:100, 5))
pies <- nodepie(data, cols = c("a", "b"))

# Should show a the tree with 5 pie charts, but only one chart is displayed. 
# Works as expected if layout_dendrogram() is removed
ggtree(tree) + layout_dendrogram() + geom_inset(pies)

Result: ggtree

Any advice on how to deal with this would be great!

gernat avatar Oct 16 '24 09:10 gernat