R/dplyr-summarize.R
ranges-summarise.RdReduce multiple values in a Ranges down to a single value
# S3 method for class 'Ranges'
summarise(.data, ...)A S4Vectors::DataFrame()
Creates one or more variables as a S4Vectors::DataFrame()
from the input Ranges object. If the ranges object is grouped, there will
be a row for each group. Because grouping may remove whether a Ranges object
is valid, a DataFrame is always returned.
df <- data.frame(start = 1:10, width = 5, seqnames = "seq1",
strand = sample(c("+", "-", "*"), 10, replace = TRUE), gc = runif(10))
rng <- as_granges(df)
rng %>% summarise(gc = mean(gc))
#> DataFrame with 1 row and 1 column
#> gc
#> <numeric>
#> 1 0.651071
rng %>% group_by(strand) %>% summarise(gc = mean(gc))
#> DataFrame with 3 rows and 2 columns
#> strand gc
#> <Rle> <numeric>
#> 1 + 0.646987
#> 2 - 0.443210
#> 3 * 0.759085