Generate randomly placed intervals on a genome.

bed_random(genome, length = 1000, n = 1e+06, seed = 0, sorted = TRUE)

Arguments

genome

genome_df

length

length of intervals

n

number of intervals to generate

seed

seed RNG for reproducible intervals

sorted

return sorted output

Value

ivl_df

Details

Sorting can be suppressed with sorted = FALSE.

See also

Examples

genome <- tibble::tribble( ~chrom, ~size, "chr1", 10000000, "chr2", 50000000, "chr3", 60000000, "chrX", 5000000 ) bed_random(genome, seed = 10104)
#> # A tibble: 1,000,000 x 3 #> chrom start end #> <chr> <int> <int> #> 1 chr1 103 1103 #> 2 chr1 127 1127 #> 3 chr1 136 1136 #> 4 chr1 366 1366 #> 5 chr1 570 1570 #> 6 chr1 578 1578 #> 7 chr1 583 1583 #> 8 chr1 608 1608 #> 9 chr1 626 1626 #> 10 chr1 643 1643 #> # … with 999,990 more rows
# sorting can be suppressed bed_random(genome, sorted = FALSE, seed = 10104)
#> # A tibble: 1,000,000 x 3 #> chrom start end #> <chr> <int> <int> #> 1 chr3 57732457 57733457 #> 2 chr3 3718191 3719191 #> 3 chr2 14303922 14304922 #> 4 chr2 35002561 35003561 #> 5 chr3 41721326 41722326 #> 6 chr3 57830588 57831588 #> 7 chr3 42197908 42198908 #> 8 chrX 3787839 3788839 #> 9 chr3 33492117 33493117 #> 10 chr2 14530349 14531349 #> # … with 999,990 more rows
# 500 random intervals of length 500 bed_random(genome, length = 500, n = 500, seed = 10104)
#> # A tibble: 500 x 3 #> chrom start end #> <chr> <int> <int> #> 1 chr1 401902 402402 #> 2 chr1 591204 591704 #> 3 chr1 703042 703542 #> 4 chr1 738352 738852 #> 5 chr1 848804 849304 #> 6 chr1 1406707 1407207 #> 7 chr1 1701984 1702484 #> 8 chr1 1725426 1725926 #> 9 chr1 2058953 2059453 #> 10 chr1 2095530 2096030 #> # … with 490 more rows