thackl / gggenomes

A grammar of graphics for comparative genomics
https://thackl.github.io/gggenomes/
Other
606 stars 65 forks source link

Sublinks between CDS with the same ID #113

Closed tardl closed 2 years ago

tardl commented 2 years ago

Hello, Thanks a lot again for your help and this nice tool. In a pure graphical purpose, I was wondering if there'll be a way to draw sublinks that'll link CDS that are carrying the same name. I already run blastn and minimap2 in order to draw identity links but I'm ending with to many of them and I just want to make clear connections for readers. I guess that again the files I'm exporting from geneious are not conventional.

Sorry if my question is trivial, I'm an R beginner. archive.zip

thackl commented 2 years ago

Have a look at add_clusters(). It takes a data.frame of cluster_id,feat_id used for drawing sublinks. You can create such a data.frame manually to connect whatever CDS you want. And in your specific case, you can easily construct it from the gene table using the name of CDS as cluster ids.

library(tidyverse)
library(gggenomes)

g0 <- read_feats("3L_for_graph.gff")
s0 <- read_seqs("3L_for_graph.fasta")

# raw plot
p0 <- gggenomes(g0, s0) + geom_seq() + geom_gene() +
  geom_gene_tag(aes(label=name))
p0

image

# construct, add and plot CDS sublinks
c0 <- select(g0, cluster_id = name, feat_id)
p1 <- p0 %>% add_clusters(c0)
p1 + geom_link(aes(fill=cluster_id))

image