imageW {wrGraph} | R Documentation |
Display numeric content of matrix as image
Description
To get a quick overview of the spatial distribution of smaller data-sets it may be useful to display numeric values as colored boxes.
Such an output may also be referred to as heatmap (note that the term 'heatmap' is frequently associated with graphical display of hierarchcal clustering results).
The function image
provides the basic support to do so (ie heatmap without rearranging rows and columns by clustering).
To do this more conveniently, the function imageW
offers additional options for displaying row- and column-names or displaying NA-values as custom-color.
Usage
imageW(
data,
latticeVersion = FALSE,
transp = TRUE,
NAcol = "grey95",
tit = NULL,
rowNa = NULL,
colNa = NULL,
xLab = NULL,
yLab = NULL,
las = 2,
col = NULL,
nColor = 9,
balanceCol = TRUE,
gridCol = "grey75",
gridLty = 1,
centColShift = 0,
cexDispl = NULL,
panel.background.col = "white",
supLat = list(),
rotXlab = 0,
rotYlab = 0,
cexXlab = 0.7,
cexAxs = NULL,
cexYlab = 0.9,
Xtck = 0,
Ytck = 0,
cexTit = 1.6,
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
Arguments
data |
(matrix or data.frame) main input |
latticeVersion |
(logical) use lattice for plotting (this will include a color-legend) |
transp |
(logical) decide if data should get transposed (if |
NAcol |
(character or integer) custom color for NA-values, default is light grey |
tit |
(character) custom figure title |
rowNa |
(character) optional custom rownames |
colNa |
(character) optional custom colnames |
xLab |
(character) optional custom text for x-axis 'values' |
yLab |
(character) optional custom text for y-axis 'values' |
las |
(numeric) style of axis labels (see also |
col |
(character or integer) colors; in lattice version 2 or 3 color-names to define central- and end-points of gradient (starting with color for lowest values, optional central color and color for highest values), default is 60 shades 'RdYlBu' RColorBrewer, if 'heat.colors' use heat.colors in min 15 shades |
nColor |
(integer, only used in lattice version) number of color-blocks in color gradient (made based on central- and end-points from |
balanceCol |
(logical, only used in lattice version) if |
gridCol |
(character, only used in lattice version) define color of grid |
gridLty |
(integer, only used in lattice version) define line-type of grid (see also lty |
centColShift |
(integer, only used in lattice version) shift central (default grey) color element for negative scale up or down (ie increase or reduce number of color-blocks for negatve values), used for correcting automatic scaling rounding issues to ensure the central elements captures 0 |
cexDispl |
(numeric, length=1, only used in lattice version) define cex size for displaying (rounded) values in plot, set to |
panel.background.col |
(character, only used in lattice version) |
supLat |
(list, only used in lattice version) additional arguments/parameters passed to |
rotXlab |
(numeric, 0 - 360, lattice version only) control rotation of x-axis labels |
rotYlab |
(numeric, 0 - 360, lattice version only) control rotation of y-axis labels |
cexXlab |
(numeric) cex-like expansion factor for x-axis labels (see also |
cexAxs |
(numeric) cex-like expansion factor for x- and y-axis text/labels (see also |
cexYlab |
(numeric) cex-like expansion factor for y-axis labels (see also |
Xtck |
(numeric or logical) expansion factor for length of tick-marks on x-axis (default=0 for no tick-marks) |
Ytck |
(numeric or logical) expansion factor for length of tick-marks on y-axis |
cexTit |
(numeric) cex-like expansion factor for title (see also |
silent |
(logical) suppress messages |
debug |
(logical) additional messages for debugging |
callFrom |
(character) allow easier tracking of messages produced |
Details
This function allows two modes of operation : 1) plotting using standard R -graphics or 2) using the framework of grid- and lattice-graphics (since version 1.2.6).
The latter version allows integrating a legend for the color-scale and adding grid-lines, rotation of axis-labels or removing tick-marks.
Please note that sometimes the center-color segment may not end up directly with the center-color, in this case you may adjust using the argument centColShift=-1
Value
This function plots in image (to the current graphical device) as image
does
See Also
image
, for the lattice version levelplot
, heatmaps including hierarchical clustering heatmap
or heatmap.2
from package gplots
Examples
imageW(as.matrix(iris[1:40,1:4]), transp=FALSE, tit="Iris (head)")
imageW(as.matrix(iris[1:20,1:4]), latticeVersion=TRUE, col=c("blue","red"),
rotXlab=45, yLab="Observation no", tit="Iris (head)")