PolyGenius
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

ArgumentDescription
dataA PolyGeniusStudy object. A summary-mode study (no genotype backend attached, or an empty samples table) is refused.
keyUnquoted name of the embedding matrix in data$samples or data$models, for example PCA.
dimsLength-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.byOptional 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.byOptional 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.
highlightOptional 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.
paletteCategorical 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.
themeOne 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

Aliases: visualize_embedding, .visualize.embedding, visualize$data$embedding$samples, visualize$data$embedding$models