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, trend.args=list(), dec.args=list(), ...)

### Arguments

`x` | A SingleCellExperiment object containing log-normalized expression values, computed from size factors centred in each block - see `normalize` for details.
`block` | A factor specifying the blocking level for each cell.
`trend.args` | A list of named arguments to pass to `trendVar`.
`dec.args` | A list of named arguments to pass to `decomposeVar`.
`...` | 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` 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 are centred within each block when computing log-normalized expression values. This preserves the scale of the counts within each block, and ensures that the spike-in normalized values are comparable to those of the endogenous genes. Centring can be performed by setting the `size_factor_grouping` argument in `normalize`. Otherwise, a warning will be raised about non-centred 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` 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`, `normalize`

### 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 <- normalize(y, size_factor_grouping=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.8.4 Index]