Question: How to arrange multiple Gviz plots into a multipanelfigure?
0
gravatar for Aditya
6 weeks ago by
Aditya120
Germany
Aditya120 wrote:

The Gviz package is great - thank you Florian and Robert :-)

    seqinfo <- GenomeInfoDb::seqinfo(BSgenome.Mmusculus.UCSC.mm10::Mmusculus)
    grA <- GenomicRanges::GRanges(
               'chr1', c('4712628-4712643', '4712428-4712627'), '+', seqinfo = seqinfo)
    grB <- GenomicRanges::GRanges(
               'chr1', c('5250212-5250227', '5250012-5250211'), '-', seqinfo = seqinfo)

    ideogram   <- Gviz::IdeogramTrack(genome = 'mm10', chromosome = 'chr1')
    genomeaxis <- Gviz::GenomeAxisTrack()
    siteA     <- Gviz::AnnotationTrack(grA, name = 'siteA')
    siteB     <- Gviz::AnnotationTrack(grB, name = 'siteB')

    pA <- Gviz::plotTracks(list(ideogram, genomeaxis, siteA))  # Works great
    pB <- Gviz::plotTracks(list(ideogram, genomeaxis, siteB))  # Works great too

But how do I capture the generated plots, so that I can re-arrange them together into a multipanelfigure?

    gridExtra::grid.arrange(pA, pB)
    Error in gList(list(chr1 = new("IdeogramTrack", bandTable = list(chrom = c(1L,  : 
    only 'grobs' allowed in "gList"
gviz • 56 views
ADD COMMENTlink modified 6 weeks ago by Robert Ivanek640 • written 6 weeks ago by Aditya120
Answer: How to arrange multiple Gviz plots into a multipanelfigure?
2
gravatar for Robert Ivanek
6 weeks ago by
Robert Ivanek640
Switzerland
Robert Ivanek640 wrote:

Thanks. We are happy you like it.

What about this?

grid.newpage()
# 2x2 layout
pushViewport(viewport(layout=grid.layout(2, 2)))
# 1,1 first plot
pushViewport(viewport(layout.pos.col=1,layout.pos.row=1))
Gviz::plotTracks(list(ideogram, genomeaxis, siteA), add=TRUE)
popViewport()
# 2,2 second plot
pushViewport(viewport(layout.pos.col=2,layout.pos.row=2))
Gviz::plotTracks(list(ideogram, genomeaxis, siteB), add=TRUE)
popViewport()
popViewport()
ADD COMMENTlink written 6 weeks ago by Robert Ivanek640

Great! Thank you :-)

ADD REPLYlink written 6 weeks ago by Aditya120
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 193 users visited in the last hour