Compute relative distances between intervals.
bed_reldist(x, y, detail = FALSE)
x | |
---|---|
y | |
detail | report relative distances for each |
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.
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.
http://bedtools.readthedocs.io/en/latest/content/tools/reldist.html
Other interval statistics: bed_absdist
,
bed_fisher
, bed_jaccard
,
bed_projection
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.0100 19966 999954 0.0200 #> 3 0.0200 20135 999954 0.0201 #> 4 0.0300 20105 999954 0.0201 #> 5 0.0400 19854 999954 0.0199 #> 6 0.0500 19848 999954 0.0198 #> 7 0.0600 20095 999954 0.0201 #> 8 0.0700 20232 999954 0.0202 #> 9 0.0800 19889 999954 0.0199 #> 10 0.0900 19949 999954 0.0199 #> # ... with 41 more rowsbed_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