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

coord_polar #89

Open
thackl opened this issue Oct 8, 2021 · 1 comment
Open

coord_polar #89

thackl opened this issue Oct 8, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@thackl
Copy link
Owner

thackl commented Oct 8, 2021

Originally posted by @iferres in #85 (comment)

I assume the following feature request is not trivial at all, but have you considered ... + coord_polar() to draw circularized contigs? Playing with the package (and diving into the source code) I found that the following kinda works:

library(gggenomes) 

s0 <- tibble(
  gene_id = letters[1:6],
  bin_id = c("A", "A", "B", "B", "B", "B"),
  seq_id = factor(c("A1", "A1", "B1", "B1", "B2", "B2"), levels = c("A1", "B2", "B1")), # set factor to order contigs
  feat_id = c("a1","a2","b3", "b4", "b1", "b2"),
  start = c(1, 20, 1, 50, 1, 20),
  end = c(10, 30, 40, 70, 10, 30),
  strand = c(1, 1, 1, 1, 1, 1),
  length = c(1000, 1000, 1000, 1000, 1000, 1000)
)

gggenomes(s0) + 
  geom_seq() + 
  gggenomes:::geom_gene2() + 
  coord_polar() # + 
  # facet_wrap(~bin_id)

but I guess is experimental and there's a lot to work with to make it stable and user friendly, isn't it?

@thackl
Copy link
Owner Author

thackl commented Oct 8, 2021

Yes, I thought about it and, yep, your last sentence perfectly sums it up :D.

Here's something I put together playing around before. There's definitely potential, but also a lot of things that break (like geom_gene()). At this point it's not high enough up on my priority list to put in the effort and fully implement it. But it might already be useful to some users to provide guidance on how to explore it as an experimental feature (as you did)

gggenomes(emale_genes %>% mutate(gene_id=feat_id), emale_seqs[1:5,], feats=emale_gc) %>%
  add_clusters(emale_cogs) %>%
  flip_by_links() +
  geom_seq() +
  geom_wiggle(aes(z=score, color=score), geom="linerange", offset=-.4) +
  geom_link(offset=c(0.2,0.2), color=NA) +
  gggenomes:::geom_gene2() +
  coord_polar() + ylim(-2, NA) + xlim(-9000,NA) +
  geom_bin_label(aes(x=0, label=paste0(bin_id, "   ")), angle=-90, hjust=1, vjust=.5, nudge_left = 0.02) +
  scale_colour_viridis_b(option="A")

emales-polar

@thackl thackl added the enhancement New feature or request label Oct 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant