heat_map {opm}R Documentation

Heat map

Description

A wrapper for heatmap from the stats package and heatmap.2 from the gplots package with some adaptations likely to be useful for OmniLog(R) data. The data-frame and OPMS methods extract a numeric matrix from a given data frame or OPMS object and pass the result to the matrix method.

Usage

  ## S4 method for signature 'MOPMX'
heat_map(object, as.labels,
    subset = opm_opt("curve.param"), as.groups = NULL, sep = " ",
    extract.args = list(), ...) 
  ## S4 method for signature 'OPMS'
heat_map(object, as.labels,
    subset = opm_opt("curve.param"), as.groups = NULL, sep = " ",
    extract.args = list(), ...) 
  ## S4 method for signature 'data.frame'
heat_map(object, as.labels, as.groups = NULL, sep = " ", ...)
  ## S4 method for signature 'matrix'
heat_map(object,
    hclustfun = "ward.D2", distfun = "euclidean", scale = "none",
    r.groups = "row.groups", r.col = opm_opt("colors"),
    c.groups = "col.groups", c.col = opm_opt("colors"),
    magnif = 4, cexRow = magnif[1L] / sqrt(nrow(object)),
    cexCol = magnif[length(magnif)] / sqrt(ncol(object)),
    borders = c(0.55, 0.75),
    margins = if (use.fun[1L] == "gplots")
      c(borders[1L] * cexCol * max(nchar(colnames(object))),
      borders[length(borders)] * cexRow * max(nchar(rownames(object))))
    else
      c(5, 5),
    col = opm_opt("heatmap.colors"), asqr = FALSE, log1 = FALSE, lmap = 1L:3L,
    abbrev = c("none", "row", "column", "both"), plot.na = "plot.NA",
    reorderfun = function(d, w) reorder(d, w, mean), ...,
    use.fun = c("gplots", "stats")) 

Arguments

object

Matrix, data frame or OPMS or MOPMX object. The matrix method is mainly designed for curve-parameter matrices as created by extract but can be used with any numeric matrix. If a data frame, it must contain at least one column with numeric data. Not all MOPMX objects are suitable for this function; see the remarks under extract.

as.labels

Character, numeric or logical vector indicating the positions of the columns to be joined and used as row labels. If NULL or empty, the row names of object are used. See extract for details.

as.groups

Character, numeric or logical vector indicating the positions of the columns to be joined and used as group indicators. If NULL or empty, groups are ignored.

sep

Character scalar determining how to join row and group names. See extract for details.

subset

Character scalar passed to the OPMS method of extract.

extract.args

Optional list of arguments passed to that method.

hclustfun

Determines the clustering method used. If a function, used directly. If a character scalar, used as the ‘method’ argument of hclust. If a list, passed as argument list to hclust.

distfun

Determines the distance method used. If a function, used directly. If a character scalar, used as the ‘method’ argument of dist. If a list, passed as argument list to dist.

scale

Character scalar. See heatmap for details. The default was changed to no rescaling because the curve parameters estimated from OmniLog(R) data have the same scale. If the relative changes per substrate are of interest, ‘column’ should be used.

r.groups

Determines the plotting of a colour bar indicating row groups.

If NULL, ignored. If a function, applied to the row names of object; should then yield one group name for each row name. If a character scalar, the name of an attribute of object that contains the row group affiliations (ignored if this is not found). Otherwise, coerced to ‘character’ mode.

Finally the groups are converted to a factor and used for selecting from r.col.

r.col

Character vector of colour names used by r.groups. Ignored if that is NULL.

c.groups

Determines the plotting of a colour bar indicating column groups.

If NULL, ignored. If a function, applied to the column names of object; should then yield one group name for each column name. If a character scalar, the name of an attribute of object that contains the column group affiliations (ignored if this is not found). Otherwise, coerced to ‘character’ mode.

Finally the groups are converted to a factor and used for selecting from c.col.

c.col

Character vector of colour names used by c.groups. Ignored if that is NULL.

magnif

Numeric vector. Factor(s) used per default by cexRow and cexCol.

cexRow

Magnification of the row labels.

cexCol

Magnification of the column labels.

borders

Numeric vector. Factor(s) used per default by margin and cexCol.

margins

Two-element numeric vector determining the relative size of the margin (i) at the bottom and (ii) at the left.

col

Character vector containing the proper heat map colours.

asqr

Logical scalar indicating whether the data should be treated with the arcsine-square root transformation. This usually only makes sense for proportion data and cannot be used in conjunction with the log1 argument set to TRUE. If NA, percentages are assumed.

log1

Logical scalar indicating whether log1p should be used for transforming the data prior to plotting.

lmap

Numeric scalar with at least three elements, or empty. If empty, ignored. Otherwise used for mapping logical values to numeric values. See map_values for details. Ignored if the data are not logical.

abbrev

Character scalar indicating whether row or column shall be abbreviated before plotting. Note that abbreviation is done by shortening words and ending them with a dot, so there is no guarantee that a certain maximum length will be obtained.

plot.na

Character scalar with the name of an optional attribute that contains replacement values for NA that are inserted prior to plotting.

reorderfun

Function passed to heatmap or heatmap.2. The modification from their defaults is intended to yield an ordering that more strongly reflects row and column sums (instead of also taking cluster size into consideration).

...

Optional arguments passed to heatmap or heatmap.2. Note that some defaults of heatmap.2 are overwritten even though this is not transparent from the argument list of heat_map. If set explicitly, the default heatmap.2 behaviour is restored. ... also represents all arguments passed from the OPMS or data-frame methods to the matrix method.

use.fun

Character scalar. If gplots, it is attempted to load the gplots package and use its heatmap.2 function (the default). If this fails, a warning is issued, and heatmap from the stats package (the default) is called instead.

Value

A list as output by heatmap or heatmap.2 with the additional entries rowColMap or colColMap giving the mapping(s) of group names to colours as named character vector(s), if this feature was used.

See Also

stats::heatmap gplots::heatmap.2

Other plotting-functions: ci_plot, level_plot, parallel_plot, parallelplot, radial_plot, summary, xy_plot

Examples

# temporarily disabled until an error specific for Windows on
# R-Forge is fixed; needs not affect user code, Windows users
# can well try heat_map()
if (!grepl("windows", Sys.info()[["sysname"]], TRUE, TRUE)) {

# Matrix method (usually unnecessary, see below)
x <- extract(vaas_4, as.labels = list("Strain"),
  as.groups = list("Species"))
hm <- heat_map(x)
stopifnot(identical(metadata(vaas_4, "Species"), names(hm$rowColMap)))

# 'OPMS' method (more convenient)
hm.2 <- heat_map(vaas_4, as.labels = "Strain", as.groups = "Species")
stopifnot(identical(hm[-3], hm.2[-3]))

# Data-frame method
x <- extract(vaas_4, as.labels = list("Species", "Strain"), dataframe = TRUE)
hm <- heat_map(x, as.labels = "Strain", as.groups = "Species")
stopifnot(identical(metadata(vaas_4, "Species"), names(hm$rowColMap)))

}

plot of chunk unnamed-chunk-1 plot of chunk unnamed-chunk-1


[Package opm version 1.3.63 Index]