do_ExpressionHeatmap() | Averaged expression heatmaps

Expression heatmaps display averaged gene expression across groups. Each cell in the heatmap represents the mean expression of a gene within a group (cluster, condition, etc.), providing a compact summary of expression patterns.


Basic usage

Create an expression heatmap for a set of genes:

genes <- c("CDC25C", "KIF18B", "KIF14", "CENPE",
           "DNAAF1", "ADGB", "CFAP61", "CFAP157",
           "KCNQ5", "MEOX2", "MBP", "SNTG1",
           "S100A1", "MGP", "TNNT1", "H2AFJ")

p <- SCpubr::do_ExpressionHeatmap(sample = sample,
                                  features = genes)
p


Multiple grouping variables

Group by multiple metadata variables to create stacked heatmaps:

p <- SCpubr::do_ExpressionHeatmap(sample = sample,
                                  features = genes,
                                  group.by = c("Annotation", "subtype"))
p


Clustering

Automatic clustering (default)

By default, both genes and groups are hierarchically clustered:

p <- SCpubr::do_ExpressionHeatmap(sample = sample,
                                  features = genes,
                                  cluster = TRUE)
p

Disable clustering

Preserve the original order:

p <- SCpubr::do_ExpressionHeatmap(sample = sample,
                                  features = genes,
                                  cluster = FALSE)
p


Display values

Show expression values as text overlaid on cells:

p <- SCpubr::do_ExpressionHeatmap(sample = sample,
                                  features = genes,
                                  values.show = TRUE,
                                  values.threshold = 1.5,
                                  values.size = 3,
                                  values.round = 1)
p

Parameter Description
values.show Display numeric values on cells
values.threshold Threshold for switching text color (white above, black below)
values.size Text size
values.round Decimal places to display

Scale customization

Clamp values

p <- SCpubr::do_ExpressionHeatmap(sample = sample,
                                  features = genes,
                                  min.cutoff = 0,
                                  max.cutoff = 1.5)
p

Symmetrical (diverging) scale

Center the color scale around zero:

p <- SCpubr::do_ExpressionHeatmap(sample = sample,
                                  features = genes,
                                  enforce_symmetry = TRUE,
                                  diverging.palette = "RdBu")
p


Visual customization

Customize grid and border colors

p <- SCpubr::do_ExpressionHeatmap(sample = sample,
                                  features = genes,
                                  grid.color = "blue",
                                  border.color = "red")
p


Parameter reference

Note

For parameters shared across many functions (color palettes, typography, legend styling), see Shared features.

Core parameters

Parameter Description Default
features Genes to display

Clustering & ordering

Parameter Description Default
cluster Hierarchically cluster genes and groups TRUE
features.order Custom gene order NULL
groups.order Custom group order (named list) NULL

Value display

Parameter Description Default
values.show Show values on cells FALSE
values.threshold Color switch threshold NULL
values.size Value text size 3
values.round Decimal places 1

Appearance

Parameter Description Default
grid.color Color between cells "white"
border.color Heatmap border color "black"
axis.text.x.angle X-axis label rotation 45

See also