scparadise.scnoah.get_frac

Contents

scparadise.scnoah.get_frac#

scparadise.scnoah.get_frac(adata=None, path=None, path_save='', celltype=None, fraction=0.1, shuffle=True, random_state=0)[source]#

Get fraction of anndata object. Specify path OR anndata object. The function returns a portion of the AnnData object while maintaining the ratio of cell types.

Parameters:
  • adata (AnnData) – Annotated data matrix.

  • path (str, path object) – Path to the AnnData object if AnnData is not loaded into RAM.

  • path_save (str, path object) – Path to save fraction of AnnData

  • celltype (str, (default: None)) – Cell type annotation. Key in adata.obs dataframe.

  • fraction (float or int, (default: 0.1)) – Should be between 0.0 and 1.0 and represent the proportion of the dataset to include in the adata.

  • shuffle (bool, (default: True)) – Whether or not to shuffle the data before subsetting. If shuffle = False, then celltype is not used to maintain the same ratio.

  • random_state (int, (default: 0)) – Controls the data shuffling and splitting. Pass an int for reproducible output across multiple function calls.

  • types. (Returns a fraction of the AnnData object while maintaining the same ratio of cell)

  • adata_fraction.h5ad. (This fraction of the AnnData object is also saved as)