Skip to contents

A theme sets the default look of every part of a chart: fonts, text and line colours, the background, the gene colours and the options of each component. Options set with the other GC_ functions (e.g. GC_labels(fontSize = )) always take precedence over the theme, whatever the order of the calls.

Usage

GC_theme(
  GC_chart,
  theme = NULL,
  textScale = NULL,
  fontFamily = NULL,
  textColor = NULL,
  lineColor = NULL,
  background = NULL,
  palette = NULL,
  pattern = NULL,
  ...
)

Arguments

GC_chart

The GC chart object to be modified.

theme

The theme to start from: the name of a built-in theme ("default", "classic", "dark", "vintage", "infographic", "publication" or "bw", see geneviewer_theme()) or a list of theme settings. "bw" is black and white: genes, exons and legend markers are filled with a pattern per group. Default is NULL: change the current theme of the chart.

textScale

Text size, as a factor of the default font sizes: e.g. 1.5 makes all text one and a half times as large. Font sizes set in the theme are scaled too; those set with the other GC_ functions are not. The title and its default height grow with the text.

fontFamily

Font family of all text, e.g. "Arial".

textColor

Colour of all text.

lineColor

Colour of the sequence line, the axis, the coordinates and the scale bar.

background

Background colour of the chart, also the fill of the UTRs of transcripts.

palette

Gene colours: the name of a d3 colour scheme (e.g. "schemeSet2") or a geneviewer palette (e.g. "okabeIto", see geneviewer_palette()), or a vector of colours, used in the order of the groups. Colours set with GC_color() or the colorScheme or customColors of GC_genes() take precedence.

pattern

Patterns of the genes, exons and legend markers: a list with the arguments of GC_pattern() (patterns, color, background, size, strokeWidth), e.g. list(patterns = c("dots", "grid")). Set with the theme, they are merged with the patterns of the current theme; GC_pattern() takes precedence. FALSE removes the patterns of the theme.

...

Options per component, as lists named after the component (see Details), e.g. labels = list(fontSize = "10px").

Value

The GC chart object with the theme.

Details

Call GC_theme() with a theme to start from that theme, or without one to change the current theme. The global settings (fontFamily, textColor, lineColor, background, palette, pattern) are applied to all components; options set for a component, in the theme or in ..., take precedence over them. textScale scales all text of the chart: the default font sizes and those set in the theme, not those set with the other GC_ functions.

The options of each component are those of its GC_ function, by their argument name (e.g. normal_color) or their name in the browser (e.g. normalColor). Components and their functions:

ComponentFunctionExample
chartGC_chart()list(style = list(padding = "10px"))
gridGC_grid()list(margin = list(left = "80px"))
clusterGC_cluster()list(separate_strands = TRUE)
titleGC_title()list(height = 40, titleFont = list(fontSize = "18px"))
clusterTitleGC_clusterTitle()list(titleFont = list(fill = "grey"))
clusterFooterGC_clusterFooter()list(align = "center")
clusterLabelGC_clusterLabel()list(width = "120px", fontWeight = "normal")
sequenceGC_sequence()list(sequenceStyle = list(stroke = "black"))
genesGC_genes()list(marker = "rbox", stroke = "none")
transcriptGC_transcript()list(styleExons = list(stroke = "black"))
labelsGC_labels()list(fontSize = "10px", fontStyle = "normal")
coordinatesGC_coordinates()list(textStyle = list(fontSize = "8px"))
scaleGC_scale()list(axis_position = "top", ticksCount = 5)
scaleBarGC_scaleBar()list(labelStyle = list(fontSize = "12px"))
legendGC_legend()list(position = "top")
linksGC_links()list(normal_color = "grey", curve = FALSE)
tooltipGC_tooltip()list(backgroundColor = "black", color = "white")
trackMouseGC_trackMouse()list(cursor = "cell")
annotationsGC_annotation()list(text = list(style = list(fontSize = "14px")))

annotations takes a list per annotation type: text, line, arrow, textMarker, symbol, rectangle, promoter, terminator and arc.

A theme only sets how things look: it does not add components to the chart (e.g. a scale needs GC_scale()) or change the data.

The "publication" theme follows common journal figure guidelines: Arial or Helvetica, 7 pt text when the chart is used at its final print size, black text and keylines, visible axis ticks, no patterns or shadows, and the colour-blind-safe Wong palette. Gene labels are italic, as gene symbols are in journals; use GC_labels(fontStyle = "normal") for protein names or other labels. Journals often also require axis labels with units in parentheses and bold panel labels; these are content-specific and must be added by the author. Export as SVG to retain editable vector text and artwork, then check that fonts are embedded when converting to the PDF or EPS supplied to the journal.

See also

geneviewer_theme() to see the settings of a built-in theme.

Examples

genes_data <- data.frame(
  start = c(10, 90, 130, 170, 210),
  end = c(40, 120, 160, 200, 240),
  name = c('Gene 1', 'Gene 3', 'Gene 4', 'Gene 5', 'Gene 6'),
  group = c('A', 'B', 'B', 'A', 'C'),
  cluster = c(1, 1, 2, 2, 2)
)

chart <- GC_chart(genes_data, cluster = "cluster", group = "group",
                  height = "200px") %>%
  GC_labels("name") %>%
  GC_clusterLabel()

# A built-in theme
chart %>% GC_theme("dark")
# A built-in theme with other fonts and colours chart %>% GC_theme("classic", fontFamily = "Georgia", palette = c("#1b9e77", "#d95f02", "#7570b3"))
# Black and white with patterns, and other patterns chart %>% GC_theme("bw")
chart %>% GC_theme("bw", pattern = list(patterns = c("dots", "crosshatch", "none")))
# Larger text, e.g. for a slide or a figure that is printed small chart %>% GC_theme("classic", textScale = 1.4)
# Change one component; options of the GC_ functions still take precedence chart %>% GC_theme("classic", labels = list(fontSize = "14px", fill = "grey")) %>% GC_labels("name", fontSize = "10px")