Client
- class cellarium.cas.client.CASClient(api_token: str, num_attempts_per_chunk: int = 7)[source]
Bases:
objectService that is designed to communicate with the Cellarium Cloud Backend.
- Parameters:
api_token – API token issued by the Cellarium team
num_attempts_per_chunk – Number of attempts the client should make to annotate each chunk.
Default:3
- annotate_10x_h5_file(filepath: str, chunk_size: int = 2000, cas_model_name: str = 'default', count_matrix_name: str = 'X', feature_ids_column_name: str = 'index', include_dev_metadata: bool = False) List[Dict[str, Any]][source]
Parse the 10x ‘h5’ matrix and apply the
annotate_anndata()method to it.- Parameters:
filepath – Filepath of the local ‘h5’ matrix
chunk_size – Size of chunks to split on
cas_model_name – Model name to use for annotation.
Allowed Values: Model name from theallowed_models_listlist or"default"keyword, which refers to the default selected model in the Cellarium backend.
Default:"default"count_matrix_name –
Where to obtain a feature expression count matrix from.
Allowed Values: Choice of either"X"or"raw.X"in order to useadata.Xoradata.raw.X,respectively
Default:
"X"feature_ids_column_name – Column name where to obtain Ensembl feature ids.
Allowed Values: A value fromadata.var.columnsor"index"keyword, which refers to index column.
Default:"index"include_dev_metadata – Boolean indicating whether to include a breakdown of the number of cells by dataset
- Returns:
A list of dictionaries with annotations for each of the cells from input adata
- annotate_anndata(adata: AnnData, chunk_size=2000, cas_model_name: str = 'default', count_matrix_name: str = 'X', feature_ids_column_name: str = 'index', include_dev_metadata: bool = False) List[Dict[str, Any]][source]
Send an instance of
anndata.AnnDatato the Cellarium Cloud backend for annotations. The function splits theadatainto smaller chunks and asynchronously sends them to the backend API service. Each chunk is of equal size, except for the last one, which may be smaller. The backend processes these chunks in parallel.- Parameters:
adata –
anndata.AnnDatainstance to annotatechunk_size – Size of chunks to split on
cas_model_name – Model name to use for annotation.
Allowed Values: Model name from theallowed_models_listlist or"default"keyword, which refers to the default selected model in the Cellarium backend.
Default:"default"count_matrix_name –
Where to obtain a feature expression count matrix from.
Allowed Values: Choice of either"X"or"raw.X"in order to useadata.Xoradata.raw.X,respectively
Default:
"X"feature_ids_column_name – Column name where to obtain Ensembl feature ids.
Allowed Values: A value fromadata.var.columnsor"index"keyword, which refers to index column.
Default:"index"include_dev_metadata – Boolean indicating whether to include a breakdown of the number of cells by dataset
- Returns:
A list of dictionaries with annotations for each of the cells from input adata
- annotate_anndata_file(filepath: str, chunk_size=2000, cas_model_name: str = 'default', count_matrix_name: str = 'X', feature_ids_column_name: str = 'index', include_dev_metadata: bool = False) List[Dict[str, Any]][source]
Read the ‘h5ad’ file into a
anndata.AnnDatamatrix and apply theannotate_anndata()method to it.- Parameters:
filepath – Filepath of the local
anndata.AnnDatamatrixchunk_size – Size of chunks to split on
cas_model_name – Model name to use for annotation.
Allowed Values: Model name from theallowed_models_listlist or"default"keyword, which refers to the default selected model in the Cellarium backend.
Default:"default"count_matrix_name –
Where to obtain a feature expression count matrix from.
Allowed Values: Choice of either"X"or"raw.X"in order to useadata.Xoradata.raw.X,respectively
Default:
"X"feature_ids_column_name – Column name where to obtain Ensembl feature ids.
Allowed Values: A value fromadata.var.columnsor"index"keyword, which refers to index column.
Default:"index"include_dev_metadata – Boolean indicating whether to include a breakdown of the number of cells per dataset
- Returns:
A list of dictionaries with annotations for each of the cells from input adata