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 changes
Clean ggchord input data with explicit, report-driven policies
Source:R/clean.R
clean_ggchord_data.RdApplies a conservative, predictable set of cleaning policies to the three
ggchord tables and returns the cleaned copies plus a full report. The
original data frames are never modified. Nothing is dropped silently: every
change (including every dropped row) is recorded in report with the
original row number, the reason, the original value(s) and the new value(s).
Its historical sorting default differs deliberately from preparation's
direction-preserving default. Use reversed_interval = "keep" for
directional links and circular-origin features; sorting endpoints loses
information that a later workflow cannot reconstruct.
Usage
Code
clean_ggchord_data(
seq_data,
ribbon_data = NULL,
gene_data = NULL,
unknown_id = c("drop", "error", "keep"),
out_of_range = c("clip", "drop", "error", "keep"),
reversed_interval = c("sort", "drop", "error", "keep"),
invalid_pident = c("clip", "drop", "error", "keep"),
empty_annotation = c("keep", "drop", "replace"),
replacement_annotation = "unannotated"
)Arguments
- seq_data
data.frame/tibble, required. Must contain
accverandlength; used as the coordinate reference for clipping. Reference IDs must always be non-missing, non-empty and unique, regardless ofunknown_id.- ribbon_data
data.frame/tibble or
NULL, optional. Alignment results. Other input types are rejected rather than treated as absent.- gene_data
data.frame/tibble or
NULL, optional. Gene annotation data. Other input types are rejected rather than treated as absent.- unknown_id
Character, default
"drop". Policy for rows whose sequence ID inribbon_dataorgene_datais missing, empty or unknown:"drop"removes them,"error"stops with a message,"keep"leaves them unchanged. A kept row without a reference sequence is reported, but its coordinates and annotations are not cleaned and it is not guaranteed to be drawable. IDs are never guessed or replaced. Other structural checks, including finite numeric coordinates and valid gene strands, still apply.- out_of_range
Character, default
"clip". Policy for coordinates outside[1, sequence length]:"clip"clamps them,"drop"removes the row,"error"stops,"keep"leaves them unchanged. Coordinates are one-based inclusive, sostart == endis a valid single-base interval and is retained. With"clip", intervals wholly outside their sequence are removed and reported; partially overlapping intervals retain their intersection, even a single base.- reversed_interval
Character, default
"sort". Policy for intervals withstart > end:"sort"swaps the endpoints so the feature draws stably (the original direction is recorded in the report),"drop"removes the row,"error"stops,"keep"leaves them unchanged.- invalid_pident
Character, default
"clip". Policy forpidentoutside[0, 100]:"clip"clamps them,"drop"removes the row,"error"stops,"keep"leaves them unchanged.- empty_annotation
Character, default
"keep". Policy for missing/emptyannoin gene data:"replace"fills them withreplacement_annotation,"drop"removes the row,"keep"leaves them unchanged.- replacement_annotation
Character, default
"unannotated". Replacement annotation used whenempty_annotation = "replace".
Value
A list with four components: seq_data, ribbon_data,
gene_data (cleaned copies) and report (a data.frame with
columns table, row (original row number), column,
reason, original_value, new_value and
action).
Examples
Code
library(dplyr)
data(seq_data_example)
seqs <- seq_data_example |>
select(accver, length)
data(ribbon_data_example)
links <- ribbon_data_example |>
select(qaccver, saccver, qstart, qend, sstart, send, pident, length)
# Deliberate diagnostic error in a copy; source observations remain unchanged.
problem <- links |>
slice_head(n = 2) |>
mutate(qaccver = replace(qaccver, 2, "absent"))
cleaned <- clean_ggchord_data(seqs, problem, unknown_id = "drop")
cleaned$report