YuLab-SMU / ggtree

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

Aligning tree with other ggplot2 #29

Closed stiatragul closed 8 years ago

stiatragul commented 8 years ago

Hi Guangchuang Yu,

First of all thank you for your ggtree package, it is truly versatile and really takes advantage of the good stuff from ggplot2!

I am currently preparing a figure for publication about trait variation and evolution across fiddler crab species. My goal is to have a figure that looks like this: http://ape-package.ird.fr/image/Figure2_TEJEDO.png (Richter-Boix A., Tejedo M. & Rezende E. L. 2011).

Attempt: (attached) I created a dendogram using ggtree and a ggplot of trait (size) vs species (order). The species name is at the tip of the dendogram. I used ggExtra to arrange them in such a way. While it looks ok, the alignment is not proper.

Request: Is there a way to align a ggplot like this one with each taxa from ggtree? This will be similar to what has been done with the gheatmap, if we can somehow make the dendogram the x-axis of the ggplot, that would be awesome!

Thank you so much in advance! Putter

Picture: gridetraarrange

GuangchuangYu commented 8 years ago

same issue as in issue 3, gridExtra can not arrange them properly. This is the reason why I need to develop gheatmap function.

stiatragul commented 8 years ago

The gheatmap function is great for aligning a 'data' with the tree. However, my graph is a ggplot so the gheatmap function does not recognize it. In issue 3, the problem seemed to be aligning a "heatmap."

I hope this helps and that this is not just me being incapable of writing the code correctly. I looked at the vignette many times but could not figure it out. Please advise how I could use the gheatmap function to align my ggplot with my tree.

Thank you for your patience! I appreciate your time in helping me out!

GuangchuangYu commented 8 years ago

In issue 3, the issue is using grid.arrange can't align a ggplot object (heatmap) with a tree.

AND gheatmap is designed to align heatmap with a tree. It can't work with a ggplot object.

stiatragul commented 8 years ago

I see, thank you very much again for your response. I saw a request for ggplot2 two to develop a function that will do just that. I hope this development will happen in the near future.

GuangchuangYu commented 8 years ago

I think gtable can help. I will look into it when I have some free time.

It would be great if we can work out a way more general than gheatmap.

stiatragul commented 8 years ago

Thanks so much, I will look into using gtable but a lot of learning has to take place on my part first. I agree, it would be great to get a more general function because these sort of figure are helpful!

GuangchuangYu commented 8 years ago

one possible solution: http://guangchuangyu.github.io/ggtree/advanceTreeAnnotation.html#align-tree-with-other-plots-on-a-page