svaseqRemove: Detect surrogate variables from count data and remove their...

View source: R/svaseqRemove.R

svaseqRemoveR Documentation

Detect surrogate variables from count data and remove their effects VSN-transformed counts

Description

Detect surrogate variables from count data and remove their effects VSN-transformed counts

Usage

svaseqRemove(dgeList, design, nullModel, verbose = FALSE, offset)

Arguments

dgeList

An DGEList object

design

Design matrix

nullModel

Null model matrix

verbose

Logical

offset

If provided, it is passed to pcaScores.

In case no significant surrogate variables are detected, PCA analysis is applied to the vsn-transformed matrix.

Value

A list with following items

  • svaResults of svaseq

  • vsnFitFit object of vsn

  • vsnMatFitted matrix of vsn

  • vsnBatchRemovedFitted matrix of vsn, with surrogates' effect removed

  • vsnBatchRemovedPcaPCA object derived from vsnBatchRemoved

  • vsnBatchRemovedPcaScoresPCA scores with annotations

  • designWithSVDesign matrix with surrogates variables appended if any

Note

This function needs to be harmonized with the other SVA functions. The reason is that svaseq was for a long time not stable until recently. Therefore this function is written later, and unfortunately the outcome is not harmonized yet.

See Also

pcaScores

Examples

y1org <- matrix(rnbinom(4000, mu=5, size=2), ncol=8)
genes1 <- data.frame(GeneSymbol=sprintf("Gene%d", 1:nrow(y1org)))
y1 <- y1org
y1[30:120, 4:7] <- y1[30:120, 4:7]+9 ## mimicking batch effect
rownames(y1org) <- rownames(y1) <- rownames(genes1) <- 1:nrow(y1)
anno1 <- data.frame(treatment=gl(2,4, labels=c("ctrl", "tmt")),
    donor=factor(rep(c(1,2), 4)))
d1 <- DGEList(counts=y1, genes=genes1, samples=anno1)
d2 <- DGEList(counts=y1org, genes=genes1, samples=anno1)

design <- model.matrix(~treatment+donor, data=d1$samples)
nullModel <-  model.matrix(~donor, data=d1$samples)
d1VsnSvaRes <- svaseqRemove(d1, design, nullModel)
d2VsnSvaRes <- svaseqRemove(d2, design, nullModel)

bedapub/ribiosNGS documentation built on Feb. 10, 2025, 12:34 a.m.