Variants along a protein, drawn over its domain architecture: a backbone spanning the sequence with domain rectangles on it, mutation stems whose head area is proportional to recurrence, and an optional post-translational modification track below. Hotspots inside a functional domain read very differently from truncating variants scattered across one, which is what this figure exists to show. Variants at one residue stack on one stem, most recurrent at the bottom, so the top of a stem is the residue's total.
Usage
lollipop(
variants,
length,
gene = NULL,
uniprot = NULL,
domains = NULL,
ptms = NULL,
classes = NULL,
class_colors = NULL,
domain_colors = NULL,
label_top_n = 12,
show_ptms = TRUE,
show_domains = TRUE,
show_legend = TRUE,
min_head_radius = 3,
max_head_radius = 11,
y_label = "samples",
backbone_color = "#E6DCC8",
stem_color = "#93a1b8",
theme = NULL,
width = NULL,
height = NULL,
element_id = NULL
)Arguments
- variants
A data frame with columns
position(amino-acid position, 1-based) andcount(recurrence, zero or more; a variant with a missing count is not drawn). Optionalclass(variant class) andlabel(e.g."R175H") columns drive the colour and the text labels.- length
Protein length in residues.
- gene, uniprot
Identifiers shown on the axis title.
- domains
Optional data frame of domain rectangles with columns
name,startandend.- ptms
Optional data frame of modification sites with columns
positionandtype.- classes
Character vector fixing the legend order and colour assignment. Defaults to the classes present, most frequent first, equal counts by name in code point order, as in Python.
- class_colors, domain_colors
Character vectors of hex colours.
NULLgives the classes the categorical palette of the theme. The domains never take that palette:NULLgives them a muted palette of their own that the default class colours do not use,#9F95C3,#B2C28C,#84B2C0,#AD9967,#B6BAD4,#CE9B79,#7EA3D4and#7DAB88, repeated past the eighth domain. Each domain name is dark or light, whichever reads on its fill.- label_top_n
Label the
nmost recurrent variants. Which stems get a label is resolved here and sent to the browser, so a redraw, an export and any static counterpart all label the same ones.0labels none.- show_ptms, show_domains, show_legend
Toggle the surrounding tracks.
- min_head_radius, max_head_radius
Stem head radius range in pixels. Head area is proportional to recurrence, so these bound the mapping rather than setting a size: raise
max_head_radiuswhen one hotspot dwarfs the rest and you want the difference to read at a glance.- y_label
Axis title for the recurrence axis. It also names the count in the tooltip: "12 samples" with the default, and "frequency: 0.3" for
y_label = "frequency".- backbone_color, stem_color
Hex colours for the protein backbone rectangle and the mutation stems.
- theme
Optional named list of theme overrides. Its
categoricalpalette colours the variant classes only, not the domains; seedomain_colors. Itspaddingentry 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. 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
Stems and domains are canvas-drawn so a protein with thousands of variants stays responsive; labels, axis and legend are a vector overlay.
Examples
v <- data.frame(
position = c(175, 248, 273),
count = c(21, 15, 13),
class = c("Missense", "Missense", "Missense"),
label = c("R175H", "R248Q", "R273H")
)
d <- data.frame(name = "P53 DNA-binding", start = 100, end = 288)
lollipop(v, length = 393, gene = "TP53", uniprot = "P04637", domains = d)