ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

How to move x axis in heatmap by geom_fruit to top?

Open SilentGene opened this issue 5 months ago • 0 comments

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

  • [ ] Make a reproducible example (e.g. 1)
  • [ ] 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)
  • [ ] for questions, please post to google group

Hi Prof. Guangchuang Yu,

Thanks for the amazing tool! I was just wondering when I create a heatmap by geom_fruit, how can I move the x axis to the top instead of at the bottom?

Here is my pseudocode and outcome:

# my tree
x <- rtree(10)
p<-ggtree(x) + geom_tiplab()

# my metadata
metadata <- data.frame(Node = sample(x$tip.label, 10), 
                       Function = sample(c("A", "B", "C"), 10, replace = TRUE), 
                       Value = runif(10))
# visulize
p.test + new_scale_fill() +
  geom_fruit(data = metadata, geom=geom_tile,
             mapping = aes(y=Node, x=Function, fill = Value), 
             offset=0.1, pwidth=0.5,
             axis.params=list(axis="x", text.size=3,hjust=1, text.angle=45, vjust=1)
             )

Now, I get: image

So my question was how to move the x axis "A, B, C" to the top of the heatmap?

Best Regards, Heyu

SilentGene avatar Sep 13 '24 08:09 SilentGene