library(ggchord)

library(ggchord)
library(dplyr)


p_linear_base <- ggchord(seq_data = seq_data_example) +
  geom_seq() +
  geom_seq_label() +
  coord_collinear()


report <- diagnose_ggchord(p_linear_base, width = 8, height = 5, device = "png")
report$checks


layout <- export_ggchord_layout(p_linear_base, include = "seq")
head(unique(layout$seq[c("layer_id", "component", "source_row")]), 4)


library(ggchord)
library(dplyr)
scale_seqs <- seq_data_example[c("accver", "length")]
scale_links <- ribbon_data_example
scale_ids <- scale_seqs$accver
scale_colours <- setNames(c("#E64B35", "#233E4A", "#269B82", "#D59B17"), scale_ids)
scale_opacity <- setNames(c(0.35, 0.55, 0.75, 0.95), scale_ids)
scale_lines <- setNames(c("solid", "dashed", "dotted", "dotdash"), scale_ids)
scale_base <- ggchord(scale_seqs, ribbon_data = scale_links) + geom_seq() + coord_chord()
scale_numeric <- scale_base + geom_link_ribbon(aes(ribbon_fill = pident))


diagnostics <- diagnose_ggchord(scale_base, width = 9, height = 7, units = "in")
layout_tables <- export_ggchord_layout(scale_base, include = "seq", original_data = TRUE)
full_reference <- get_chord_layout(scale_base)
order_choice <- optimize_ggchord_layout(scale_seqs, scale_links,
  optimize = c("order", "orientation"), weight = "length")
list(measurement = diagnostics$measurement, order = order_choice$seq_order)

