Apply a random resample of cell identifier in Seurat object. Original cell type proportion in Seurat dataset will be preserved when non-spatial sampling strategy is applied. With spatial resampling, rare/sparse cell types will be less penalised from resampling compared to more abundant and spatially dense cell type, with a sampling proportion that tends to be inversely correlated with the initial cell type relative abundance

resample_cells(
  seurat = NULL,
  label = "cell_types",
  spatial = T,
  maxcells = 10000,
  seed = 347548,
  return.seurat = T,
  update.kandinsky = T
)

Arguments

seurat

Seurat object

label

character string indicating meta data variable containing cell type annotation

spatial

boolean, whether or not applying a spatially-informed resampling

maxcells

numeric, ideal number of cells to resample. When `spatial` is true, an optimal number of cells as close as possible to `maxcells` argument will be sampled by testing multiple resampling resolution parameters

seed

numeric, random seed for reproducibility

return.seurat

boolean, whether returning resampled IDs (FALSE) or the whole seurat object already filtered with resampled IDs (TRUE)

update.kandinsky

boolean, whether or not update Kandinsky data after resampling. Default is TRUE. Only applied when `return.seurat` is TRUE

Value

vector of resampled cell IDs or Seurat object with resampled cell subset