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,sampleandclass. Unaltered pairs are simply absent; the full grid is reconstructed fromgenesandsamples. A row with a missing gene or sample is left out before anything is counted, so it adds no sample column, gene row or class.- genes
Character vector of genes, top row first. Defaults to the genes present in
alterations, the gene altered in the most samples first.- samples
Character vector of samples, left column first. Defaults to the memo-sorted order of the samples present in
alterations. The frequency bars divide by the number of samples shown, so passsamplesto count unaltered samples of the cohort too.- classes
Character vector of alteration classes, which fixes both the legend order and the colour assignment. Defaults to the classes present, most frequent first, equal counts by name in code point order, as in Python. A missing class (
NA) stops with an error, unlessclassesholdsNAtoo: then it is a class of its own, sent as null. A gene and sample with two or more different classes is drawn as"Multi-hit", in dark grey, which is added to the classes when it occurs.- class_colors
Character vector of hex colours, one per entry of
classes.NULLuses 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),valuesand an optionalcolors.valuesis a vector named by sample id, matched to the columns by name. An unnamed vector is read in the order ofsamples, so it needssamplesto be given. The levels of a strip, in legend order, are the levels of a factor, unused ones included, and otherwise the distinct values in code point order, as in Python. Namedcolorsgo to the level of the same name, whatever their order, and every level needs one. Unnamedcolorsgo to the levels in that order.- 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
0for 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. Its
paddingentry is the space in px between the edge of the widget and the plot: one number for every side, or numbers namedtop,right,bottomandleftin a list or vector, a side left out keeping the default of 10. Itscategoricalentry is an ordered palette: the colours go to the alteration classes in order, and names on the colours are not matched to them. A colour given as a CSS custom property, such asbackground = "var(--bg)", takes the value the page gives it when the plot draws. After the page changes the property, what the plot drew on a canvas keeps the old colour until it draws again: resize the widget or render it again.- width, height
Widget dimensions (any valid CSS size).
- element_id
Optional explicit DOM id.
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)