Skip to contents

The HeatmapFeatures function draws a heatmap of features by cluster identity.

Usage

HeatmapFeatures.SingleCellExperiment(
  object,
  clustering.label,
  features,
  use.color,
  seed.color,
  ...
)

# S4 method for class 'SingleCellExperiment'
HeatmapFeatures(
  object,
  clustering.label,
  features,
  use.color = NULL,
  seed.color = 123,
  ...
)

Arguments

object

of SingleCellExperiment class

clustering.label

A variable name (of class character) available in the cell metadata colData(object) with the clustering labels (character or factor) to use.

features

Feature names to plot by cluster (character) matching row.names(object).

use.color

Character specifying the colors for the clusters. By default NULL, i.e., colors are randomly chosen based on the seed given at seed.color. It is overwritten in case the argument annotation_colors is provided.

seed.color

Seed to randomly select colors for the clusters. By default 123. It is overwritten in case the argument annotation_colors is provided.

...

Parameters to pass to pheatmap::pheatmap function.

Value

nothing

Examples

# Import package
suppressPackageStartupMessages(library("SingleCellExperiment"))

# Create toy SCE data
batches <- c("b1", "b2")
set.seed(239)
batch <- sample(x = batches, size = nrow(iris), replace = TRUE)
sce <- SingleCellExperiment(assays = list(logcounts = t(iris[,1:4])),  
                            colData = DataFrame("Species" = iris$Species, 
                                                "Batch" = batch))
colnames(sce) <- paste0("samp", 1:ncol(sce))

# Plot features by clustering, i.e., grouping variable
# without scaling rows (using 'logcounts' expression): 
HeatmapFeatures(object = sce, clustering.label = "Species", 
                features = row.names(sce)[1:4])


# scaling rows: 
HeatmapFeatures(object = sce, clustering.label = "Species", 
                features = row.names(sce)[1:4], scale = "row") # scale