multiBlockVar {scran}R Documentation

Per-block variance statistics

Description

Fit a mean-dependent trend to the per-gene variances for each blocking level, and decompose them to biological and technical components.

Usage

multiBlockVar(x, block, make.tech.trend=FALSE, trend.args=list(), 
    dec.args=list(), assay.type="logcounts", ...)

Arguments

x

A SingleCellExperiment object containing log-normalized expression values, computed with multiBlockNorm.

block

A factor specifying the blocking level for each cell in x.

make.tech.trend

A logical scalar indicating whether to use makeTechTrend to create the mean-variance trend.

trend.args

A list of named arguments to pass to trendVar if make.tech.trend=FALSE or makeTechTrend otherwise.

dec.args

A list of named arguments to pass to decomposeVar.

assay.type

A string or integer scalar specifying the assay in x to use for all calculations (except for makeTechTrend).

...

Additional arguments to pass to combineVar.

Details

This function models the variance of expression in each level of block separately. Each subset of cells is passed to trendVar (or makeTechTrend) to fit a block-specific trend, and then passed to decomposeVar to obtain block-specific biological and technical components. Results are consolidated across blocks using the combineVar function. The aim is to enable users to handle differences in the mean-variance relationship across, e.g., different experimental batches.

We assume that the size factors for the endogenous genes have the same mean as the size factors for the spike-ins within each block. This ensures that the spike-in normalized values are comparable to those of the endogenous genes. Centering should be performed by running multiBlockNorm before calling this function. Otherwise, a warning will be raised about non-centered size factors.

Value

A DataFrame is returned containing all components returned by combineVar, in addition to a per.block column. This additional column is a DataFrame containing nested DataFrames, each containing a result of decomposeVar for the corresponding level of block. The trend function from trendVar or makeTechTrend is also stored as trend in the metadata of the per-block nested DataFrames.

Author(s)

Aaron Lun

References

Lun ATL, McCarthy DJ and Marioni JC (2016). A step-by-step workflow for low-level analysis of single-cell RNA-seq data with Bioconductor. F1000Res. 5:2122

See Also

trendVar, decomposeVar, combineVar, multiBlockNorm

Examples

example(computeSpikeFactors) # Using the mocked-up data 'y' from this example.

# Normalizing (gene-based factors for genes, spike-in factors for spike-ins)
y <- computeSumFactors(y) 
y <- computeSpikeFactors(y, general.use=FALSE)

# Setting up the blocking levels.
block <- sample(3, ncol(y), replace=TRUE)
y <- multiBlockNorm(y, block)
out <- multiBlockVar(y, block=block)

# Creating block-level plots.
par(mfrow=c(1,3))
is.spike <- isSpike(y)
for (x in as.character(1:3)) {
    current <- out$per.block[[x]]
    plot(current$mean, current$total, col="black", pch=16)
    points(current$mean[is.spike], current$total[is.spike], col="red", pch=16)
    curve(metadata(current)$trend(x), col="dodgerblue", lwd=2, add=TRUE)
}

[Package scran version 1.12.1 Index]