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.
Arguments
- data
A data frame describing a tree as an edge list. Required columns:
id(unique node id) andparent(id of the parent; the root's parent isNAor""). A numericvaluecolumn supplies leaf weights (internal nodes are summed automatically); an optionallabelcolumn 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.
NULLuses the default theme.- width, height
Widget dimensions (any valid CSS size).
- element_id
Optional explicit DOM id.
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)