plotHeatmap {scater} | R Documentation

## Plot heatmap of gene expression values

### Description

Create a heatmap of expression values for each cell and specified features in a SingleCellExperiment object.

### Usage

    plotHeatmap(object, features, columns = NULL, exprs_values = "logcounts",
      center = FALSE, zlim = NULL, symmetric = FALSE, color = NULL,
      colour_columns_by = NULL, by_exprs_values = exprs_values,
      by_show_single = FALSE, ...)

### Arguments

`object` | A SingleCellExperiment object.
`features` | A character vector of row names, a logical vector of integer vector of indices specifying rows of `object` to show in the heatmap.
`columns` | A vector specifying the subset of columns in `object` to show as columns in the heatmp. By default, all columns are used in their original order.
`exprs_values` | A string or integer scalar indicating which assay of `object` should be used as expression values for colouring in the heatmap.
`center` | A logical scalar indicating whether each row should have its mean expression centered at zero prior to plotting.
`zlim` | A numeric vector of length 2, specifying the upper and lower bounds for the expression values. This winsorizes the expression matrix prior to plotting (but after centering, if `center=TRUE`). If `NULL`, it defaults to the range of the expression matrix.
`symmetric` | A logical scalar specifying whether the default `zlim` should be symmetric around zero. If `TRUE`, the maximum absolute value of `zlim` will be computed and multiplied by `c(-1, 1)` to redefine `zlim`.
`color` | A vector of colours specifying the palette to use for mapping expression values to colours. This defaults to the default setting in `pheatmap`.
`colour_columns_by` | A list of values specifying how the columns should be annotated with colours. Each entry of the list can be of the form described by `?"scater-vis-var"`. A character vector can also be supplied and will be treated as a list of strings.
`by_exprs_values` | A string or integer scalar specifying which assay to obtain expression values from, for colouring of column-level data - see `?"scater-vis-var"` for details.
`by_show_single` | Logical scalar specifying whether single-level factors should be used for column-level colouring, see `?"scater-vis-var"` for details.
`...` | Additional arguments to pass to `pheatmap`.

### Details

Setting `center=TRUE` is useful for examining log-fold changes of each cell's expression profile from the average across all cells. This avoids issues with the entire row appearing a certain colour because the gene is highly/lowly expressed across all cells.

Setting `zlim` preserves the dynamic range of colours in the presence of outliers. Otherwise, the plot may be dominated by a few genes, which will “flatten” the observed colours for the rest of the heatmap.

### Value

A heatmap is produced on the current graphics device. The output of `pheatmap` is invisibly returned.

### Author(s)

Aaron Lun

### See Also

`pheatmap`

### Examples

    example(normalizeSCE) # borrowing the example objects in here.
    plotHeatmap(example_sce, features=rownames(example_sce)[1:10])
    plotHeatmap(example_sce, features=rownames(example_sce)[1:10],
        center=TRUE, symmetric=TRUE)

    plotHeatmap(example_sce, features=rownames(example_sce)[1:10],
        colour_columns_by=c("Mutation_Status", "Cell_Cycle"))

[Package scater version 1.8.4 Index]