Chapters and reference
Module I · Multi-sequence relationships · Section 8 of 16
1.7 Repeated displays and instance selection
On this page
1 Preparation
Data preparation and settings (expand)
R · Example code
library(dplyr)
foundation_source <- ribbon_data_example |>
mutate(source_hsp_id = paste0("bundled:", row_number()))
foundation_pair <- foundation_source |>
slice_head(n = 1) |>
select(qaccver, saccver)
foundation_ids <- c(foundation_pair$qaccver, foundation_pair$saccver)
foundation_seqs <- seq_data_example |>
filter(accver %in% foundation_ids) |>
select(accver, length)
foundation_hsp <- foundation_source |>
filter(qaccver %in% foundation_ids, saccver %in% foundation_ids,
qaccver != saccver)
foundation_features <- gene_data_example |>
filter(accver %in% foundation_ids) |>
transmute(accver, start, end, strand = source_strand, anno)2 Named A–B–A routes
The three displayed rows refer to two biological sequences. seq_order values identify sources; names identify instances. Filter each layer’s original HSPs before routing. between accepts two names or two declaration-order indices. Ambiguous routes fail. The two subsets below are disjoint and preserve every HSP.
R · Example code
foundation_order <- setNames(
c(foundation_ids[1], foundation_ids[2], foundation_ids[1]),
c("A_high", "B", "A_low")
)
foundation_split <- ceiling(nrow(foundation_hsp) / 2)
foundation_plot <- ggchord(foundation_seqs, feature_data = foundation_features) +
geom_seq(seq_order = foundation_order) +
geom_seq_label() +
geom_feature(shape = "arrow") +
geom_link_ribbon(
data = foundation_hsp |> slice_head(n = foundation_split),
between = c("A_high", "B")
) +
geom_link_ribbon(
data = foundation_hsp |> slice_tail(n = nrow(foundation_hsp) - foundation_split),
between = c(2, 3)
)
p_foundationvertical <- foundation_plot + coord_collinear(seq_axis = "vertical")
view_ggchord(p_foundationvertical, width = 9, height = 8, units = "in")
The same foundation_plot can use coord_chord() or coord_collinear(). Vertical Collinear changes the global view while keeping source strands and positions. Positive local normal points left. Explicit text styles retain priority. map_ggchord_position() accepts an instance name; its inverse input is final y in vertical views.
export_ggchord_layout() supplies display_instances, instance_routing and instance_omissions. Explicit source_hsp_id detects repeated display across layers; use allow_repeated=TRUE only when that repetition is intended. Without an ID, identity stays layer-local; equal row values do not establish identity.