rnabioco / valr

Genome Interval Arithmetic in R
http://rnabioco.github.io/valr/
Other
88 stars 25 forks source link

closest behavior on book-ended intervals #327

Closed kriemo closed 6 years ago

kriemo commented 6 years ago

Distances are now reported correctly for book-ended intervals. The tests have been updated to reflect this fix. The distances reported are now also the same as bedtools closest output.

closes #311

library(valr)

x <- trbl_interval(
  ~chrom, ~start, ~end,
  "chr1", 100,    150
)

y <- trbl_interval(
  ~chrom, ~start, ~end,
  "chr1", 99,     100,
  "chr1", 100,    101,
  "chr1", 150,    151
)

bed_closest(x, y)
#> # A tibble: 3 x 7
#>   chrom start.x end.x start.y end.y .overlap .dist
#>   <chr>   <dbl> <dbl>   <dbl> <dbl>    <int> <int>
#> 1  chr1     100   150      99   100        0    -1
#> 2  chr1     100   150     100   101        1     0
#> 3  chr1     100   150     150   151        0     1

Created on 2018-01-24 by the reprex package (v0.1.1.9000).