Skip to contents

Randomly subsamples cells from a SingleCellExperiment either evenly across cell types or proportionally to their original abundance. If a cell type has fewer cells than requested, you can keep all of them ("asis") or drop that cell type ("remove").

Usage

subsetSCE(
  sce,
  cell_type_col = "celltype_major",
  scenario = "even",
  ncells = 1000,
  notEnough = "asis",
  seed = 12345
)

Arguments

sce

A SingleCellExperiment with cell type annotations in colData.

cell_type_col

Column name in colData containing cell type labels.

scenario

Subsampling strategy: "even" selects equal counts per type, "mirror" preserves original proportions.

ncells

Target total number of cells to keep (default: 1000).

notEnough

Behavior when a cell type has too few cells: "asis" keeps all, "remove" drops that cell type.

seed

Random seed for reproducible sampling.

Value

A subsetted SingleCellExperiment.