gggenomes
gggenomes copied to clipboard
Bézier curve for synteny block
Hi, @thackl
Can gggenomes
use the Bézier curve for synteny block ? Like the sankey plot https://github.com/davidsjoberg/ggsankey
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...
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")