moduleHeatmap {celda} | R Documentation

## Heatmap for featureModules

### Description

Renders a heatmap for selected `featureModule`. Cells are ordered from those with the lowest probability of the module on the left to the highest probability on the right. Features are ordered from those with the highest probability in the module on the top to the lowest probability on the bottom. Use of save_multi_panel_figure is recommended for outputting figures in various formats.

### Usage

    moduleHeatmap(
      x,
      useAssay = "counts",
      altExpName = "featureSubset",
      featureModule = NULL,
      col = circlize::colorRamp2(c(-2, 0, 2), c("#1E90FF", "#FFFFFF", "#CD2626")),
      topCells = 100,
      topFeatures = NULL,
      normalizedCounts = NA,
      normalize = "proportion",
      transformationFun = sqrt,
      scaleRow = scale,
      showFeatureNames = TRUE,
      displayName = NULL,
      trim = c(-2, 2),
      rowFontSize = NULL,
      showHeatmapLegend = FALSE,
      showTopAnnotationLegend = FALSE,
      showTopAnnotationName = FALSE,
      topAnnotationHeight = 5,
      showModuleLabel = TRUE,
      moduleLabel = "auto",
      moduleLabelSize = NULL,
      width = "auto",
      height = "auto",
      unit = "mm",
      ncol = NULL,
      useRaster = TRUE,
      ...
    )

    ## S4 method for signature 'SingleCellExperiment'
    moduleHeatmap(
      x,
      useAssay = "counts",
      altExpName = "featureSubset",
      featureModule = NULL,
      col = circlize::colorRamp2(c(-2, 0, 2), c("#1E90FF", "#FFFFFF", "#CD2626")),
      topCells = 100,
      topFeatures = NULL,
      normalizedCounts = NA,
      normalize = "proportion",
      transformationFun = sqrt,
      scaleRow = scale,
      showFeatureNames = TRUE,
      displayName = NULL,
      trim = c(-2, 2),
      rowFontSize = NULL,
      showHeatmapLegend = FALSE,
      showTopAnnotationLegend = FALSE,
      showTopAnnotationName = FALSE,
      topAnnotationHeight = 5,
      showModuleLabel = TRUE,
      moduleLabel = "auto",
      moduleLabelSize = NULL,
      width = "auto",
      height = "auto",
      unit = "mm",
      ncol = NULL,
      useRaster = TRUE,
      ...
    )

### Arguments

`x` | A numeric matrix of counts or a SingleCellExperiment with the matrix located in the assay slot under `useAssay`. Rows represent features and columns represent cells. Celda results must be present under `metadata(altExp(x, altExpName))`.
`useAssay` | A string specifying which assay slot to use if `x` is a SingleCellExperiment object. Default "counts".
`altExpName` | The name for the altExp slot to use. Default "featureSubset".
`featureModule` | Integer Vector. The featureModule(s) to display. Multiple modules can be included in a vector. Default `NULL` which plots all module heatmaps.
`col` | Passed to Heatmap. Set color boundaries and colors.
`topCells` | Integer. Number of cells with the highest and lowest probabilities for each module to include in the heatmap. For example, if `topCells = 50`, the 50 cells with the lowest probabilities and the 50 cells with the highest probabilities for each featureModule will be included. If NULL, all cells will be plotted. Default 100.
`topFeatures` | Integer. Plot 'topFeatures' features with the highest probabilities in the module heatmap for each featureModule. If `NULL`, plot all features in the module. Default `NULL`.
`normalizedCounts` | Integer matrix. Rows represent features and columns represent cells. If you have a normalized matrix result from normalizeCounts, you can pass through the result here to skip the normalization step in this function. Make sure the colnames and rownames match the object in x. This matrix should correspond to one generated from this count matrix `assay(altExp(x, altExpName), i = useAssay)`. If `NA`, normalization will be carried out in the following form `normalizeCounts(assay(altExp(x, altExpName), i = useAssay), normalize = "proportion", transformationFun = sqrt)`. Use of this parameter is particularly useful for plotting many module heatmaps, where normalizing the counts matrix repeatedly would be too time consuming. Default NA.
`normalize` | Character. Passed to normalizeCounts if `normalizedCounts` is `NA`. Divides counts by the library sizes for each cell. One of 'proportion', 'cpm', 'median', or 'mean'. 'proportion' uses the total counts for each cell as the library size. 'cpm' divides the library size of each cell by one million to produce counts per million. 'median' divides the library size of each cell by the median library size across all cells. 'mean' divides the library size of each cell by the mean library size across all cells. Default "proportion".
`transformationFun` | Function. Passed to normalizeCounts if `normalizedCounts` is `NA`. Applies a transformation such as sqrt, log, log2, log10, or log1p. If `NULL`, no transformation will be applied. Occurs after normalization. Default sqrt.
`scaleRow` | Function. Which function to use to scale each individual row. Set to NULL to disable. Occurs after normalization and log transformation. For example, scale will Z-score transform each row. Default scale.
`showFeatureNames` | Logical. Whether feature names should be displayed. Default TRUE.
`displayName` | Character. The column name of `rowData(altExp(x, altExpName))` that specifies the display names for the features. Default `NULL`, which displays the row names. Only works if `showFeaturenames` is `TRUE` and `x` is a SingleCellExperiment object.
`trim` | Numeric vector. Vector of length two that specifies the lower and upper bounds for plotting the data. This threshold is applied after row scaling. Set to NULL to disable. Default `c(-2,2)`.
`rowFontSize` | Numeric. Font size for feature names. If `NULL`, then the size will automatically be determined. Default `NULL`.
`showHeatmapLegend` | Passed to Heatmap. Show legend for expression levels.
`showTopAnnotationLegend` | Passed to HeatmapAnnotation. Show legend for cell annotation.
`showTopAnnotationName` | Passed to HeatmapAnnotation. Show heatmap top annotation name.
`topAnnotationHeight` | Passed to HeatmapAnnotation. Column annotation height. rowAnnotation. Show legend for module annotation.
`showModuleLabel` | Show left side module labels.
`moduleLabel` | The left side row titles for module heatmap. Must be vector of the same length as `featureModule`. Default "auto", which automatically pulls module labels from `x`.
`moduleLabelSize` | Passed to gpar. The size of text (in points).
`width` | Passed to multi_panel_figure. The width of the output figure.
`height` | Passed to multi_panel_figure. The height of the output figure.
`unit` | Passed to multi_panel_figure. Single character object defining the unit of all dimensions defined.
`ncol` | Integer. Number of columns of module heatmaps. If `NULL`, then this will be automatically calculated so that the number of columns and rows will be approximately the same. Default `NULL`.
`useRaster` | Boolean. Rasterizing will make the heatmap a single object and reduced the memory of the plot and the size of a file. If `NULL`, then rasterization will be automatically determined by the underlying Heatmap function. Default `TRUE`.
`...` | Additional parameters passed to Heatmap.

### Value

A multi_panel_figure object if plotting more than one module heatmaps. Otherwise a HeatmapList object is returned.

### Examples

    data(sceCeldaCG)
    moduleHeatmap(sceCeldaCG, width = 250, height = 250,
     displayName = "rownames")

[Package celda version 1.8.1 Index]