Skip to contents

This function creates a heatmap using the numeric columns from the provided data frame. It provides the ability to hide row and column names, adjust font sizes and clustering, and apply additional transformations such as log10 or combined z‑scoring. A file name with extension may be provided via title to save the heat map to disk; otherwise the plot is drawn on the active graphics device.

Usage

cyt_heatmap(
  data,
  scale = c(NULL, "log2", "log10", "row_zscore", "col_zscore", "zscore"),
  annotation_col = NULL,
  annotation_side = c("auto", "row", "col"),
  show_row_names = FALSE,
  show_col_names = TRUE,
  fontsize_row = 10,
  fontsize_col = 10,
  cluster_rows = TRUE,
  cluster_cols = TRUE,
  title = NULL
)

Arguments

data

A data frame. Only numeric columns are used to construct the heat map.

scale

Character specifying an optional scaling. Accepts NULL (no scaling), "log2", "log10", "row_zscore", "col_zscore" or "zscore" (apply both row and column z‑scoring). Default is NULL.

annotation_col

Optional. Either the name of a column in data or a vector of length equal to the number of rows or columns of the numeric matrix. If a column name is supplied the function determines whether it annotates rows or columns based on its length or the value of annotation_side.

annotation_side

Character. One of "auto", "row" or "col". When "auto" (default) the side is determined by matching the length of annotation_col to rows or columns.

show_row_names

Logical. If TRUE row names are shown Default is FALSE.

show_col_names

Logical. If FALSE column names are hidden. Default is TRUE.

fontsize_row

Numeric. Font size for row names. Default is 10.

fontsize_col

Numeric. Font size for column names. Default is 10.

cluster_rows

Logical. If TRUE (default), rows are clustered.

cluster_cols

Logical. If TRUE (default), columns are clustered.

title

Character. The heat map title or file name. If title ends with ".pdf" or ".png" (case insensitive), the heat map is saved to that file and no title is printed on screen. If NULL (default), the heat map is drawn on the active device without saving and without a main title.

Value

Invisibly returns the pheatmap object created by pheatmap::pheatmap().

Author

Shubh Saraswat

Examples

# Load sample data
data("ExampleData1")
data_df <- ExampleData1
# Generate a heatmap with log2 scaling and annotation based on
# the "Group" column
cyt_heatmap(
  data = data_df[, -c(2:3)],
  scale = "log2",  # Optional scaling
  annotation_col = "Group",
  annotation_side = "auto",
  title = NULL
)