scparadise.scnoah.get_frac#
- scparadise.scnoah.get_frac(adata=None, path=None, path_save=None, stratify=None, fraction=0.1, shuffle=True, random_state=0)[source]#
Return a random subset of an AnnData object.
- Parameters:
adata (anndata.AnnData or None (default: None)) – Input AnnData object. Provide exactly one of adata and path.
path (str or path-like or None (default: None)) – Path to an .h5ad file. If supplied, the file is opened in backed read-only mode and the requested subset is materialized in memory.
path_save (str or path-like or None (default: None)) – Directory in which to save the output as adata_fraction.h5ad. No file is written when None.
stratify (str or None (default: None)) – Column in adata.obs used for stratified random sampling. If None, cells are sampled without stratification.
fraction (float or int (default: 0.1)) – If float, fraction of cells to return and must be in the interval (0, 1]. If int, absolute number of cells to return and must be between 1 and adata.n_obs.
shuffle (bool (default: True)) – If True, randomly sample cells. If False, return the first selected cells in the existing observation order. Stratification is ignored when shuffle=False.
random_state (int or None (default: 0)) – Random seed used for reproducible sampling when shuffle=True. Set to None for non-deterministic sampling.
- Returns:
Independent in-memory AnnData object containing the selected cells.
- Return type:
anndata.AnnData