Compute relative distances between intervals.

bed_reldist(x, y, detail = FALSE)

Arguments

x

ivl_df

y

ivl_df

detail

report relative distances for each x interval.

Value

If detail = FALSE, a ivl_df 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 20170 999954 0.0202 #> 2 0.01 19966 999954 0.0200 #> 3 0.02 20135 999954 0.0201 #> 4 0.03 20105 999954 0.0201 #> 5 0.04 19854 999954 0.0199 #> 6 0.05 19848 999954 0.0198 #> 7 0.06 20095 999954 0.0201 #> 8 0.07 20232 999954 0.0202 #> 9 0.08 19889 999954 0.0199 #> 10 0.09 19949 999954 0.0199 #> # … 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 323 1323 0.0608 #> 2 chr1 2032 3032 0.405 #> 3 chr1 2475 3475 0.494 #> 4 chr1 2759 3759 0.448 #> 5 chr1 2766 3766 0.447 #> 6 chr1 3528 4528 0.294 #> 7 chr1 8394 9394 0.0764 #> 8 chr1 8819 9819 0.461 #> 9 chr1 12963 13963 0.493 #> 10 chr1 24939 25939 0.0594 #> # … with 999,944 more rows