Skip to contents

Draws a heatmap of curated subtype‑driver genes using the output of classifyHNSC. The function scales expression values per gene and annotates samples by their predicted molecular subtype.

Usage

plot_subtype_heatmap(
  expr,
  subtype,
  idType = c("SYMBOL", "ENSEMBL", "ENTREZID", "REFSEQ"),
  gene_set = NULL,
  main = "Subtype heatmap",
  show_rownames = TRUE,
  cluster_rows = FALSE,
  cluster_cols = FALSE,
  cap = NULL,
  color = NULL,
  low_color = "#2c7bb6",
  mid_color = "white",
  high_color = "#d7191c",
  n_color = 100,
  silent = FALSE,
  ...
)

Arguments

expr

A numeric gene expression matrix with genes in rows and samples in columns. Row names must be gene symbols (default) or identifiers matching idType. Column names must be sample IDs.

subtype

A named factor vector giving the predicted subtype for each sample (e.g. c(sample1 = "Basal", sample2 = "Classical")). This is the direct output of classifyHNSC(..., outputType = "class"). A two‑column data frame with columns Sample and Subtype is also accepted for convenience, but will be coerced to a named vector. Probability matrices are not allowed.

idType

Character string specifying the gene identifier type used in the rownames of expr. Acceptable values are "SYMBOL" (default), "ENSEMBL", "ENTREZID", or "REFSEQ". Non‑symbol identifiers are automatically converted to gene symbols.

gene_set

A named list of genes to display, where names correspond to the subtype levels. The default uses a built‑in curated set of known HNSCC subtype markers.

main

Title for the heatmap.

show_rownames

Logical, whether to show gene names (default TRUE).

cluster_rows

Logical, whether to cluster rows (default FALSE).

cluster_cols

Logical, whether to cluster columns (default FALSE).

cap

Numeric value at which to cap (trim) the scaled expression values. Values above cap are set to cap, values below -cap are set to -cap. Default is NULL (no capping). Typical choices are 2 or 3, but the appropriate threshold depends on the data distribution.

color

A character vector of colours to use for the heatmap gradient. If NULL (default), a three‑colour gradient is built from low_color, mid_color and high_color with n_color levels. If supplied, this vector is passed directly to pheatmap and the low_/mid_/high_ arguments are ignored.

low_color, mid_color, high_color

Colours for the gradient when color = NULL. low_color and high_color map to the minimum and maximum scaled values, while mid_color corresponds to zero. Defaults are "#2c7bb6" (blue), "white", and "#d7191c" (red), respectively.

n_color

Number of colour levels to generate in the gradient (default 100). Only used when color = NULL.

silent

Logical. If FALSE (default), the heatmap is drawn directly to the current graphics device. If TRUE, the heatmap is built but not drawn, returning a gtable object for manual drawing with grid::grid.draw().

...

Additional arguments passed to pheatmap. Note that color is set internally and should not be passed via ....

Value

A pheatmap object (invisibly). The heatmap is drawn as a side effect.

Note

The pheatmap package must be installed.

Examples

if (FALSE) { # \dontrun{
# Directly from classifyHNSC output
subtypes <- classifyHNSC(TCGA_LUSC, outputType = "class")
plot_subtype_heatmap(TCGA_LUSC, subtypes)

# With custom capping and colours
plot_subtype_heatmap(TCGA_LUSC, subtypes,
                     cap = 2,
                     low_color = "green", high_color = "red")
} # }