PolyGenius
Contents

visualize

Visualization functions for PolyGenius

visualize is an environment of plotting entry points, grouped by the domain object each one reads. Compute or generate a result first, then pass that object straight to a plot rather than reconstructing plotting inputs by hand.

Usage

visualize$palette$categorical(n = NULL, variant = "line", system = NULL)

visualize$palette$sequential(hue = "green", n = NULL, system = NULL)

visualize$palette$diverging(system = NULL)

visualize$palette$theme(...)

visualize$palette$scale$color(...)

visualize$palette$scale$colour(...)

visualize$palette$scale$fill(...)

Arguments

ArgumentDescription
nInteger scalar, or NULL (default). For categorical(), how many colors to return, at most 30. The first 10 are the system's primary hues; 11-30 repeat them at two further lightness levels, so the first 10 never change as n grows. For sequential(), how many interpolated steps to return.
variantOne of "line" (default), "fill", "soft", "pale", "pooled". Plot-mark role, which fixes the lightness a hue is drawn at (700, 500, 300 and 100 respectively), so a line and its companion fill are the same hue. "pooled" is not a peer category: it returns one fixed ink color and ignores n and system.
hueCharacter scalar, default "green". Name of the hue in visualize$palette$tokens the sequential ramp runs to.
systemCharacter scalar naming a palette system, or NULL (default). See Palette systems.
...For theme(), base_size (numeric scalar, default 8) and base_family (character scalar, default "sans"). For scale$color(), scale$colour() and scale$fill(), variant (default "line" for color, "fill" for fill) and system as above, plus any further argument of ggplot2::discrete_scale().

Value

  • categorical(): an unnamed character vector of n hex colors, or the full ordered set of 30 when n is NULL, or one ink color when variant = "pooled". Aborts when n exceeds 30 rather than interpolating past it.
  • sequential(): an unnamed character vector of hex colors, the 2-stop anchor (the background neutral to the hue's "900") when n is NULL, otherwise n interpolated stops. Aborts on a hue absent from visualize$palette$tokens.
  • diverging(): an unnamed character vector of 3 hex colors, in the order green "900", the background neutral, purple "900".
  • theme(): a ggplot2 theme, added to a plot with +.
  • scale$color(), scale$colour(), scale$fill(): a ggplot2 discrete Scale object, added to a plot with +.

An unknown system aborts, listing the available ones.

Details

Each sub-environment groups the plots that read one kind of object.

Data plots (visualize$data) read scores, similarity and embeddings: scores$distribution(), scores$distribution.heatmap(), scores$heatmap(), similarity$samples()/$models(), embedding$samples()/$models().

Model composition plots (visualize$models) describe the model library: sizes(), reuse(), uniqueness(), top.variants().

Association plots (visualize$associations) render association results: forest(), heatmap(), landscape(), survival(), variants.qq().

Evaluate plots (visualize$evaluate) render evaluation results: performance(), incremental(), association(), stratification(), compare(), redundancy(), profile().

Genome tracks (visualize$genome) share a positioned axis; stack() composes tracks, overview() builds the default view in one call and loci() supplies bands: stack(), overview(), manhattan(), prs(), reuse(), coverage(), effects(), concordance(), convergence(), cumulativeWeight(), attribution(), loci().

Execution monitoring (visualize$execution) reads a run's .jsonl event stream: dashboard(), performance().

Palette and theme (visualize$palette) exposes the color tokens and ggplot2 building blocks every plot draws with, so a hand-written figure can match package output. Nothing there reads a PolyGenius object or computes a statistic.

Every entry point above accepts a palette argument for per-plot color overrides, except the composers and the execution readers -- genome$stack, genome$overview, genome$loci, execution$dashboard and execution$performance -- and the evaluate family, which reads the package-wide categorical, sequential and diverging palettes without a per-call override. The package-wide default is set with workspace$config$update(palette = ...).

Return types differ by entry point across six shapes: a ggplot, a patchwork, a ComplexHeatmap heatmap, a PolyGeniusGenomeTrack, a named list of ggplots, or a file path. Nothing may assume + composition works. A patchwork inherits ggplot, so the two are told apart by class(x)[[1]], which is what test-visualize-return-types.R pins.

Palette and theme

visualize$palette$tokens is a named list of 10 hues (red, rose, orange, amber, purple, lavender, blue, teal, green, olive), each a named vector of 5 hex colors keyed "900" (darkest) through "700", "500", "300" and "100" (palest). visualize$palette$neutral is a named vector of 7 greys for chrome. categorical(), sequential() and diverging() select from them and return plain hex colors; theme() and scale$color(), scale$colour() (an alias) and scale$fill() wrap them for ggplot2.

system names a palette bundle: "polygenius" (the tokens) or "nature-npg", a 10-color qualitative palette. NULL reads workspace$config$palette. Sequential and diverging ramps are shared across systems.

Examples

# Hex colors, for any plotting system
visualize$palette$categorical(n = 5)
visualize$palette$sequential(hue = "blue", n = 7)
visualize$palette$diverging()

# Raw tokens
visualize$palette$tokens$green[["700"]]
visualize$palette$neutral[["mid_grey"]]

# ggplot building blocks, added to a plot with `+`
house.theme <- visualize$palette$theme(base_size = 9)
fill.scale <- visualize$palette$scale$fill(variant = "soft")
Aliases: visualize, visualize$data, visualize$models, visualize$associations, visualize$evaluate, visualize$genome, visualize$palette, visualize$execution, visualize$data$scores, visualize$data$similarity, visualize$data$embedding, visualize$palette$scale, visualize$palette$tokens, visualize$palette$neutral, visualize$palette$categorical, visualize$palette$sequential, visualize$palette$diverging, visualize$palette$theme, visualize$palette$scale$color, visualize$palette$scale$colour, visualize$palette$scale$fill