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 changesVisualize multi-sequence alignments, a single circular sequence or linear
collinearity using ggplot2's layered grammar. The constructor supplies data
and validation. Add geometry with geom_*(), select a global view with
coord_chord(), coord_circular() or coord_collinear(), and use
mappings/scales for data-driven styles and themes for non-data appearance.
The layout is computed lazily when the plot is built (e.g. via print(),
ggsave(), or ggplot_build()).
Usage
Code
ggchord(
seq_data,
ribbon_data = NULL,
gene_data = NULL,
debug = FALSE,
validate = c("warn", "error", "none"),
...
)Arguments
- seq_data
data.frame/tibble with accver and length, or a
GRanges,SeqinfoorGInteractionsobject with known full sequence lengths, or a named nucleotide BiostringsXStringSet. Unnamed sequence objects must first useas_ggchord_seq()with explicitids. Optional S4 inputs useas_ggchord_seq(). When present,sequence_unitmust be"bp"; amino-acid intervals require an explicit CDS projection, and arbitrary character widths are not bp lengths.- ribbon_data
Optional alignment table with qaccver, saccver, qstart, qend, sstart and send. length and pident are optional unless requested by a mapping, filter or statistic. A
GInteractionsobject usesas_ggchord_link()without inventing identity or alignment length.- gene_data
Optional table with accver, start, end and strand. Annotation (anno) may be omitted. Directional
GRangesare accepted; usegeom_feature(data = ...)for unknown-strand intervals.- debug
Logical. Whether to output debug information, default FALSE
- validate
Character, default
"warn". How to run the structured input-data validation (seevalidate_ggchord_data):"warn"emits a single summary warning when the data has problems and caches the full report on the plot object (p$ggchord$validation);"error"stops on severe problems;"none"skips the diagnostic validation (the cheap structural checks that prevent crashes are still performed).- ...
Reserved for clear migration errors from removed constructor arguments. Use
labs(),coord_chord()andtheme()for presentation.
Examples
Code
library(dplyr)
library(ggchord)
data(seq_data_example)
data(ribbon_data_example)
data(gene_data_example)
seqs <- seq_data_example |>
select(accver, length)
links <- ribbon_data_example |>
select(qaccver, saccver, qstart, qend, sstart, send)
genes <- gene_data_example |>
transmute(accver, start, end, strand = source_strand)
p <- ggchord(
seq_data = seqs,
ribbon_data = links,
gene_data = genes
) +
geom_seq() +
geom_link_ribbon() +
geom_gene()
print(p)