Skip to content
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

Changing start site of seq track and keeping layout. #190

Open
Rikkiff opened this issue Jun 18, 2024 · 4 comments
Open

Changing start site of seq track and keeping layout. #190

Rikkiff opened this issue Jun 18, 2024 · 4 comments

Comments

@Rikkiff
Copy link

Rikkiff commented Jun 18, 2024

Hi,
I am comparing circular sequences with random start points. It there a way that I can manually change the start points of the seq tracks without changing the mapping of the other tracks to the seq track?

@thackl
Copy link
Owner

thackl commented Jun 18, 2024

Not 100% sure what you mean, but could this be it https://thackl.github.io/gggenomes/reference/shift.html

@Rikkiff
Copy link
Author

Rikkiff commented Jun 18, 2024

Thanks Thomas!
Actually, I want to change the start site of the sequences. So, for example that all sequences are starting with the MCP gene you are centring on in your example.

@thackl
Copy link
Owner

thackl commented Jun 18, 2024

Ah, ok, so you sort of want to rotate the annotations. How about something like this:

library(tidyverse)
library(gggenomes)

s1 <- tibble(
  seq_id = c("A", "B"),
  length = 2000
)

g1 <- tibble(
  seq_id = rep(c("A", "B"), each=4),
  feat_id = c("a-start", "a2", "a3", "a4", "b3", "b4", "b-start", "b2"),
  start = rep(c(100, 600, 1100, 1600), 2),
  end = start +300)

Original sequence with B having start in the middle

#| fig.height: 2
#| fig.width: 5
gggenomes(g1, s1) +
  geom_seq() +
  geom_gene() +
  geom_gene_tag(aes(label=feat_id))

image

B broken up at start gene and first half of genome plotted as individual contig before second half of genome

#| fig.height: 2
#| fig.width: 5
# "zoom" in on parts of sequences and reorganize
# use all of A:0-2000, use B:1000-2000, then B:0:1000
p1 <- gggenomes(g1, s1, spacing = 10) |> # spacing controls the distance between contigs of same genome
  focus(.loci = tibble(  
    seq_id = c("A", "B", "B"),
    start = c(0, 1000, 0),
    end = c(2000, 2000, 1000)))
p1 + 
  geom_seq() +
  geom_gene() +
  geom_gene_tag(aes(label=feat_id))

image

I chose the breakpoint here (.loci tibble) manually, but I think it could also be computed easily from your start gene locations...

@Rikkiff
Copy link
Author

Rikkiff commented Jun 19, 2024

This works. Thanks again Thomas!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants