I am curious how people make genome track plots such as what can be done with the Bioconductor package ggbio
.
For example this plot was made w/ ggbio:
I think ggbio is great for making fast plots, but it is kind of a pain to make publication quality figures because it is hard to manipulate the plots after they are constructed. I have noticed that ggbio constructed plots do not return a ggplot or gtable object. I can access the grobs from a ggbio tracks object, but they won't be aligned as they would be in the final plot. I like to make shared legends and include them in the plot, and without having a gtable or ggplot object it is hard to add the shared legends in, and I end up having to save them as a separate file which is tedious. FYI I mainly use ggbio for gene tracks + x-axis alignment.
Normally I would use ggplot2 to customize the plot extensively, but it doesn't work very well after plotting with ggbio.
How can I use ggbio for these types of plots? Is there a better tool instead?
EDIT: I would get the legends for each individual plot and combine them before adding back to the main plot using something like this:
leg1.grob = cowplot::get_legend(plot1)
leg2.grob = cowplot::get_legend(plot2)
sharedleg.grob = gridExtra::gtable_rbind(leg1,leg2)
mainplot.grob = ggplotGrob(main_plot)
mainplot.grob = gtable_add_cols(mainplot.grob,
widths = sum(sharedleg.grob$widths))
mainplot.grob = gtable_add_grobs(mainplot.grob,
grobs = sharedleg.grob,
t=t,b=b,l=l,r=r)
cowplot::ggdraw(mainplot.grob)
I've used gviz before, but long ago. Do you know if you can extract the grid plot grobs of the gene track plots with Gviz?