Created
August 3, 2023 14:03
-
-
Save mikelove/b855d493656438c0de64901d44b3eafc to your computer and use it in GitHub Desktop.
join_overlap_* but with distance as a metadata column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plyranges) | |
x <- data.frame(seqnames=1, | |
start=sample(1000,10,FALSE), | |
width=1, id=1:10) %>% | |
as_granges() | |
y <- data.frame(seqnames=1, | |
start=sample(1000,10,FALSE), | |
width=1, id=letters[1:10]) %>% | |
as_granges() | |
x %>% | |
join_overlap_inner(y, maxgap=100) | |
y2 <- y %>% | |
mutate(y_start = start) | |
x %>% | |
join_overlap_inner(y2, maxgap=100) %>% | |
mutate(distance = abs(start - y_start)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment