Closed acpguedes closed 4 years ago
gggenes and ggtree are not fully compatible. This is the reason why we provide geom_motif()
which is a wrapper for gggenes.
If you want to align them using cowplot or patchwork, you need to adjust the order yourself and make sure that they are properly align, see also https://github.com/YuLab-SMU/ggtree/issues/313.
I found a way which might be useful even if it is not the best one.
Fist extract an ordered list of the leaves:
leaf_order <- tre_plot$data %>%
filter(isTip) %>%
arrange(y) %>%
pull(block_id)
And, on the plot, adjust the y
axis scale:
nbh_plot +
scale_y_discrete(limits=leaf_order)
Remember convert numeric type in factor.
Finally combine them::
tree_plo + nbh_plot
there is a function get_taxa_name
in ggtree
that can extract taxa order displayed on the ggtree() plot.
If you want to do it in this way, I recommend you using aplot
package (examples can be found https://yulab-smu.top/treedata-book/chapter7.html#composite_plot).
Hi. Sorry if here Isn't the right place to post this question. I thought the group in Gmail might be too flooded because of the whole code.
I'm trying to do something like the example 13.4 Phylogenetic trees with genome locus structure but it is not working.
I tried something like:
This works but does not align them.
I also tried another method which lacks the sub-motifs (domains) showed in
nbh_plot
Another variation with geom_facet which also lacks the domains and the figure not shows the alignment