library(ggchord)

library(ggchord)
library(dplyr)


p_chord_backbone <- ggchord(seq_data = seq_data_example) +
  geom_seq() +
  geom_seq_label() +
  coord_chord()


chord_links <- head(ribbon_data_example, 1)


p_chord_ribbon <- p_chord_backbone +
  geom_link_ribbon(data = chord_links)


chord_genes_example <- subset(gene_data_example, accver == "OQ646790.1" & start == 43765)
chord_genes_example$strand <- chord_genes_example$source_strand


p_chord_feature <- p_chord_ribbon +
  geom_gene(data = chord_genes_example)


p_chord_sequence_labels <- ggchord(seq_data = seq_data_example) +
  geom_seq() +
  geom_seq_label(seq_label_radius = 0.7, seq_label_orientation = "horizontal") +
  coord_chord()
view_ggchord(p_chord_sequence_labels, width = 7, height = 7, units = "in")


chord_genes_example <- subset(gene_data_example, accver == "OQ646790.1" & start == 43765)
chord_genes_example$strand <- chord_genes_example$source_strand

p_chord_gene_labels <- p_chord_feature +
  geom_gene_label(data = chord_genes_example, label_radial_offset = 0.10)
view_ggchord(p_chord_gene_labels, width = 7, height = 7, units = "in")


library(ggchord)
library(dplyr)
finish_seqs <- seq_data_example[c("accver", "length")]
finish_chord <- ggchord(finish_seqs) + geom_seq() + coord_chord(rotation = 0)
finish_region <- ribbon_data_example |>
  slice_head(n = 1) |>
  transmute(accver = qaccver, start = pmin(qstart, qend), end = pmax(qstart, qend))


p_compareseqlabelarc <- finish_chord + geom_seq_label(seq_label_orientation = "arc")
view_ggchord(p_compareseqlabelarc, width = 9, height = 7, units = "in")


p_compareseqlabelhorizontal <- finish_chord + geom_seq_label(seq_label_orientation = "horizontal")
view_ggchord(p_compareseqlabelhorizontal, width = 9, height = 7, units = "in")


p_compareseqlabelrotation <- finish_chord + geom_seq_label(seq_label_orientation = "arc", seq_label_rotation = 30)
view_ggchord(p_compareseqlabelrotation, width = 9, height = 7, units = "in")

