Contents
visualize$data$embedding$samples
visualize pre-computed embeddings
Scatters two dimensions of a stored embedding, one point per sample or per
model. visualize$data$embedding$samples() reads the embedding matrices in
data$samples; visualize$data$embedding$models() reads the per-study model
overlay in data$models.
Usage
visualize$data$embedding$samples(data, key, dims = c(1, 2), group.by = NULL, split.by = NULL, highlight = NULL, palette = NULL, theme = c("polygenius", "none"), ...)
visualize$data$embedding$models(data, key, dims = c(1, 2), group.by = NULL, split.by = NULL, highlight = NULL, palette = NULL, theme = c("polygenius", "none"), ...)Arguments
| Argument | Description |
|---|---|
data | A PolyGeniusStudy object. A summary-mode study (no genotype backend attached, or an empty samples table) is refused. |
key | Unquoted name of the embedding matrix in data$samples or data$models, for example PCA. |
dims | Length-2 selector for the plotted columns: either two column names, or two positions. Positions first try the <KEY>_<n> column-name convention (PCA_1, PCA_2) and fall back to raw column positions. Default c(1, 2). |
group.by | Optional unquoted expression, resolved by data$fetch() on the plotted axis, mapped to point color. c(expr1, expr2, ...) draws one panel per expression instead of one plot. NULL leaves points uncolored. |
split.by | Optional unquoted expression for faceting; one expression gives facet_wrap(), c(rows, cols) gives facet_grid(). More than two is an error. NULL draws a single panel. |
highlight | Optional unquoted subsetting expression over the plotted axis. Selected points keep their color and the rest are greyed to NA; with no group.by the selection is drawn black on grey with no legend. A fetching expression is an error. NULL highlights nothing. |
palette | Categorical color palette: a role name, a hue name, a vector of two or more colors, or a ramp function. NULL uses the package categorical palette. Ignored when highlight is given without group.by. |
theme | One of "polygenius" (default), "none". Plot theme. "none" gives a bare theme_minimal() to style yourself; palette colors are applied either way. |
... | Further arguments passed to geom_point(). |
Value
A ggplot object (concrete class ggplot2::ggplot) for a single
panel, or a patchwork object when group.by names two or more
expressions. Both accept +, but only the plain ggplot accepts a scale
or geom meaningfully.
Examples
visualize$data$embedding$samples(study, PCA, group.by = ancestry)
# One panel per grouping expression, faceted by sex.
visualize$data$embedding$samples(
study, PCA, dims = c(1, 3), group.by = c(ancestry, batch), split.by = sex)See Also
compute$embedding$samples(), which produces the matrix, and visualize$data$similarity$samples() for the pairwise matrix an embedding is often derived from.
Other visualize-data:
visualize.scores.distribution(),
visualize.scores.distribution.heatmap(),
visualize.scores.heatmap(),
visualize_similarity