| Title: | Colour Palettes for 'ggplot2' and Faster 'Bioconductor' Analysis |
|---|---|
| Description: | Provides drop-in replacements for the default colour scales of 'ggplot2', with discrete, continuous, binned and diverging scales and one switch for every plot. Also makes 'clusterProfiler', 'GOSemSim', 'DESeq2' and 'sva' faster when loaded: GO and KEGG data are cached on disk, and slow internal steps are replaced by vectorised code. Results are identical to the original functions. |
| Authors: | catch-26 [aut, cre] |
| Maintainer: | catch-26 <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 26.11.0 |
| Built: | 2026-11-20 00:11:09 UTC |
| Source: | https://github.com/catch-26/paradoxR |
Deletes the GO annotation data, enrichGO() results and KEGG tables that
paradoxR keeps in memory and on disk. The cache lives in
tools::R_user_dir("paradoxR", "cache"), or in the directory set with
options(paradoxR.cache_dir = ) (the older name paradoxR.go_cache_dir
still works).
clear_cache()clear_cache()
The number of files deleted, invisibly.
clear_cache()clear_cache()
Clears the ggplot2.discrete.*, ggplot2.continuous.* and
ggplot2.binned.* options set by use_<palette>_palette(), such as
use_sienna_palette().
reset_ggplot2_palette()reset_ggplot2_palette()
The previous option values, invisibly.
use_sienna_palette() reset_ggplot2_palette()use_sienna_palette() reset_ggplot2_palette()
Drop-in replacements for ggplot2's default colour and fill scales.
scale_colour_sienna_d( ..., h_start = 18, direction = 1, harmonise = TRUE, aesthetics = "colour" ) scale_fill_sienna_d( ..., h_start = 18, direction = 1, harmonise = TRUE, aesthetics = "fill" ) scale_colour_sienna_c( palette = "ocean", ..., reverse = FALSE, aesthetics = "colour" ) scale_fill_sienna_c( palette = "ocean", ..., reverse = FALSE, aesthetics = "fill" ) scale_colour_sienna_b( palette = "ocean", ..., reverse = FALSE, aesthetics = "colour" ) scale_fill_sienna_b( palette = "ocean", ..., reverse = FALSE, aesthetics = "fill" ) scale_colour_sienna_div( palette = "red_blue", ..., midpoint = 0, reverse = FALSE, aesthetics = "colour" ) scale_fill_sienna_div( palette = "red_blue", ..., midpoint = 0, reverse = FALSE, aesthetics = "fill" ) scale_color_sienna_d( ..., h_start = 18, direction = 1, harmonise = TRUE, aesthetics = "colour" ) scale_color_sienna_c( palette = "ocean", ..., reverse = FALSE, aesthetics = "colour" ) scale_color_sienna_b( palette = "ocean", ..., reverse = FALSE, aesthetics = "colour" ) scale_color_sienna_div( palette = "red_blue", ..., midpoint = 0, reverse = FALSE, aesthetics = "colour" )scale_colour_sienna_d( ..., h_start = 18, direction = 1, harmonise = TRUE, aesthetics = "colour" ) scale_fill_sienna_d( ..., h_start = 18, direction = 1, harmonise = TRUE, aesthetics = "fill" ) scale_colour_sienna_c( palette = "ocean", ..., reverse = FALSE, aesthetics = "colour" ) scale_fill_sienna_c( palette = "ocean", ..., reverse = FALSE, aesthetics = "fill" ) scale_colour_sienna_b( palette = "ocean", ..., reverse = FALSE, aesthetics = "colour" ) scale_fill_sienna_b( palette = "ocean", ..., reverse = FALSE, aesthetics = "fill" ) scale_colour_sienna_div( palette = "red_blue", ..., midpoint = 0, reverse = FALSE, aesthetics = "colour" ) scale_fill_sienna_div( palette = "red_blue", ..., midpoint = 0, reverse = FALSE, aesthetics = "fill" ) scale_color_sienna_d( ..., h_start = 18, direction = 1, harmonise = TRUE, aesthetics = "colour" ) scale_color_sienna_c( palette = "ocean", ..., reverse = FALSE, aesthetics = "colour" ) scale_color_sienna_b( palette = "ocean", ..., reverse = FALSE, aesthetics = "colour" ) scale_color_sienna_div( palette = "red_blue", ..., midpoint = 0, reverse = FALSE, aesthetics = "colour" )
... |
Passed to the underlying ggplot2 scale, such as |
h_start |
Starting hue in degrees. 18 is the palette's red; |
direction |
|
harmonise |
If |
aesthetics |
Aesthetics the scale applies to. |
palette |
A name from |
reverse |
If |
midpoint |
Data value mapped to the neutral centre. |
| ggplot2 default | sienna replacement |
scale_colour_discrete() |
scale_colour_sienna_d() |
scale_fill_continuous() |
scale_fill_sienna_c("ocean") |
scale_fill_binned() |
scale_fill_sienna_b("ocean") |
scale_fill_gradient2(midpoint = m) |
scale_fill_sienna_div("red_blue", midpoint = m)
|
A ggplot2 scale.
p <- ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, colour = class)) + ggplot2::geom_point() p + scale_colour_sienna_d() ggplot2::ggplot(ggplot2::faithfuld, ggplot2::aes(waiting, eruptions, fill = density)) + ggplot2::geom_raster() + scale_fill_sienna_c("teal", reverse = TRUE)p <- ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, colour = class)) + ggplot2::geom_point() p + scale_colour_sienna_d() ggplot2::ggplot(ggplot2::faithfuld, ggplot2::aes(waiting, eruptions, fill = density)) + ggplot2::geom_raster() + scale_fill_sienna_c("teal", reverse = TRUE)
The 24 sienna swatches. sienna_colours holds the original swatches for
logos, tables and one-off accents. sienna_colours_harmonised holds the
same hues with lightness and chroma pulled towards L 63, C 60; plots use
these. sienna_gradients, sienna_diverging and sienna_ramps hold the
9-stop sequential, diverging and single-hue palettes.
Named character vectors of hex codes (sienna_colours,
sienna_colours_harmonised) and named lists of 9 hex codes each
(sienna_gradients, sienna_diverging, sienna_ramps).
sienna_colours[["teal"]] sienna_colours_harmonised[["teal"]] names(sienna_gradients)sienna_colours[["teal"]] sienna_colours_harmonised[["teal"]] names(sienna_gradients)
sienna_gradient() returns the 9 stops of a sequential, diverging or
single-hue palette. sienna_ramp() returns the single-hue ramp of one
swatch. sienna_grad_pal() returns a palette function for values in
[0, 1], like scales::pal_gradient_n().
sienna_gradient(palette = "ocean", reverse = FALSE) sienna_ramp(colour) sienna_grad_pal(palette = "ocean", reverse = FALSE)sienna_gradient(palette = "ocean", reverse = FALSE) sienna_ramp(colour) sienna_grad_pal(palette = "ocean", reverse = FALSE)
palette |
A name from |
reverse |
If |
colour |
A name from |
Sequential gradients run light (low) to dark (high), the opposite of
ggplot2's default; reverse = TRUE matches ggplot2.
sienna_gradient() and sienna_ramp() return 9 hex codes;
sienna_grad_pal() returns a function.
sienna_gradient("ocean") sienna_ramp("purple") sienna_grad_pal("sunset")(seq(0, 1, length.out = 10))sienna_gradient("ocean") sienna_ramp("purple") sienna_grad_pal("sunset")(seq(0, 1, length.out = 10))
Keeps each colour's hue and pulls its lightness and chroma towards the
palette's level, keeping strength of the original deviation. This is the pull
that produced sienna_colours_harmonised. Needs the colorspace package.
sienna_harmonise(x, l = sienna_l, c = sienna_c, strength = sienna_harmony)sienna_harmonise(x, l = sienna_l, c = sienna_c, strength = sienna_harmony)
x |
Hex codes, optionally named. |
l, c
|
Target luminance and chroma. |
strength |
Share of the original deviation to keep: |
Hex codes with the names of x.
if (rlang::is_installed("colorspace")) sienna_harmonise(c(accent = "#FF0066"))if (rlang::is_installed("colorspace")) sienna_harmonise(c(accent = "#FF0066"))
Converts hue, chroma and luminance (polar CIELUV, as in grDevices::hcl())
to hex. Out-of-gamut colours have their chroma lowered in steps of 0.5
until they fit, instead of returning NA.
sienna_hcl(h, c, l)sienna_hcl(h, c, l)
h |
Hue in degrees. |
c |
Chroma. |
l |
Luminance, 0 to 100. |
A character vector of hex codes.
sienna_hcl(h = 200, c = 40, l = 70)sienna_hcl(h = 200, c = 40, l = 70)
Drop-in replacement for scales::pal_hue(). Spaces n target hues evenly
from h_start and snaps each to the nearest unused hue of the 13-hue sienna
wheel, so group k lands on roughly the same hue as in ggplot2's default.
Above 13 groups it falls back to evenly spaced hues at sienna lightness and
chroma.
sienna_pal(h_start = 18, direction = 1, harmonise = TRUE)sienna_pal(h_start = 18, direction = 1, harmonise = TRUE)
h_start |
Starting hue in degrees. 18 is the palette's red; |
direction |
|
harmonise |
If |
A function of n returning n hex codes.
sienna_pal()(5) sienna_pal(h_start = 145, direction = -1)(3)sienna_pal()(5) sienna_pal(h_start = 145, direction = -1)(3)
Sets ggplot2's ggplot2.discrete.*, ggplot2.continuous.* and
ggplot2.binned.* options, so every plot uses sienna without a scale_*()
call. reset_ggplot2_palette() switches back.
use_sienna_palette(h_start = 18, harmonise = TRUE, continuous = "ocean")use_sienna_palette(h_start = 18, harmonise = TRUE, continuous = "ocean")
h_start |
Starting hue in degrees. 18 is the palette's red; |
harmonise |
If |
continuous |
Palette for continuous and binned scales. |
The previous option values, invisibly.
use_sienna_palette(continuous = "ocean") ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, colour = class)) + ggplot2::geom_point() reset_ggplot2_palette()use_sienna_palette(continuous = "ocean") ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, colour = class)) + ggplot2::geom_point() reset_ggplot2_palette()
use_speedups() replaces functions inside clusterProfiler, DOSE, GOSemSim,
DESeq2 and sva so that
clusterProfiler::enrichGO(), clusterProfiler::simplify() and the
functions that call them, such as clusterProfiler::compareCluster(),
reuse earlier work and run faster:
use_speedups(packages = NULL) reset_speedups(packages = NULL)use_speedups(packages = NULL) reset_speedups(packages = NULL)
packages |
Names of the packages to speed up or restore, any of
|
the GO annotation for an OrgDb, ontology and key type is built once and kept on disk, so a new R session reads it in under a second instead of querying the OrgDb again;
the result of an enrichGO() call is kept, so the same gene list with the
same settings returns at once;
Wang semantic similarity between GO terms is computed for all term pairs
at once instead of pair by pair, which speeds up simplify() and
enrichplot::pairwise_termsim(method = "Wang"); results are unchanged;
the first GO annotation for an OrgDb is read with one SQL query per
ontology table instead of AnnotationDbi::mapIds(), and information
content in GOSemSim::godata() is summed over all terms at once; the
results are identical;
DESeq2::DESeq() computes the trimmed means behind Cook's distances
with one sort per matrix instead of one mean(trim = ) call per gene;
a gene's value is used only where it provably equals the original;
sva::ComBat_seq() moves counts to their adjusted quantiles in one
vectorised stats::pnbinom() and stats::qnbinom() call instead of one
call per gene and sample;
every KEGG table that enrichKEGG(), gseKEGG(), enrichMKEGG() and
gseMKEGG() download from the KEGG REST API is kept on disk per species,
KEGG database and key type, so switching species or key type, or starting
a new R session, no longer downloads it again. The cache is checked
against KEGG's release dates once an hour and downloads again when KEGG
has been updated; when KEGG is unreachable, the cached tables are used.
Called automatically when paradoxR is loaded. Packages loaded later are
sped up as they load. The cache is keyed by the clusterProfiler and GO.db
versions and the OrgDb database file, so updating any of them starts a
fresh cache. The simplify(), similarity, DESeq2 and sva replacements
apply only to the package versions they were checked against; other
versions keep their own code.
reset_speedups() restores the original functions, for example to compare
results against the original code. With packages, only the functions of
those packages are restored and the others stay fast. A restored package
stays original for the rest of the session, also if it is loaded later,
until use_speedups() is called for it. clear_cache() deletes the cache.
To keep the original functions from the start of a session, set
options(paradoxR.speedups = FALSE) (all packages),
options(paradoxR.deseq2 = FALSE) or options(paradoxR.sva = FALSE)
before loading paradoxR.
use_speedups() returns TRUE invisibly when at least one function
of packages is replaced, FALSE when none is, for example because the
packages are not loaded yet; they are then sped up when they load.
reset_speedups() returns TRUE invisibly when it restored at least one
function.
use_speedups() reset_speedups("DESeq2") use_speedups("DESeq2") reset_speedups() use_speedups()use_speedups() reset_speedups("DESeq2") use_speedups("DESeq2") reset_speedups() use_speedups()