-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introducing sequence breaks? #161
Comments
Interesting case. Do you have some (dummy) data for a reproducible example that I can play with? |
Here is a file with info on the sequences and genes. Don't think links are really necessary here for this particular case. |
How about something like this. library(gggenomes)
s0 <- read_csv("seqs.csv")
g0 <- read_csv("genes.csv")
g0
# full loci
p0 <- gggenomes(g0, s0) +
geom_seq() +
geom_gene(aes(fill=str_sub(feature_id, 1,3)))
# magic zoom in on "default" which mean all genes
p1 <- p0 |> focus(.expand = 1e3)
p1
# decorate sequence breaks
geom_break <- function(mapping_start = NULL, mapping_end = NULL,
data_start = seqs(start > 1), data_end=seqs(end < length),
label="//", size=4, hjust=.75, family="bold", stat="identity",
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...){
aes_start <- aes(x=x, y=y)
aes_start <- gggenomes:::aes_intersect(mapping_start, aes_start)
aes_end <- aes(x=xend, y=y)
aes_end <- gggenomes:::aes_intersect(mapping_end, aes_end)
list(
geom_text(aes_start, data=data_start, label=label, size=size, hjust=hjust,
family=family, ...),
geom_text(aes_end, data=data_end, label=label, size=size, hjust=1-hjust,
family=family, ...)
)
}
p2 <- p1 + geom_break(label="/")
p2
library(patchwork)
p0 + p1 + p2 + plot_layout(guides="collect") & theme(legend.position = "bottom")
ggsave("break-at-long-non-coding.png", width=10, height=5) |
Thanks! This I think is workable for my purposes :) |
Wait -- one more question actually. Is there a way to print the amount of nucleotides excluded in the breaks? |
Two options:
|
Extremely helpful, thank you so much! |
Hi! First, thanks for this excellent package -- it really generates beautiful plots and I appreciate that it works with eukaryotic datasets as well.
I am using this to generate some microsynteny plots for a locus I am working on. One of the odd features of this locus is that there is about ~10-15kb of non-coding region upstream of my GOI, which I would like to 'trim' so that I can make the useful information bigger. I am imagining a sequence break of at least 5kb or so in the middle of the 'contigs' that I show (see boxed parts of the screenshot below). I browsed the issues page and it seems like you were working on adding some tools to do this but I'm not sure if this particular use case has been implemented. I can likely hack something once I export the image as an svg but looking to hardcode as much of this as possible.
Thanks for your help!!
The text was updated successfully, but these errors were encountered: