Skip to contents
0.16.6 documentation

Complete canonical API text; task articles explain the workflows. Tutorials

Site guide · find your task

Adds a free-standing reference bar in the empty space outside the sequence envelope. Its length uses the same bp-to-x conversion as every backbone in coord_collinear(), including independent windows on shared display rows. Display gaps are never interpreted as genomic length. Local reversals and original-source axis labels do not change the bar's bp scale. Chord and circular coordinates have local sequence axes instead and are rejected.

Usage

Code
geom_seq_scale(
  mapping = NULL,
  data = NULL,
  length = NULL,
  label = NULL,
  location = c("bottomleft", "bottomright", "topleft", "topright"),
  offset = grid::unit(c(2, 6), "mm"),
  tick_height = grid::unit(1.5, "mm"),
  label_gap = grid::unit(1.5, "mm"),
  linewidth = 0.4,
  colour = "#3D4348",
  size = 3,
  position = "identity",
  show.legend = FALSE,
  inherit.aes = FALSE,
  ...
)

Arguments

mapping, data

Standard ggplot2 layer inputs. Optional scale_length maps one positive integer bp length per bar; label supplies its text. Multiple bars require explicit x and y layout positions in data (or their role mappings), to avoid accidental overprinting.

length

Optional fixed positive integer length in bp. Cannot be combined with a scale_length mapping. NULL uses input lengths or an automatic reference length.

label

Optional fixed character label, or a function receiving the chosen bp lengths. NULL uses input labels or formatted "... bp" text.

location

Corner of the sequence envelope used for automatic placement.

offset

Two non-negative distances, horizontal then vertical. Absolute grid units are supported; plain numeric values are layout-unit distances.

tick_height, label_gap

Non-negative absolute grid units or layout-unit numbers for the end ticks and space between the bar and caption. Physical conversion uses the current render context when available; device-free builds retain an explicitly estimated measurement status.

linewidth, colour, size

Fixed line colour/width and text size. Text size follows ordinary ggplot2 millimetres. These may also use normal mappings and scales when not supplied as fixed arguments.

position, show.legend, inherit.aes

Standard ggplot2 layer arguments.

...

Additional fixed aesthetics passed to ggplot2::layer().

Value

One independent ggplot2 layer. Exported axis geometry retains the bp length, input row and measurement status for each bar.

Details

The bar does not claim to span one source interval. An explicit length can therefore exceed a single window and still be a valid distance reference in the shared linear metric. With no length, a small whole-number 1/2/5 reference is chosen from displayed window lengths. No source coordinates are modified and no missing genomic region is manufactured.

To change ticks and labels on sequence axes instead, use scale_seq_position_continuous(). A position scale configures existing axes; this geom adds an independent distance reference.

Examples

Code
library(dplyr)
data(seq_data_example)
seqs <- seq_data_example |>
  select(accver, length)
ggchord(seq_data = seqs) +
  geom_seq() +
  coord_collinear() +
  geom_seq_scale(length = 10000)