Skip to contents

This function takes a RangedSummarizedExperiment with modification counts (collapsed over reads, such as created by readBedMethyl) and sums the counts for all features that overlap provided regions.

Usage

sumOverRegions(se, regions, keepZero = FALSE, verbose = FALSE, ...)

Arguments

se

A RangedSummarizedExperiment object with assays "Nmod" and "Nvalid", typically returned by readBedMethyl.

regions

A GRanges object with target regions.

keepZero

Logical scalar. If FALSE (the default), only elements from regions that contain at least one feature from se will be returned. If TRUE, all elements of regions will be returned, potentially with zero counts.

verbose

A logical scalar. If TRUE, report on progress.

...

Additional parameters for aggregateAcrossFeatures, such as BPPARAM to run the summing in parallel.

Value

A RangedSummarizedExperiment with up to length(regions) rows (exactly length(regions) rows if keepZero = TRUE) and ncol(se) columns. colData(se), but not rowData(se) will be preserved.

See also

aggregateAcrossFeatures that is used to

Author

Michael Stadler

Examples

# example bedMethyl file
bmfile <- system.file("extdata", "modkit_pileup_1.bed.gz", package = "footprintR")

# read into a RangedSummarizedExperiment
se <- readBedMethyl(bmfile)

# collaps it to a single region of interest
regions <- GenomicRanges::GRanges(
    "chr1", IRanges::IRanges(start = 6940000, end = 7000000, names = "a"))
sumOverRegions(se, regions)
#> Warning: dropping 1257 of 10000 positions (12.57%) that do not overlap any tile
#> class: RangedSummarizedExperiment 
#> dim: 1 1 
#> metadata(0):
#> assays(2): Nmod Nvalid
#> rownames(1): a
#> rowData names(0):
#> colnames(1): s1
#> colData names(0):