smoothSds: Smooth the standard deviations using a thresholded running...

View source: R/BSmooth.fstat.R

smoothSdsR Documentation

Smooth the standard deviations using a thresholded running mean based on smoothed whole-genome bisulfite sequencing data.

Description

Smooth the standard deviations using a thresholded running mean based on smoothed whole-genome bisulfite sequencing data.

Usage

    smoothSds(BSseqStat, k = 101, qSd = 0.75, mc.cores = 1, maxGap = 10^8,
              verbose = TRUE)

Arguments

BSseqStat

An object of class BSseqStat, typically an object returned by BSmooth.fstat(...) and not constructed by the user.

k

A positive scalar, see details.

qSd

A scalar between 0 and 1, see details.

mc.cores

The number of cores used. Note that setting mc.cores to a value greater than 1 is not supported on MS Windows, see the help page for mclapply.

maxGap

A scalar greater than 0, see details.

verbose

Should the function be verbose?

Details

The standard deviation estimates are smoothed using a running mean with a width of k and thresholded using qSd which sets the minimum standard deviation to be the qSd-quantile.

Value

An object of class BSseqStat. More speciically, the input BSseqStat object with the computed statistics added to the stats slot (accessible with getStats).

Author(s)

Kasper Daniel Hansen khansen@jhsph.edu

See Also

BSmooth.fstat for the function to create the appropriate BSseqStat input object. BSseqStat also describes the return class. This function is likely to be followed by the use of computeStat.

Examples

  
    if(require(bsseqData)) {
        # library(limma) required for makeContrasts()
        library(limma)
        data(keepLoci.ex)
        data(BS.cancer.ex.fit)
        BS.cancer.ex.fit <- updateObject(BS.cancer.ex.fit)
        ## Remember to subset the BSseq object, see vignette for explanation
        ## TODO: Kind of a forced example
        design <- model.matrix(~0 + BS.cancer.ex.fit$Type)
        colnames(design) <- gsub("BS\\.cancer\\.ex\\.fit\\$Type", "",
                                 colnames(design))
        contrasts <- makeContrasts(
            cancer_vs_normal = cancer - normal,
            levels = design
        )
        BS.stat <- BSmooth.fstat(BS.cancer.ex.fit[keepLoci.ex,],
                                 design,
                                 contrasts)
        BS.stat <- smoothSds(BS.stat)
        ## Comparing the raw standard deviations to the smoothed standard
        ## deviations
        summary(getStats(BS.stat, what = "rawSds"))
        summary(getStats(BS.stat, what = "smoothSds"))
    }
  

kasperdanielhansen/bsseq documentation built on Dec. 17, 2024, 12:47 p.m.