xplot: Repeat specified plot across multiple columns of a matrix

Description Usage Arguments Author(s) Examples

Description

This is designed to repeat a plot, usually an image plot, across multiple columns of a matrix of gene expression values. A boxplot that shows the distribution of values appears below each panel.

Usage

1
2
3
4
5
6
xplot(data = DAAGbio::coralRG$R, images = 1:6, layout = DAAGbio::coralRG$printer, mfrow =
c(3, 2),
FUN = imgplot, device = NULL, title = NULL, width = 7.5, height = 10,
paneltitles = c("1:R/G", "2:G/R", "3:R/G", "4:G/R", "5:R/G", "6:G/R"),
paneltitles.line = 0.5,
mar = c(3.6, 3.6, 1.6, 0.6), oma = c(0.6, 0.6, 1.6, 0.6), file = NULL)

Arguments

data

matrix of expression array values

images

columns of matrix for which plots are required

layout

layout of spots, in the order (rows of grids, columns of grids, rows of spots in a grid, columns in a grid)

mfrow

row by column layout of plots on a page

FUN

imgplot, or imageplot from limma

device

If NULL, plot appears on the monitor. Other possibilities include pdf, postscript, png, jpeg and bitmap

title

A title for the page of graphs

width

width of plot (in)

height

height of plot (in)

paneltitles

character vector of titles for individual panels

paneltitles.line

height (lines) at which panel title are to appear above the upper margin of each panel

mar

Setting for par$mar

oma

Setting for par$mar

file

Optional file name, if output is to a file

Author(s)

J. H. Maindonald

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## Not run: 
xplot(data=coralRG$R, layout=coralRG$printer, FUN=imgplot)

## End(Not run)

## The function is currently defined as
function(data = DAAGbio::coralRG$R, images=1:6, layout = DAAGbio::coralRG$printer, mfrow=c(3,2),
           FUN = imgplot, device=NULL, title=NULL, width=7.5, height=10,
           paneltitles=c("1:R/G","2:G/R", "3:R/G","4:G/R", "5:R/G","6:G/R"),
           paneltitles.line=0.5,
           mar=c(3.6,3.6,1.6,0.6), oma=c(0.6,0.6,1.6,0.6), file=NULL){
    if(is.null(title)){title <- as.character(substitute(data))
    title <- paste(title[2], title[3], sep=":")
                    }
    if(is.null(file))file <- title
    nch <- nchar(title)
    if(!is.null(device)){devnam <- deparse(substitute(device))
    ext <- switch(devnam, ps="ps", pdf="pdf", png="png",
                  jpeg="jpg", bitmap="bmp")
      file <- paste(title,".", ext, sep="")
      print(file)
      device(file=file, width=width, height=height)
    }
    oldpar <- par(mfrow=mfrow, mgp=c(1,0.25,0), oma=oma, mar=mar)
    on.exit(par(oldpar))
    for(i in images){
      FUN(data[,i], layout=layout)
      mtext(side=3,line=paneltitles.line,paneltitles[i],adj=0)
    }
    mtext(side=3, line=0.25, title, outer=TRUE)
    if(!is.null(device))dev.off()
  }

Example output

Loading required package: limma
function (data = DAAGbio::coralRG$R, images = 1:6, layout = DAAGbio::coralRG$printer, 
    mfrow = c(3, 2), FUN = imgplot, device = NULL, title = NULL, 
    width = 7.5, height = 10, paneltitles = c("1:R/G", "2:G/R", 
        "3:R/G", "4:G/R", "5:R/G", "6:G/R"), paneltitles.line = 0.5, 
    mar = c(3.6, 3.6, 1.6, 0.6), oma = c(0.6, 0.6, 1.6, 0.6), 
    file = NULL) 
{
    if (is.null(title)) {
        title <- as.character(substitute(data))
        title <- paste(title[2], title[3], sep = ":")
    }
    if (is.null(file)) 
        file <- title
    nch <- nchar(title)
    if (!is.null(device)) {
        devnam <- deparse(substitute(device))
        ext <- switch(devnam, ps = "ps", pdf = "pdf", png = "png", 
            jpeg = "jpg", bitmap = "bmp")
        file <- paste(title, ".", ext, sep = "")
        print(file)
        device(file = file, width = width, height = height)
    }
    oldpar <- par(mfrow = mfrow, mgp = c(1, 0.25, 0), oma = oma, 
        mar = mar)
    on.exit(par(oldpar))
    for (i in images) {
        FUN(data[, i], layout = layout)
        mtext(side = 3, line = paneltitles.line, paneltitles[i], 
            adj = 0)
    }
    mtext(side = 3, line = 0.25, title, outer = TRUE)
    if (!is.null(device)) 
        dev.off()
}

DAAGbio documentation built on May 1, 2019, 7:30 p.m.