getCoverage {bsseq} | R Documentation

## Obtain coverage for BSseq objects.

### Description

Obtain coverage for BSseq objects.

### Usage

    getCoverage(BSseq, regions = NULL, type = c("Cov", "M"),
      what = c("perBase", "perRegionAverage", "perRegionTotal"),
      withDimnames = TRUE)

### Arguments

`BSseq` | An object of class `BSseq`.
`regions` | An optional `data.frame` or `GenomicRanges` object specifying a number of genomic regions.
`type` | This returns either coverage or the total evidence for methylation at the loci.
`what` | The type of return object, see details.
`withDimnames` | A `logical(1)`, indicating whether dimnames should be applied to extracted coverage elements. Setting `withDimnames = FALSE` increases the speed and memory efficiency with which coverage is extracted.

### Value

NOTE: The return type of `getCoverage` varies depending on its arguments.

If `regions` are not specified (`regions = NULL`) a DelayedMatrix object (`what = "perBase"`) is returned. This will either contain the per-base coverage, the average coverage, or the genome total coverage (depending on value of `what`).

If `what = "perBase"` and `regions` are specified, a list is returned. Each element of the list is a DelayedMatrix object corresponding to the genomic loci inside the region. It is conceptually the same as splitting the coverage by region.

If `what = "perRegionAverage"` or `what = "perRegionTotal"` and `regions` are specified the return value is a DelayedMatrix object. Each row of the DelayedMatrix corresponds to a region and contains either the average coverage or the total coverage in the region.

### Author(s)

Kasper Daniel Hansen khansen@jhsph.edu.

### See Also

`BSseq` for the `BSseq` class.

### Examples

    data(BS.chr22)
    head(getCoverage(BS.chr22, type = "M"))
    reg <- GRanges(seqnames = c("chr22", "chr22"),
      ranges = IRanges(start = c(1, 2*10^7), end = c(2*10^7 +1, 4*10^7)))
    getCoverage(BS.chr22, regions = reg, what = "perRegionAverage")
      cList <- getCoverage(BS.chr22, regions = reg)
    length(cList)
    head(cList[[1]])

    #-------------------------------------------------------------------------------
    # An example using a HDF5Array-backed BSseq object
    #

    library(HDF5Array)
    # See ?SummarizedExperiment::saveHDF5SummarizedExperiment for details
    hdf5_BS.chr22 <- saveHDF5SummarizedExperiment(x = BS.chr22,
                                                  dir = tempfile())
    head(getCoverage(hdf5_BS.chr22, type = "M"))
    reg <- GRanges(seqnames = c("chr22", "chr22"),
                   ranges = IRanges(start = c(1, 2 * 10 ^ 7),
                   end = c(2 * 10 ^ 7 + 1, 4 * 10 ^ 7)))
    getCoverage(hdf5_BS.chr22, regions = reg, what = "perRegionAverage")
    hdf5_cList <- getCoverage(hdf5_BS.chr22, regions = reg)
    length(hdf5_cList)
    head(hdf5_cList[[1]])

[Package bsseq version 1.24.4 Index]