apeglmResults: Run a quick pairwise contrast using lfcShrink with apeglm

Description Usage Arguments Details Value Note See Also Examples

Description

Wrapper function that helps set up lfcShrink() to shrink LFC values for a pairwise contrast via apeglm, without having to manually relevel factor reference levels to use the required coef argument.

Usage

1
2
3
4
apeglmResults(object, ...)

## S4 method for signature 'DESeqDataSet'
apeglmResults(object, contrast, res, ...)

Arguments

object

Object.

...

Additional arguments.

contrast

character(3). Pairwise contrast vector:

  1. factor: Grouping factor. Corresponds to column name in colData().

  2. numerator: Numerator samples.

  3. denominator: Denominator samples.

Numerator and denominator values correspond to grouping factor column. See results() for details. Note that we're intentionally being more strict about the input format here.

res

DESeqResults. Results containing unshrunken LFC values, generated with results().

Details

Dynamically sets reference factor levels, as recommended by DESeq2 vignette. Matches contrast input internally to corresponding coef corresponding to values in resultsNames().

Runs nbinomWaldTest() via DESeq(), followed by lfcShrink().

Value

DESeqResults, with apeglm adaptive shrinkage applied to fold change values.

Note

Updated 2020-08-17.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## DESeqDataSet ====
if (requireNamespace("apeglm", quietly = TRUE)) {
    dds <- DESeq2::makeExampleDESeqDataSet(n = 1000L, m = 12L)
    dds$condition <- factor(rep(LETTERS[seq_len(4L)], each = 3L))
    dds <- DESeq2::DESeq(dds)
    resultsNames(dds)

    ## Contrast C vs. B.
    contrast <- c(factor = "condition", numerator = "C", denominator = "B")

    ## Unshrunken DESeqResults.
    res <- DESeq2::results(dds, contrast = contrast)
    class(res)
    lfcShrinkType(res)

    ## Shrunken DESeqResults, using apeglm via `lfcShrink()`.
    shrink <- apeglmResults(
        object = dds,
        contrast = contrast,
        res = res
    )
    class(shrink)
    lfcShrinkType(shrink)
}

steinbaugh/DESeqAnalysis documentation built on Oct. 15, 2020, 2:02 a.m.