Skip to contents

Draw a CNV heatmap split by chromosomes and annotated by a sample/cell grouping variable. Designed for objects that provide cnv.data (cells × bins), annotation (with cell.id and a grouping column), and chr_pos (per-chromosome bin start indices). Supports on-screen display and saving to PDF/PNG with optional auto-sizing based on data dimensions.

Usage

cnv_heatmap(
  cnv.obj,
  groupby = "cell.label",
  color_panel = c("#ffadad", "#ffd6a5", "#fdffb6", "#caffbf", "#9bf6ff", "#a0c4ff",
    "#bdb2ff", "#ffc6ff"),
  min_value = -3,
  max_value = 3,
  show = TRUE,
  save = FALSE,
  outfile = "cnv_heatmap.pdf",
  auto_size = TRUE,
  width_in = 10,
  height_in = 6,
  res = 300,
  ...
)

Arguments

cnv.obj

A list-like object with components:

  • cnv.data: numeric matrix, rows = cells/spots, cols = bins.

  • annotation: data.frame with at least columns cell.id and the column referenced by groupby.

  • chr_pos: named numeric/integer vector or list mapping chromosome names to 0-based start indices of bins (i.e., first bin index for chromosome k is start+1).

groupby

Character scalar; column name in cnv.obj$annotation used to color rows (default "cell.label").

color_panel

Character vector of colors used for group annotation (recycled to the number of groups).

min_value, max_value

Numeric; lower/upper limits for the heatmap color mapping (default -3 and 3).

show

Logical; draw to current device (default TRUE).

save

Logical; if TRUE, write a file to outfile.

outfile

Character; output filename. If it ends with .pdf or .png, that format is used. Otherwise both PDF and PNG are written with sensible names.

auto_size

Logical; if TRUE (default) choose device size based on matrix dimensions.

width_in, height_in

Numeric; device width/height in inches used when auto_size = FALSE. Ignored otherwise.

res

Integer; PNG resolution (dpi) when saving PNG (default 300).

...

Passed to ComplexHeatmap::Heatmap().

Value

(Invisibly) a HeatmapList object.

Examples

if (FALSE) { # \dontrun{
ht <- cnv_heatmap(
  cnv.obj,
  groupby = "cell.label",
  show = TRUE,
  save = TRUE,
  outfile = "cnv_heatmap.pdf"
)
} # }