Complete canonical API text; task articles explain the workflows. Tutorials
Site guide · find your task
Setup and learning paths
HomeInstall and prepare the environmentChoose your learning moduleModule I · Chord
1.1 Tables and field meanings1.2 Produce and import comparisons1.3 Build the layers step by step1.4 Direction, curvature and clearance1.5 Filter and summarize links1.6 Full source-file workflow1.7 Complete chord showcaseModule II · Collinear
2.1 Reuse chord input tables2.2 Switch coordinates and add layers2.3 Routes, clearance and the ruler2.4 Compare CDS neighbourhoods2.5 Focus, anchors and segments2.6 Complete collinear showcaseModule III · Plasmid
3.1 DNA, annotations and 13 references3.2 From a circle to annotation layers3.3 Features, primers and restriction3.4 Thirteen plasmid references3.5 Complete plasmid casesConsult as needed · Data and layers
Prepare tables and coordinatesImport and convert dataImport nucleotide and protein alignmentsProject protein intervals to genomic coordinatesFeatures, stacking and genomic decorationLabels and local placementQuantitative tracksMappings, scales, guides and themesSet values by sequence and strandCommon adjustments and grammarExport, preview and diagnosticsLearning map and reference
Articles and complete workflowsFunction referenceReproducible galleryFrequently asked questionsMigrate to the candidate APITerminology and design sourcesDevelopment status and changes
Draw explicit quantitative tracks along sequence backbones
Source:R/geom-track.R
geom_track_tile.RdTile 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.
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