Learn R Programming

prada (version 1.48.0)

plotPlate: Plot a well statistic for microtiter plates.

Description

Plot a well statistic in false color representation or using a self-defined grid plotting function. The plot is supposed to resemble the physical geometry of a microtitre plate.

Usage

plotPlate(x,nrow = 8, ncol = 12, col=c("red", "blue"), ind = 1:(ncol*nrow), xrange=function(y) range(y, na.rm=TRUE), na.action = "zero", main, char, desc = character(2), add=FALSE, gridFun="default", funArgs=NULL,...)

Arguments

x
Numeric vector of length ncol*nrow or matrix with ncol*nrow rows (except if argument ind is specified). If of class matrix, the use of argument gridFun is expected.
nrow
Numeric of length 1. The number of rows of the plate.
ncol
Numeric of length 1. The number of columns of the plate.
col
Character vector. Usually the names of two or three colors between which the color map is interpolated, using the function colorRampPalette.
ind
Optional integer vector of equal length as x. It indicates the position of the respective value of x on the plate. Can be used to adress the problem of missing values. Each well that is not allocated a value of x by ind will not be plotted.
xrange
Numeric vector of length two giving thwe range of x that is mapped into the color scale. Alternatively, this can be a function which takes the values of x as input and creates such a vector.
na.action
Character. One of "zero" "omit" or "xout". How should the wells for which x is NA be treated? For "zero", they are plotted as if the value were 0. For "omit", they are omitted. For "xout", they are crossed out. When x is a matrix, na.action is only applied to rows containing nothing but NAs. Further special treatment of NA values in matrices need to be implemented in gridFun.
main
Character of length 1. Plot title.
char
An optional character vector of equal length as x (except if argument ind is specified) to be used for well annotation. Each element of the vector may contain a string to be superimposed on the respective well or NA for no plotting.
desc
Character of length 2. Legend for the two extremes of the colorbar, e.g. 'act' and 'inh'.
add
Logical. If TRUE add plate plot to current plot. May be used when plotting in grid layout panels.
gridFun
Character. The name of the plotting function to create individual graphs for each well. See functions .drawCircle and .drawPie
funArgs
Dataframe with argument values to be passed to gridCall. For each argument specified in gridCall there must be one column with the argument name as colname and the argument values for every well.
...
Further graphical parameters that can be used to control the output of plotPlate.
cex.main:
expansion factor for title.

cex.lab:
expansion factor for label.

cex.char:
expansion factor for well annotation.

cex.legend:
expansion factor for well legend labels.

cex.desc:
expansion factor for well legend description.

Value

It returns a list withfour elements. The element which is a vector with the indices of those elements in x that were plotted (see argument na.action). The element coord is a length(which) by 4 matrix in which each row specifies the corners of a rectangle that contains a well. It is intended to be used as an argument to a subsequent call to imageMap. Elements width and height may be used to open a graphic devices that can hold the plate plot with the correct aspect ratio.

Details

You may use this function either to create plots showing a single-value per well statistic for microtiter plates, or you can use a self-made plotting function using a combination of any valid grid commands to produce arbitrary plots in a plate array format. These plots may also show multifactorial data. Self-defined plotting functions need to have data as first argument. plotPlate passes all data values for the respective well to the plotting function. Any further arguments may be passed on using argument funArgs. See .drawCircle and .drawPie for examples of valid plotting functions and the vignette for detailed information. Note that using funCall overrides some of the default functionalities, e.g. plotting of legends and alters the treatment of NA values.

Argument ind allows the user to indicate the position (well number) for each element of vector x on the plate. This can be used either to change the order in which elements of x are to be plotted or to deal with the problem of missing data for some of the wells on a plate.

To further increase the amount of information of the platePlot one may decorate wells with short annotations using argument char. Each element of char != NA will be superimposed on the respective well (see examples).

See Also

imageMap

Examples

Run this code
plotPlate(runif(96), main="example 1", col=c("#0000e0", "#e00000"), desc=c("act", "inh"))
plotPlate(runif(384), nrow=16, ncol=24, main="example 2", col=c("#0000e0", "white", "#e00000"))
plotPlate(runif(48), main="example 3", col=c("#0000e0", "#e00000"), ind=c(1:24, 73:96))
x <- runif(96)
x[sample(96, 10)] <- NA
plotPlate(x, main="example 4", col=c("#0000e0", "#e00000"),
char=c(rep(NA, 72), LETTERS[1:24]), na.action="xout")
plotPlate(runif(96, min=0.1, max=0.5), gridFun=".drawCircle")
plotPlate(matrix(runif(288), ncol=3), gridFun=".drawPie",
funArgs=as.data.frame(matrix(2:4, ncol=3, nrow=96, byrow=TRUE)))
 

Run the code above in your browser using DataLab