[R] Navigating a grid.

Michael Muratet
Sun, 21 Oct 2012 17:08:55 -0000

Greetings

I am trying to make a multiple panel plot from a tool (genoPlotR) that
is layered on grid. My code and session info are below. When I execute
the code, I get a single plot in the center of the graphics page. I
have tried various pop/push/down/seekViewport commands at the end of
the plotpush method. There must be something I'm missing in the
documentation, I believe what I have should work. I haven't been able
to find a similar scenario in the help archives.

Could I get someone to critique my code and help me figure out how to
make multiple plots in columns and rows?

Thanks

Mike

plotpush <- function(x,n,letter,row,column) {

pushViewport
(viewport
(layout.pos.row=row,layout.pos.col=column,name=as.character(n)))


plot_gene_map
(dna_segs=list(x[["seg"]]),annotations=x[["annot"]],dna_seg_scale=T,

scale_cex
=
1.4
,dna_seg_line
=F,plot_new=FALSE,scale=F,arrow_head_length=1,annotation_cex=1.4,
                   main=toupper(letters[n]),main_pos="left"
     )
     popViewport(0)
}

pushViewport(viewport(layout = grid.layout(nrow=26,ncol=2)))

sapply(repeats,plotpush,n=1:26,letter=1:26,row=1:26,col=1)
sapply(repeats,plotpush,n=27:52,letter=1:26,row=1:26,col=2)

 > sessionInfo()
R version 2.15.0 (2012-03-30)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets
methods   base

other attached packages:
[1] GenomicFeatures_1.9.41 AnnotationDbi_1.19.38
Biobase_2.17.8         GenomicRanges_1.9.65   IRanges_1.15.44
BiocGenerics_0.3.2
[7] genoPlotR_0.8          ade4_1.4-17

loaded via a namespace (and not attached):
  [1] biomaRt_2.13.2      Biostrings_2.25.12  bitops_1.0-4.1
BSgenome_1.25.8     DBI_0.2-5           RCurl_1.91-1
  [7] Rsamtools_1.9.30    RSQLite_0.11.2      rtracklayer_1.17.19
stats4_2.15.0       tools_2.15.0        XML_3.9-4
[13] zlibbioc_1.3.0
 >