Client

class cellarium.cas.client.CASClient(api_token: str, num_attempts_per_chunk: int = 3)[source]

Bases: object

Service 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') 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 the allowed_models_list list 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 use adata.X or adata.raw.X,

    respectively

    Default: "X"

  • feature_ids_column_name – Column name where to obtain Ensembl feature ids.
    Allowed Values: A value from adata.var.columns or "index" keyword, which refers to index column.
    Default: "index"

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') List[Dict[str, Any]][source]

Send an instance of anndata.AnnData to the Cellarium Cloud backend for annotations. The function splits the adata into 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:
  • adataanndata.AnnData instance to annotate

  • chunk_size – Size of chunks to split on

  • cas_model_name – Model name to use for annotation.
    Allowed Values: Model name from the allowed_models_list list 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 use adata.X or adata.raw.X,

    respectively

    Default: "X"

  • feature_ids_column_name – Column name where to obtain Ensembl feature ids.
    Allowed Values: A value from adata.var.columns or "index" keyword, which refers to index column.
    Default: "index"

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') List[Dict[str, Any]][source]

Read the ‘h5ad’ file into a anndata.AnnData matrix and apply the annotate_anndata() method to it.

Parameters:
  • filepath – Filepath of the local anndata.AnnData matrix

  • chunk_size – Size of chunks to split on

  • cas_model_name – Model name to use for annotation.
    Allowed Values: Model name from the allowed_models_list list 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 use adata.X or adata.raw.X,

    respectively

    Default: "X"

  • feature_ids_column_name – Column name where to obtain Ensembl feature ids.
    Allowed Values: A value from adata.var.columns or "index" keyword, which refers to index column.
    Default: "index"

Returns:

A list of dictionaries with annotations for each of the cells from input adata