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

Bézier curve for synteny block #104

Open
baozg opened this issue Dec 31, 2021 · 2 comments
Open

Bézier curve for synteny block #104

baozg opened this issue Dec 31, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@baozg
Copy link

baozg commented Dec 31, 2021

Hi, @thackl

Can gggenomes use the Bézier curve for synteny block ? Like the sankey plot https://github.com/davidsjoberg/ggsankey
image

@thackl
Copy link
Owner

thackl commented Mar 16, 2022

No, not at the moment. But it's something that I also think would be nice to have. Not sure though, if I'll have the time to implement it...

@thackl thackl added the enhancement New feature or request label Mar 16, 2022
@thackl
Copy link
Owner

thackl commented Mar 16, 2022

Note to self: could probably use ggsankey::sigmoid() function to "smooth" geom_link() polygons.

sigmoid <- function(x_from, x_to, y_from, y_to, smooth = 5, n = 300) {
  x <- seq(-smooth, smooth, length = n)
  y <- exp(x) / (exp(x) + 1)
  out <- data.frame(x = (x + smooth) / (smooth * 2) * (x_to - x_from) + x_from,
                    y = y * (y_to - y_from) + y_from)
  out
}

library(tidyverse)

x0 <- tibble(x=c(1,10), y=c(1,10))
x1 <- sigmoid(x0$x[1], x0$x[2], x0$y[1], x0$y[2], 5, 50)

ggplot() + 
  geom_line(aes(x,y), data=x0) +
  geom_line(aes(x,y), data=x1, color="red")

image

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

2 participants