getMeth {bsseq} | R Documentation

## Obtain methylation estimates for BSseq objects.

### Description

Obtain methylation estimates for BSseq objects, both smoothed and raw.

### Usage

    getMeth(BSseq, regions = NULL, type = c("smooth", "raw"),
      what = c("perBase", "perRegion"), confint = FALSE, alpha = 0.95,
      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 smoothed or raw estimates of the methylation level.
`what` | The type of return object, see details.
`confint` | Should a confidence interval be return for the methylation estimates (see below). This is only supported if `what` is equal to `perBase`.
`alpha` | alpha value for the confidence interval.
`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 `getMeth` varies depending on its arguments.

If `region = NULL` the `what` argument is ignored. This is also the only situation in which `confint = TRUE` is supported. The return value is either a DelayedMatrix (`confint = FALSE` or a list with three DelayedMatrix components `confint = TRUE` (`meth`, `upper` and `lower`), giving the methylation estimates and (optionally) confidence intervals.

Confidence intervals for `type = "smooth"` is based on standard errors from the smoothing algorithm (if present). Otherwise it is based on pointwise confidence intervals for binomial distributions described in Agresti (see below), specifically the score confidence interval.

If `regions` are specified, `what = "perBase"` will make the function return a list, each element of the list being a DelayedMatrix corresponding to a genomic region (and each row of the DelayedMatrix being a loci inside the region). If `what = "perRegion"` the function returns a DelayedMatrix, with each row corresponding to a region and containing the average methylation level in that region.

### Note

A `BSseq` object needs to be smoothed by the function `BSmooth` in order to support `type = "smooth"`.

### Author(s)

Kasper Daniel Hansen khansen@jhsph.edu.

### References

A Agresti and B Coull. Approximate Is Better than "Exact" for Interval Estimation of Binomial Proportions. The American Statistician (1998) 52:119-126.

### See Also

`BSseq` for the `BSseq` class and `BSmooth` for smoothing such an object.

### Examples

    data(BS.chr22)
    head(getMeth(BS.chr22, type = "raw"))
    reg <- GRanges(seqnames = c("chr22", "chr22"),
      ranges = IRanges(start = c(1, 2*10^7), end = c(2*10^7 +1, 4*10^7)))
    head(getMeth(BS.chr22, regions = reg, type = "raw", what = "perBase"))

    #-------------------------------------------------------------------------------
    # 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(getMeth(hdf5_BS.chr22, type = "raw"))
    head(getMeth(hdf5_BS.chr22, regions = reg, type = "raw", what = "perBase"))

[Package bsseq version 1.18.0 Index]