Compute relative distances between intervals.

bed_reldist(x, y, detail = FALSE)

Arguments

x

tbl_interval()

y

tbl_interval()

detail

report relative distances for each x interval.

Value

If detail = FALSE, a tbl_interval() that summarizes calculated .reldist values with the following columns:

  • .reldist relative distance metric

  • .counts number of metric observations

  • .total total observations

  • .freq frequency of observation

If detail = TRUE, the .reldist column reports the relative distance for each input x interval.

Details

Interval statistics can be used in combination with dplyr::group_by() and dplyr::do() to calculate statistics for subsets of data. See vignette('interval-stats') for examples.

See also

Examples

genome <- read_genome(valr_example('hg19.chrom.sizes.gz')) x <- bed_random(genome, seed = 1010486) y <- bed_random(genome, seed = 9203911) bed_reldist(x, y)
#> # A tibble: 51 x 4 #> .reldist .counts .total .freq #> <dbl> <int> <int> <dbl> #> 1 0 19907 999954 0.0199 #> 2 0.01 20056 999954 0.0201 #> 3 0.02 19880 999954 0.0199 #> 4 0.03 19826 999954 0.0198 #> 5 0.04 19924 999954 0.0199 #> 6 0.05 20059 999954 0.0201 #> 7 0.06 20155 999954 0.0202 #> 8 0.07 20044 999954 0.0200 #> 9 0.08 19976 999954 0.0200 #> 10 0.09 20122 999954 0.0201 #> # ... with 41 more rows
bed_reldist(x, y, detail = TRUE)
#> # A tibble: 999,954 x 4 #> chrom start end .reldist #> <chr> <int> <int> <dbl> #> 1 chr1 22801 23801 0.234 #> 2 chr1 30996 31996 0.220 #> 3 chr1 41948 42948 0.323 #> 4 chr1 43940 44940 0.0105 #> 5 chr1 50886 51886 0.447 #> 6 chr1 60622 61622 0.148 #> 7 chr1 61161 62161 0.246 #> 8 chr1 61399 62399 0.289 #> 9 chr1 61407 62407 0.291 #> 10 chr1 62047 63047 0.408 #> # ... with 999,944 more rows