Skip to contents

A hierarchical treemap of gene-set / pathway composition. The hierarchy is built from a flat edge list with d3-hierarchy (stratify + treemap) and tiles are rendered on a canvas so thousands of leaves stay interactive; tile labels and a drill-down breadcrumb are drawn as a crisp vector overlay. Click a tile to zoom into that node and the breadcrumb to zoom back out.

Usage

treemap(
  data,
  tile = c("squarify", "binary"),
  padding_inner = 1,
  color_by = c("parent", "value"),
  colormap = c("viridis", "rdbu"),
  label_min_size = 32,
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL
)

Arguments

data

A data frame describing a tree as an edge list. Required columns: id (unique node id) and parent (id of the parent; the root's parent is NA or ""). A numeric value column supplies leaf weights (internal nodes are summed automatically); an optional label column supplies display names.

tile

Tiling algorithm: "squarify" (golden-ratio rectangles) or "binary" (balanced binary partition).

padding_inner

Padding between sibling tiles, in pixels.

color_by

Color leaves by "parent" (top-level ancestor, categorical) or by "value" (a sequential/diverging ramp).

colormap

Ramp used when color_by = "value": "viridis" or "rdbu".

label_min_size

Minimum tile side (px) before a label is drawn.

theme

Optional named list of theme overrides (colors, fonts, ...) merged over the component defaults in the browser. NULL uses the default theme.

width, height

Widget dimensions (any valid CSS size).

element_id

Optional explicit DOM id.

Value

An htmlwidget object.

Examples

df <- data.frame(
  id = c("root", "P1", "P2", "g1", "g2", "g3"),
  parent = c(NA, "root", "root", "P1", "P1", "P2"),
  value = c(0, 0, 0, 3, 5, 2),
  label = c("All", "Pathway 1", "Pathway 2", "Gene 1", "Gene 2", "Gene 3")
)
treemap(df)