format_sequence_motifs: Format Sequence Motif Summaries

View source: R/sequence-motifs.R

format_sequence_motifsR Documentation

Format Sequence Motif Summaries

Description

Produces a stable, report-ready table from motif extraction, summary, or filtered-motif output.

Usage

format_sequence_motifs(
  x,
  digits = 3L,
  prevalence = c("proportion", "percent"),
  include_rank = TRUE,
  rank_by = c("sequence_prevalence", "n_occurrences", "n_sequences"),
  ties = c("min", "first"),
  include_ids = TRUE
)

Arguments

x

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

digits

Whole number from 0 to 15 controlling numeric rounding.

prevalence

Character value specifying whether prevalence and occurrence share are shown as "proportion"s or "percent"ages.

include_rank

Logical value indicating whether to add a rank column.

rank_by

Metric used to order and rank motifs: one of "sequence_prevalence", "n_occurrences", or "n_sequences".

ties

Character value specifying "min" shared ranks or deterministic "first" ranks.

include_ids

Logical value indicating whether motif_id and motif_key should be included in the formatted table.

Details

Formatting changes display precision and units only. It does not change the underlying motif counts or introduce substantive interpretation.

Value

A named list containing table, validation metadata, and formatting settings. The table contains only structural motif measurements.

Examples

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

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

formatted <- format_sequence_motifs(
  extracted,
  prevalence = "percent",
  digits = 1
)

formatted$table


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