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

profile(
  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

Show values as a share of the total rather than raw counts.

show_header, show_bar_labels

Toggle the header band and tick labels.

y_label

Axis label.

theme

Optional named list of theme overrides.

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.

Note that profile() masks the stats::profile() generic once the package is attached. Unlike bioheatmap(), which is aliased to keep clear of stats::heatmap(), this one keeps the obvious name: stats::profile() profiles a fitted model's likelihood, which no caller of this package is reaching for by accident. Call stats::profile() explicitly if you need it.

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")
)
profile(df)