ranges-reduce: Reduce then aggregate a Ranges object

reduce_rangesR Documentation

Reduce then aggregate a Ranges object

Description

Reduce then aggregate a Ranges object

Usage

reduce_ranges(.data, min.gapwidth = 1L, ...)

reduce_ranges_directed(.data, min.gapwidth = 1L, ...)

Arguments

.data

a Ranges object to reduce

min.gapwidth

Ranges separated by a gap of at least min.gapwidth positions are not merged.

...

Name-value pairs of summary functions.

Value

a Ranges object with the

Examples

set.seed(10)
df <- data.frame(start = sample(1:10), 
                 width = 5,  
                 seqnames = "seq1",
                 strand = sample(c("+", "-", "*"), 10, replace = TRUE), 
                 gc = runif(10))
                 
rng <- as_granges(df)
rng %>% reduce_ranges()
rng %>% reduce_ranges(gc = mean(gc))
rng %>% reduce_ranges_directed(gc = mean(gc))
rng %>% reduce_ranges_directed(gc = mean(gc), min.gapwidth = 10)

x <- data.frame(start = c(11:13, 2, 7:6), 
               width=3, 
               id=sample(letters[1:3], 6, replace = TRUE),
               score= sample(1:6))
x <- as_iranges(x)
x %>% reduce_ranges()
x %>% reduce_ranges(score = sum(score))
x %>% group_by(id) %>% reduce_ranges(score = sum(score))

sa-lee/plyranges documentation built on April 15, 2024, 12:25 p.m.