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
| Argument | Description |
|---|---|
n | Integer 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. |
variant | One 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. |
hue | Character scalar, default "green". Name of the hue in visualize$palette$tokens the sequential ramp runs to. |
system | Character 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 ofnhex colors, or the full ordered set of 30 whennisNULL, or one ink color whenvariant = "pooled". Aborts whennexceeds 30 rather than interpolating past it.sequential(): an unnamed character vector of hex colors, the 2-stop anchor (thebackgroundneutral to the hue's"900") whennisNULL, otherwiseninterpolated stops. Aborts on a hue absent fromvisualize$palette$tokens.diverging(): an unnamed character vector of 3 hex colors, in the order green"900", thebackgroundneutral, purple"900".theme(): a ggplot2theme, added to a plot with+.scale$color(),scale$colour(),scale$fill(): a ggplot2 discreteScaleobject, 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")