Sum number of modified and total reads for each region.
Source:R/sumOverRegions.R
sumOverRegions.Rd
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.
Arguments
- se
A
RangedSummarizedExperiment
object with assays"Nmod"
and"Nvalid"
, typically returned byreadBedMethyl
.- regions
A
GRanges
object with target regions.- keepZero
Logical scalar. If
FALSE
(the default), only elements fromregions
that contain at least one feature fromse
will be returned. IfTRUE
, all elements ofregions
will be returned, potentially with zero counts.- verbose
A logical scalar. If
TRUE
, report on progress.- ...
Additional parameters for
aggregateAcrossFeatures
, such asBPPARAM
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
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):