我正在尝试gridGraphics::grid.echo
根据此链接使用,因此我可以将Gviz
plotTracks
绘图与ggplot
using cowplot
's结合起来plot_grid
。
require(Gviz)
data(geneModels)
gtrack <- GenomeAxisTrack()
itrack <- IdeogramTrack(genome = "hg19", chromosome = as.character(geneModels$chromosome[1]))
grtrack <- GeneRegionTrack(geneModels, genome = "hg19",chromosome = as.character(geneModels$chromosome[1]), name = "Gene Model")
require(gridGraphics)
gwrap_plot <- function(x) {
tree <- grid::grid.grabExpr(gridGraphics::grid.echo(x))
u <- grid::unit(1, 'null')
gtable::gtable_col(NULL, list(tree), u, u)
}
graphics.off()
plotTracks(list(itrack, gtrack, grtrack))
track.plot <- recordPlot()
gwrap_plot(track.plot)
我得到这个错误:
Error in switch(x[[2]][[1]]$name, C_abline = C_abline(x[[2]]), C_plot_new = C_plot_new(x[[2]]), :
EXPR must be a length 1 vector
知道gridGraphics
's grid.echo
with Gviz
' 的plotTracks
情节有什么问题吗?