Skip to contents
0.16.6 documentation

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

Site guide · find your task

Visualize 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, Seqinfo or GInteractions object with known full sequence lengths, or a named nucleotide Biostrings XStringSet. Unnamed sequence objects must first use as_ggchord_seq() with explicit ids. Optional S4 inputs use as_ggchord_seq(). When present, sequence_unit must 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 GInteractions object uses as_ggchord_link() without inventing identity or alignment length.

gene_data

Optional table with accver, start, end and strand. Annotation (anno) may be omitted. Directional GRanges are accepted; use geom_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 (see validate_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() and theme() for presentation.

Value

A ggchord object (inherits from ggplot) to which geom_* layers can be added with +

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)