A GPU-accelerated 2-D scatter viewer for dimensionality-reduction output. Points are rendered with WebGL (via regl-scatterplot) so hundreds of thousands to millions of cells stay interactive at 60fps, while the legend and an optional axis frame are drawn as crisp vector overlays. Lasso selection is enabled (drag from empty space to select points).
Usage
embedding(
data,
point_size = 3,
point_scale_mode = c("asinh", "linear", "constant"),
opacity = 0.8,
color_mode = c("auto", "categorical", "continuous"),
colormap = c("viridis", "rdbu"),
mouse_mode = c("panZoom", "lasso"),
aspect = c("fill", "equal"),
padding = 0.04,
x_label = "UMAP 1",
y_label = "UMAP 2",
show_axes = FALSE,
show_legend = TRUE,
theme = NULL,
width = NULL,
height = NULL,
element_id = NULL
)Arguments
- data
A data frame with numeric columns
xandy(the embedding coordinates). An optionalcolorcolumn drives coloring: a character or factor column is treated as categorical (discrete legend), a numeric column as continuous (sequential colormap + colorbar). A factorcolorfixes the legend order and the color assignment to its levels, and keeps unused levels in the legend, the waydrop = FALSEdoes in ggplot2. An optionallabelcolumn supplies per-point tooltip text.- point_size
Point radius in pixels. Under the default
point_scale_modethe renderer scales this by the camera and clamps it to one pixel on a widely-scaled plot, so setpoint_scale_mode = "constant"if you want it honoured literally.- point_scale_mode
How
point_sizeresponds to zoom."asinh"and"linear"shrink points as you zoom out, which keeps a dense embedding readable, but both floor at one pixel once the camera scale drops below1 / point_size."constant"sizes points in literal pixels.- opacity
Point opacity in
[0, 1].- color_mode
How to interpret the
colorcolumn:"auto"detects from its type, or force"categorical"/"continuous".- colormap
Sequential color ramp for continuous coloring:
"viridis"or"rdbu".- mouse_mode
Primary drag gesture:
"panZoom"(default) pans/zooms and"lasso"makes a plain drag draw a selection.- aspect
How the fitted view maps data units onto pixels.
"fill"stretches each axis to fill the canvas, which suits a UMAP, whose axes carry no units."equal"gives both axes the same units per pixel; use it when the axes share units and their relative spread is part of the claim, as in PCA scores.- padding
Fraction of the data range to pad around the fitted view. Larger values zoom out, leaving more empty space at the edges, which stops the outermost points being clipped by the canvas border.
- x_label, y_label
Axis titles (shown when
show_axes = TRUE).- show_axes
Draw the axis frame + ticks (embeddings usually hide axes).
- show_legend
Draw the legend (discrete swatches or a colorbar).
- theme
Optional named list of theme overrides (colors, fonts, ...) merged over the component defaults in the browser.
NULLuses the default theme.- width, height
Widget dimensions (any valid CSS size).
- element_id
Optional explicit DOM id.