thackl / gggenomes

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

Change space between seqs within the same bin #150

Closed yzhong005 closed 9 months ago

yzhong005 commented 1 year ago

Thank you so much for conducting this wonderful package! I quite like it! I have met a problem that, I cannot find how to change the space (distance) between seqs on the same line (share the same bin_id). If I change the space in gggenomes, it is actually changing the space between all bins, which is not what I really want. Can anyone provide some suggestions? Thank u!

thackl commented 1 year ago

Try gggenomes(spacing=0.2) or so. Does that help?

https://thackl.github.io/gggenomes/reference/gggenomes.html

yzhong005 commented 1 year ago

That will also increase the space between different lines (bins). However, I only want to change the space within bin, between different seqs.

yzhong005 commented 1 year ago

IMG_9841

I want to change the space in GREEN circle, not the space with right arrows.

thackl commented 1 year ago

Hm, so this is how it looks like with spacing=0.3. Isn't that exactly what you want?

library(gggenomes)
s0 <- tibble(
  bin_id = c("A", "A", "B"),
  seq_id = c("a1","a2","b1"),
  length = c(2e5, 3e5, 5e5)
)

p1 <- gggenomes(seqs=s0) +
  geom_seq() +         # draw contig/chromosome lines
  geom_seq_label() +   # label each sequence 
  geom_bin_label()  # label each bin

p2 <- gggenomes(seqs=s0, spacing=0.3) +
  geom_seq() +         # draw contig/chromosome lines
  geom_seq_label() +   # label each sequence 
  geom_bin_label()  # label each bin

library(patchwork)
p1 + p2

image

yzhong005 commented 1 year ago

Wow, great! Thank you so much!