divideIntoBatches {batchelor}R Documentation

Divide into batches

Description

Divide a single input object into multiple separate objects according to their batch of origin.

Usage

divideIntoBatches(x, batch, byrow = FALSE, restrict = NULL)

Arguments

x

A matrix-like object where one dimension corresponds to cells and another represents features.

batch

A factor specifying the batch to which each cell belongs.

byrow

A logical scalar indicating whether rows correspond to cells.

restrict

A subsetting vector specifying which cells should be used for correction.

Details

This function is intended for internal use and other package developers. It splits a single input object into multiple batches, allowing developers to use the same code for the scenario where batch is supplied with a single input.

Value

A list containing:

Author(s)

Aaron Lun

Examples

X <- matrix(rnorm(1000), ncol=100)
out <- divideIntoBatches(X, sample(3, 100, replace=TRUE))
names(out)

# Recovering original order.
Y <- do.call(cbind, out$batches)
Z <- Y[,out$reorder]
all.equal(Z, X) # should be TRUE.


[Package batchelor version 1.6.3 Index]