Skip to contents
0.16.6 documentation

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

Site guide · find your task

Draws the gene annotation labels on a chord diagram. This layer is independent from geom_gene(): add it after geom_gene() to annotate the gene arrows with their texts.

Usage

Code
geom_gene_label(
  mapping = NULL,
  data = NULL,
  label_orientation = "horizontal",
  label_side = "outside",
  label_overlap = "hide",
  label_rotation = NULL,
  label_radial_offset = 0.04,
  label_circum_offset = NULL,
  label_circum_limit = NULL,
  label_wrap = NULL,
  position = "identity",
  show.legend = FALSE,
  inherit.aes = FALSE,
  ...
)

Arguments

mapping

Default NULL (uses pre-computed data)

data

Default NULL (retrieved automatically from the layout)

label_orientation

Character, default "horizontal". Text orientation relative to each sequence path: "radial", "tangent", or "horizontal".

label_side

Character, default "outside". Place labels outside the chord, use the strand-based "auto" side, or force "inside" placement.

label_overlap

Character, default "hide". Fixed-label collision policy: omit later conflicting labels ("hide"), apply the legacy gentle adjustment ("nudge"), or keep all requested positions ("allow"). Input row order therefore provides a simple way to prioritize labels in "hide" mode.

label_rotation

Optional numeric/vector/list. Label rotation angle, default 0

label_radial_offset

Optional numeric/vector/list. Radial offset of labels, default 0.04

label_circum_offset

Optional numeric/vector/list. Circumferential offset of labels, default 0

label_circum_limit

Optional logical/vector/list. Whether to limit circumferential offset, default TRUE

label_wrap

Numeric or NULL, default NULL. When set, long gene annotations are wrapped at this many characters (e.g. 15), which makes the labels narrower and less prone to overlap.

position

Position adjustment. Supply the same position_feature_stack() used by a gene/feature layer when labels are drawn from separate data or without a geometry layer. In coord_collinear(), labels without an explicit Position share a matching geometry layer's lanes; explicit label Positions do not move the geometry layer. Unique feature_id columns allow label subsets and reordered labels when their accession, interval and strand agree with the geometry input. Multiple matching geometry layers require an explicit label Position or unambiguous feature IDs.

show.legend, inherit.aes

Standard ggplot2 layer arguments.

...

Additional arguments passed to geom_text()

Value

A ggplot2 layer. To let the labels avoid each other and the genes (with leader lines), use geom_gene_label_repel() instead.

Details

This is the deterministic, fixed-position label layer. By default labels sit outside their sequence and labels that would collide are omitted in input-row order. Use label_overlap = "nudge" to retain the legacy gentle adjustment, or "allow" to draw every label at its requested position. For automatic arrangement with leader lines, use geom_gene_label_repel() instead.

Examples

Code
library(dplyr)
data(seq_data_example)
seqs <- seq_data_example |>
  select(accver, length)
data(gene_data_example)
genes <- gene_data_example |>
  transmute(accver, start, end, strand = source_strand, anno)
ggchord(seq_data = seqs, gene_data = genes) +
  geom_seq() +
  geom_gene() +
  geom_gene_label()