library(ggchord)

library(ggchord)
library(dplyr)


library(ggchord)
library(dplyr)
finish_dna <- plasmid_example_pUC19
finish_seq <- finish_dna[c("accver", "length")]
finish_features <- head(find_common_features(finish_dna), 6)
finish_circle <- ggchord(finish_seq) + geom_seq() + coord_circular()
finish_labels <- finish_features |>
  mutate(anno = paste0(anno, " [", start, "-", end, " bp]"))
finish_feature_base <- finish_circle + geom_feature(data = finish_labels)


p_comparebonedouble <- ggchord(finish_seq) + geom_seq(seq_style = "double") + coord_circular()
view_ggchord(p_comparebonedouble, width = 9, height = 8, units = "in")


p_comparebonesingle <- ggchord(finish_seq) + geom_seq(seq_style = "single") + coord_circular()
view_ggchord(p_comparebonesingle, width = 9, height = 8, units = "in")


p_comparebonegap <- ggchord(finish_seq) + geom_seq(seq_style = "double", seq_backbone_gap = 0.05) + coord_circular()
view_ggchord(p_comparebonegap, width = 9, height = 8, units = "in")


p_compareboneband <- ggchord(finish_seq) + geom_seq(seq_style = "band") + coord_circular()
view_ggchord(p_compareboneband, width = 9, height = 8, units = "in")


p_comparebandwidth <- ggchord(finish_seq) +
  geom_seq(seq_style = "band", seq_backbone_width = 0.07) + coord_circular()
view_ggchord(p_comparebandwidth, width = 9, height = 8, units = "in")


p_comparecirclecounter <- ggchord(finish_seq) + geom_seq(seq_style = "double") +
  coord_circular(direction = "counterclockwise")
view_ggchord(p_comparecirclecounter, width = 9, height = 8, units = "in")


p_comparecirclegap <- ggchord(finish_seq) + geom_seq(seq_style = "double") +
  coord_circular(gap = 25)
view_ggchord(p_comparecirclegap, width = 9, height = 8, units = "in")


p_comparecenter <- finish_circle + geom_seq_center_label()
view_ggchord(p_comparecenter, width = 9, height = 8, units = "in")


p_comparecenternolength <- finish_circle + geom_seq_center_label(length = FALSE)
view_ggchord(p_comparecenternolength, width = 9, height = 8, units = "in")


p_comparecenterstyle <- finish_circle +
  geom_seq_center_label(name_style = list(size = 6))
view_ggchord(p_comparecenterstyle, width = 9, height = 8, units = "in")


plasmid <- plasmid_example_pUC19
p_first_circle <- ggchord(seq_data = plasmid) +
  geom_seq() +
  geom_seq_center_label() +
  coord_circular()


features <- find_common_features(plasmid)
origins <- subset(features, type == "rep_origin")
p_first_features <- p_first_circle +
  geom_feature_plasmid(data = origins)


p_circle_single <- ggchord(seq_data = plasmid) +
  geom_seq(seq_style = "single") +
  geom_seq_center_label() +
  coord_circular()
view_ggchord(p_circle_single, width = 6, height = 6, units = "in")


features <- find_common_features(plasmid)
origins <- subset(features, type == "rep_origin")
p_first_features <- p_first_circle +
  geom_feature_plasmid(data = origins)

p_circle_rotated <- p_first_features + coord_circular(rotation = 90)
view_ggchord(p_circle_rotated, width = 6, height = 6, units = "in")

