Subsample from a sce object

subsample(sce, key = NULL, proportion = 0.1, minCellNum = 50, seed = 5202056)

Arguments

sce

SCE object to be sampled from

key

Required for stratefied subsampling

proportion

Proportion of cells to sample

minCellNum

Minimum number of cells in each category

seed

Random seed. The function sets the seed with withr::local_seed(), so the session's random-number state is restored on exit.

Value

A downsized SCE object

Examples

sce <- scuttle::mockSCE(ncells = 200, ngenes = 10)
small <- subsample(sce, proportion = 0.2)
ncol(small)
# Stratified by a colData column, keeping at least 20 cells per class.
strat <- subsample(sce, key = "Cell_Cycle", proportion = 0.1, minCellNum = 20)
table(strat$Cell_Cycle)