Skip to contents

The cohort alteration landscape: a gene x sample grid of categorical alteration classes, with a per-sample burden barplot above, a per-gene frequency barplot to the right, and optional clinical annotation strips below. The grid is drawn on a canvas, so cohort-scale matrices (hundreds of genes by thousands of samples) stay interactive; labels and the legend are a crisp vector overlay.

Usage

oncoplot(
  alterations,
  genes = NULL,
  samples = NULL,
  classes = NULL,
  class_colors = NULL,
  burden = NULL,
  annotations = NULL,
  show_burden = TRUE,
  show_frequency = TRUE,
  show_annotations = TRUE,
  show_legend = TRUE,
  empty_color = "#EFE9DC",
  burden_color = "#0E7175",
  frequency_color = "#ED773C",
  x_label = "samples",
  burden_label = "alterations",
  cell_gap_x = 0.12,
  cell_gap_y = 0.16,
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL
)

Arguments

alterations

A data frame of altered pairs with columns gene, sample and class. Unaltered pairs are simply absent; the full grid is reconstructed from genes and samples.

genes

Character vector of genes, top row first. Defaults to the genes present in alterations, most frequently altered first.

samples

Character vector of samples, left column first. Defaults to the memo-sorted order.

classes

Character vector of alteration classes, which fixes both the legend order and the colour assignment. Defaults to the classes present.

class_colors

Character vector of hex colours, one per entry of classes. NULL uses the component's categorical palette.

burden

Numeric vector, one value per sample, for the top barplot. Defaults to the number of altered genes per sample.

annotations

Optional list of clinical strips. Each element is a list with name (character scalar), values (one value per sample) and an optional colors.

show_burden, show_frequency, show_annotations, show_legend

Toggle the surrounding panels.

empty_color

Fill for a gene x sample cell with no alteration.

burden_color, frequency_color

Hex fills for the per-sample burden bars above the grid and the per-gene frequency bars to its right.

x_label, burden_label

Axis titles for the sample axis and the burden barplot.

cell_gap_x, cell_gap_y

Gap between cells as a fraction of cell size. Set both to 0 for a solid block, which is what you want once a cohort is wide enough that the gaps eat more pixels than the cells.

theme

Optional named list of theme overrides merged over the component defaults in the browser.

width, height

Widget dimensions (any valid CSS size).

element_id

Optional explicit DOM id.

Value

An htmlwidget object.

Details

The component renders rows and columns in exactly the order it is given and uses the burden and frequency values as supplied. Ordering an oncoplot (memo sort, burden sort, sort by a clinical variable) is the caller's decision, and re-deriving it in the browser would let two renderings of the same data disagree. Use oncoplot_memo_sort() to get the conventional order.

Examples

alt <- data.frame(
  gene = c("TP53", "TP53", "PIK3CA", "PIK3CA", "GATA3"),
  sample = c("S1", "S2", "S2", "S3", "S1"),
  class = c("Missense", "Truncating", "Missense", "Amplification", "Missense")
)
oncoplot(alt)