plot_sequence_motifs: Plot Sequence Motif Summaries

View source: R/sequence-motif-visualisation.R

plot_sequence_motifsR Documentation

Plot Sequence Motif Summaries

Description

Draws a dependency-free base-R bar chart of structural motif measurements.

Usage

plot_sequence_motifs(
  x,
  metric = c("sequence_prevalence", "n_occurrences", "n_sequences", "occurrence_share"),
  top_n = 20L,
  motif_lengths = NULL,
  ties = c("include", "first"),
  horizontal = TRUE
)

Arguments

x

A motif extraction, summary, or filtered-motif object.

metric

Structural metric to plot: "sequence_prevalence", "n_occurrences", "n_sequences", or "occurrence_share".

top_n

Positive whole number giving the requested number of motifs.

motif_lengths

Optional vector of positive whole-number motif lengths to retain.

ties

Top-n boundary policy. "include" retains all motifs tied on the selected metric; "first" retains exactly top_n after deterministic secondary sorting.

horizontal

Logical value indicating whether bars should be horizontal.

Details

The plot is descriptive. It does not perform inferential testing or assign substantive meaning to motif frequency or prevalence. Empty inputs produce an informative blank plot and return an empty table.

Value

Invisibly returns the exact motif table used for plotting, including plot_rank, plot_value, plot_label, and bar_midpoint.

Examples

sequences <- data.frame(
  id = c(rep("s1", 5L), rep("s2", 4L)),
  position = c(1:5, 1:4),
  state = c("A", "B", "A", "B", "C", "A", "B", "C", "B")
)

extracted <- extract_sequence_ngrams(
  sequences,
  sequence_id_col = "id",
  order_col = "position",
  state_col = "state"
)

plot_sequence_motifs(
  extracted,
  metric = "sequence_prevalence",
  top_n = 10
)


gp3sequences documentation built on Aug. 23, 2026, 5:10 p.m.