Skip to contents

An ordered bar profile whose categories collapse into coloured header blocks. Built for the 96-context mutational signature plot, where the bars are the trinucleotide contexts and the six blocks are the substitution classes, a layout conventional enough that readers parse it without a legend. It generalises to any ordered categorical profile that groups into runs, hence the generic name.

Usage

bioprofile(
  data,
  groups = NULL,
  group_colors = NULL,
  title = NULL,
  bar_width = 0.62,
  as_fraction = FALSE,
  show_header = TRUE,
  show_bar_labels = TRUE,
  y_label = "mutations",
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL
)

profile_plotomics(
  data,
  groups = NULL,
  group_colors = NULL,
  title = NULL,
  bar_width = 0.62,
  as_fraction = FALSE,
  show_header = TRUE,
  show_bar_labels = TRUE,
  y_label = "mutations",
  theme = NULL,
  width = NULL,
  height = NULL,
  element_id = NULL
)

Arguments

data

A data frame with a numeric value column. Optional group (category per bar, whose contiguous runs become the header blocks) and label (per-bar tick label) columns.

groups

Character vector fixing the group order and colour assignment. Defaults to order of appearance.

group_colors

One hex colour per group. NULL uses the component's categorical palette.

title

Optional title drawn above the header band.

bar_width

Fraction of each slot the bar occupies, in (0, 1].

as_fraction

TRUE to show each value as a share of the total, in place of the raw count. Every finite value must then be 0 or more.

show_header, show_bar_labels

Toggle the header band and tick labels.

y_label

Axis label.

theme

Optional named list of theme overrides. Its padding entry is the space in px between the edge of the widget and the plot: one number for every side, or numbers named top, right, bottom and left in a list or vector, a side left out keeping the default of 10. Its categorical entry is an ordered palette: the colours go to the groups in order, and names on the colours are not matched to them. A colour given as a CSS custom property, such as background = "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.

Value

An htmlwidget object.

Details

Bars are canvas-drawn, so a few thousand bins (a binned copy-number profile, a coverage track) work as well as 96 contexts.

Bars are drawn in the order given. For SBS96 that order is part of the convention, so the component does not sort.

Named bioprofile() rather than profile() so that attaching the package does not mask the stats::profile() generic, which profiles a fitted model's likelihood. This follows bioheatmap(), which keeps clear of stats::heatmap() the same way. profile_plotomics() is an alias, for symmetry with heatmap_plotomics().

Examples

df <- data.frame(
  value = c(3, 5, 2, 8),
  group = c("C>A", "C>A", "C>T", "C>T"),
  label = c("ACA", "ACC", "TCA", "TCT")
)
bioprofile(df)