Random_Cells_Downsample {scCustomize} | R Documentation |
Randomly downsample by identity
Description
Get a randomly downsampled set of cell barcodes with even numbers of cells for each identity class. Can return either as a list (1 entry per identity class) or vector of barcodes.
Usage
Random_Cells_Downsample(
seurat_object,
num_cells,
group.by = "ident",
return_list = FALSE,
allow_lower = FALSE,
seed = 123
)
Arguments
seurat_object |
Seurat object |
num_cells |
number of cells per ident to use in down-sampling. This value must be less than or equal to the size of ident with fewest cells. Alternatively, can set to "min" which will use the maximum number of barcodes based on size of smallest group. |
group.by |
The ident to use to group cells. Default is "ident" which use current active.ident. . |
return_list |
logical, whether or not to return the results as list instead of vector, default is FALSE. |
allow_lower |
logical, if number of cells in identity is lower than |
seed |
random seed to use for downsampling. Default is 123. |
Value
either a vector or list of cell barcodes
Examples
library(Seurat)
# return vector of barcodes
random_cells <- Random_Cells_Downsample(seurat_object = pbmc_small, num_cells = 10)
head(random_cells)
# return list
random_cells_list <- Random_Cells_Downsample(seurat_object = pbmc_small, return_list = TRUE,
num_cells = 10)
head(random_cells_list)
# return max total number of cells (setting `num_cells = "min`)
random_cells_max <- Random_Cells_Downsample(seurat_object = pbmc_small, num_cells = "min")