How to arrange multiple Gviz plots into a multipanelfigure?
1
0
Entering edit mode
Aditya ▴ 160
@aditya-7667
Last seen 2.5 years ago
Germany

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 • 2.6k views
ADD COMMENT
3
Entering edit mode
Robert Ivanek ▴ 750
@robert-ivanek-5892
Last seen 12 months ago
Switzerland

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 COMMENT
0
Entering edit mode

Great! Thank you :-)

ADD REPLY

Login before adding your answer.

Traffic: 532 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