Skip to contents
0.16.6 documentation

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

Site guide · find your task

Tile and bar layers require accver, start, end; lines require accver and pos. Map track_value for numeric height and track_fill or track_colour for visual mapping. Values are never inferred from column names. group separates line series; positions must increase strictly within each sequence/series. NA height breaks lines or omits bars, never becomes zero. Inf is rejected. Tiles may overlap in input drawing order; no averaging, interpolation or implicit aggregation is performed.

Usage

Code
geom_track_tile(
  mapping = NULL,
  data = NULL,
  position,
  fill = "#86AFB9",
  colour = NA,
  alpha = 1,
  linewidth = 0.25,
  linetype = 1,
  bounds = c("error", "clip"),
  show.legend = NA,
  inherit.aes = FALSE,
  ...
)

geom_track_line(
  mapping = NULL,
  data = NULL,
  position,
  colour = "#387D88",
  alpha = 1,
  linewidth = 0.4,
  linetype = 1,
  closed = FALSE,
  bounds = c("error", "clip"),
  show.legend = NA,
  inherit.aes = FALSE,
  ...
)

geom_track_bar(
  mapping = NULL,
  data = NULL,
  position,
  baseline = 0,
  fill = "#86AFB9",
  colour = NA,
  alpha = 1,
  linewidth = 0.25,
  linetype = 1,
  bounds = c("error", "clip"),
  show.legend = NA,
  inherit.aes = FALSE,
  ...
)

Arguments

mapping, data

Standard ggplot2 mapping and layer input.

position

A position_track() declaration. Every layer requires one.

fill, colour, alpha, linewidth, linetype

Fixed styles; fill and colour mappings use the dedicated track roles and scoped scales.

bounds

"error" (default) or "clip" for genomic coordinates. Clipping is reported and never changes source values.

show.legend, inherit.aes

Standard layer arguments.

...

Extra geom parameters.

closed

Explicitly close a complete circular line series.

baseline

Explicit numeric bar baseline, default zero. It is included in scale training and must remain representable under limits/transform.

Value

A ggplot2 layer with independent input and a shared named band.

Details

All coordinates are window-local, one-based inclusive. Interval bins occupy their full end - start + 1 bases, including one-base bins; line samples use the specified positions without binning.

Use focus_ggchord_track() for source windows. Lines never connect distinct windows, even when they share a display row. Circular lines close only with explicit closed = TRUE; missing endpoints are not joined across NA.

Examples

Code
library(ggchord)
library(dplyr)
data(plasmid_example_pUC19)
track_seq <- plasmid_example_pUC19 |>
  select(accver, length)
starts <- seq.int(1L, track_seq$length, by = 100L)
gc_fraction <- function(sequence) {
  bases <- strsplit(sequence, "")[[1]]
  mean(bases %in% c("G", "C"))
}
bins <- tibble(
  accver = track_seq$accver,
  start = starts,
  end = pmin(starts + 99L, track_seq$length)
) |>
  rowwise() |>
  mutate(gc = gc_fraction(substr(plasmid_example_pUC19$sequence, start, end))) |>
  ungroup()
doc_theme <- theme_ggchord_publication(
  axis.text = element_text(size = 9), axis.text.check.overlap = TRUE
) +
  theme(legend.position = "bottom")
p_tracks <- ggchord(seq_data = track_seq) +
  geom_seq() +
  geom_seq_center_label() +
  geom_track_bar(aes(track_value = gc, track_fill = gc),
    data = bins,
    position = position_track("gc", width = unit(6, "mm"))
  ) +
  scale_track_value_continuous("gc", limits = c(0, 1), unit = "GC fraction") +
  scale_track_fill_gradientn("gc", colours = c("#EDF1EA", "#8AAE9C", "#345F58")) +
  coord_circular() +
  doc_theme