How to save genoPlotR output as a grob
1
1
Entering edit mode
3.8 years ago
YiweiZhu ▴ 30

genoPlotR is among few R packages to draw genome alignment plot. I plan to arrange a genome alignment plot with other plots by packages like cowplot. But it seems that the output of plot_gene_map() function can only be exported into a image file. How could I save the output of plot_gene_map() function as a grob?

I have tried code like p1 <- plot_gene_map(...). However, the class of p1 is vpPath. Is it possible to convert a vpPath class to a grob?

genoPlotR grob grid • 1.1k views
ADD COMMENT
2
Entering edit mode
3.8 years ago
guy.lionel ▴ 20

Yiwei,

There is no such built-in option, since plot_gene_map produces more complex structures (viewports). But it is definitely possible to arrange gene maps with other plots using plot_gene_map(..., plot_new = FALSE).

There are some examples here: http://genoplotr.r-forge.r-project.org/

But for a quick example:

library(genoPlotR) 
data("three_genes")
gm <- plot_gene_map(dna_segs=dna_segs, comparisons=comparisons, plot_new = FALSE)`
grid_list <- grid.ls(grob=TRUE, viewports=TRUE, print=FALSE) 
grid_list
current.vpTree()

Hope that helps.

Lionel (genoPlotR's maintainer)

ADD COMMENT
0
Entering edit mode

Thanks for your quick reply, Prof. Guy!

I just find the grid.grab() function in grid package. I think it is what I am looking for.

library(genoPlotR) 
data("three_genes")
plot_gene_map(dna_segs=dna_segs, comparisons=comparisons)
gb <- grid.grab()
class(gb)
[1] "gTree" "grob"  "gDesc"

Cheers!

ADD REPLY

Login before adding your answer.

Traffic: 3193 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6