sfaira.ui.UserInterface

class sfaira.ui.UserInterface(custom_repo: Optional[Union[list, str]] = None, sfaira_repo: bool = False, cache_path: str = 'cache/')

This class performs data set handling and coordinates estimators for the different model types. Example code to obtain a UMAP embedding plot of the embedding created from your data with cell-type labels:

import sfaira
import anndata
import scanpy

# initialise your sfaira instance with a model lookuptable.
ui = sfaira.ui.UserInterface(custom_repo="/path/to/local/repo/folder/or/zenodo/repo/URL", sfaira_repo=False)
ui.zoo_embedding.model_id = 'embedding_human-blood-ae-0.2-0.1_theislab'  # pick desired model here
ui.zoo_celltype.model_id = 'celltype_human-blood-mlp-0.1.3-0.1_theislab'  # pick desired model here
ui.load_data(anndata.read("/path/to/file.h5ad"), gene_symbol_col='index', gene_ens_col='gene_ids')
ui.load_model_embedding()
ui.load_model_celltype()
ui.predict_all()
adata = ui.data.adata
scanpy.pp.neighbors(adata, use_rep="X_sfaira")
scanpy.tl.umap(adata)
scanpy.pl.umap(adata, color="celltypes_sfaira", show=True, save="UMAP_sfaira.png")

Attributes

estimator_embedding

estimator_celltype

zoo_embedding

zoo_celltype

data

model_lookuptable

adata_ids

Methods

celltype_summary()

Return type with frequencies of predicted cell types.

compute_denoised_expression()

Run local embedding prediction model and add denoised expression to new adata layer.

deposit_zenodo(zenodo_access_token, title, ...)

Deposit all models in model lookup table on Zenodo.

load_data(data[, gene_symbol_col, ...])

Loads the provided AnnData object into sfaira.

load_model_celltype()

Initialise cell type model and load parameters from public parameter repository.

load_model_embedding()

Initialise embedding model and load parameters from public parameter repository.

predict_all()

Run local cell type prediction and embedding models and add results of both to adata.

predict_celltypes()

Run local cell type prediction model and add predictions to adata.obs.

predict_embedding()

Run local embedding prediction model and add embedding to adata.obsm.

write_lookuptable(repo_path)

param repo_path