Disjoin then aggregate a Ranges object

disjoin_ranges(.data, ...)

disjoin_ranges_directed(.data, ...)

Arguments

.data

a Ranges object to disjoin

...

Name-value pairs of summary functions.

Value

a Ranges object with the

Examples

df <- data.frame(start = 1:10, width = 5, seqnames = "seq1", strand = sample(c("+", "-", "*"), 10, replace = TRUE), gc = runif(10)) rng <- as_granges(df) rng %>% disjoin_ranges()
#> GRanges object with 14 ranges and 0 metadata columns: #> seqnames ranges strand #> <Rle> <IRanges> <Rle> #> [1] seq1 1 * #> [2] seq1 2 * #> [3] seq1 3 * #> [4] seq1 4 * #> [5] seq1 5 * #> ... ... ... ... #> [10] seq1 10 * #> [11] seq1 11 * #> [12] seq1 12 * #> [13] seq1 13 * #> [14] seq1 14 * #> ------- #> seqinfo: 1 sequence from an unspecified genome; no seqlengths
rng %>% disjoin_ranges(gc = mean(gc))
#> GRanges object with 14 ranges and 1 metadata column: #> seqnames ranges strand | gc #> <Rle> <IRanges> <Rle> | <numeric> #> [1] seq1 1 * | 0.0378025793470442 #> [2] seq1 2 * | 0.307869990123436 #> [3] seq1 3 * | 0.44968471614023 #> [4] seq1 4 * | 0.399449137796182 #> [5] seq1 5 * | 0.379706615209579 #> ... ... ... ... . ... #> [10] seq1 10 * | 0.531334995757788 #> [11] seq1 11 * | 0.480802069301717 #> [12] seq1 12 * | 0.338751300548514 #> [13] seq1 13 * | 0.403218566789292 #> [14] seq1 14 * | 0.448299144394696 #> ------- #> seqinfo: 1 sequence from an unspecified genome; no seqlengths
rng %>% disjoin_ranges_directed(gc = mean(gc))
#> GRanges object with 15 ranges and 1 metadata column: #> seqnames ranges strand | gc #> <Rle> <IRanges> <Rle> | <numeric> #> [1] seq1 4-8 + | 0.248742402764037 #> [2] seq1 1 - | 0.0378025793470442 #> [3] seq1 2-4 - | 0.307869990123436 #> [4] seq1 5 - | 0.305492168370013 #> [5] seq1 6 - | 0.439336962881498 #> ... ... ... ... . ... #> [11] seq1 9 * | 0.433807152944307 #> [12] seq1 10 * | 0.437430150806904 #> [13] seq1 11-12 * | 0.338751300548514 #> [14] seq1 13 * | 0.403218566789292 #> [15] seq1 14 * | 0.448299144394696 #> ------- #> seqinfo: 1 sequence from an unspecified genome; no seqlengths