divideIntoBatches: Divide into batches

Description Usage Arguments Details Value Author(s) Examples

View source: R/divideIntoBatches.R

Description

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

Usage

1
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

1
2
3
4
5
6
7
8
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.

batchelor documentation built on April 17, 2021, 6:02 p.m.