lamindb.core.AnnDataAnnotator

class lamindb.core.AnnDataAnnotator(data, var_index, categoricals=None, using='default', verbosity='hint', organism=None)

Bases: DataFrameAnnotator

Annotation flow for AnnData.

Parameters:
  • data (AnnData | str | Path) – The AnnData object or an AnnData-like path.

  • var_index (DeferredAttribute) – The registry field for mapping the .var index.

  • categoricals (dict[str, DeferredAttribute] | None, default: None) – A dictionary mapping .obs.columns to a registry field.

  • using (str, default: 'default') – A reference LaminDB instance.

  • verbosity (str, default: 'hint') – The verbosity level.

  • organism (str | None, default: None) – The organism name.

Examples

>>> import bionty as bt
>>> annotate = ln.Annotate.from_anndata(
        adata,
        var_index=bt.Gene.ensembl_gene_id,
        categoricals={"cell_type_ontology_id": bt.CellType.ontology_id, "donor_id": ln.ULabel.name},
        organism="human",
    )

Attributes

categoricals

Return the obs fields to validate against.

fields

Return the columns fields to validate against.

var_index

Return the registry field to validate variables index against.

Methods

add_new_from_var_index(organism=None, **kwargs)

Update variable records.

Parameters:
  • organism (str | None, default: None) – The organism name.

  • **kwargs – Additional keyword arguments to pass to the registry model.

lookup(using=None)

Lookup categories.

Parameters:

using (str | None, default: None) – The instance where the lookup is performed. if None (default), the lookup is performed on the instance specified in “using” parameter of the validator. if “public”, the lookup is performed on the public reference.

Return type:

AnnotateLookup

save_artifact(description=None, **kwargs)

Save the validated AnnData and metadata.

Parameters:
  • description (str | None, default: None) – Description of the AnnData object.

  • **kwargs – Object level metadata.

Return type:

Artifact

Returns:

A saved artifact record.

validate(organism=None)

Validate categories.

Parameters:

organism (str | None, default: None) – The organism name.

Return type:

bool

Returns:

Whether the AnnData object is validated.