Subset a SingleCellExperiment by Cell Type
subsetSCE.Rd
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
SingleCellExperimentwith cell type annotations incolData. - cell_type_col
-
Column name in
colDatacontaining 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.