deviation-method: Deviation from expectation for each observation

deviationR Documentation

Deviation from expectation for each observation

Description

Given a model fit for each features, residuals are computed and transformed based on an absolute value or squaring transform.

Usage

deviation(fit, method = c("AD", "SQ"), scale = c("leverage", "none"))

## S4 method for signature 'MArrayLM'
deviation(fit, method = c("AD", "SQ"), scale = c("leverage", "none"))

Arguments

fit

model fit from dream()

method

transform the residuals using absolute deviation ("AD") or squared deviation ("SQ").

scale

scale each observation by "leverage", or no scaling ("none")

Value

matrix of deviations from expection for each observation

See Also

diffVar()

Examples

# library(variancePartition)
library(edgeR)
data(varPartDEdata)

# filter genes by number of counts
isexpr <- rowSums(cpm(countMatrix) > 0.1) >= 5

# Standard usage of limma/voom
dge <- DGEList(countMatrix[isexpr, ])
dge <- calcNormFactors(dge)

# make this vignette faster by analyzing a subset of genes
dge <- dge[1:1000, ]

# regression formula
form <- ~Disease

# estimate precision weights
vobj <- voomWithDreamWeights(dge, form, metadata)

# fit dream model
fit <- dream(vobj, form, metadata)
fit <- eBayes(fit)

# Compute deviation from expection for each observation
# using model residuals
z <- deviation(fit)
z[1:4, 1:4]


GabrielHoffman/variancePartition documentation built on April 20, 2024, 7:29 p.m.