lamindb.Annotate

class lamindb.Annotate

Bases: object

Annotation flow.

Attributes

Methods

classmethod from_anndata(data, var_index, categoricals=None, using='default', verbosity='hint', organism=None)

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.

Return type:

AnnDataAnnotator

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",
    )

.

classmethod from_df(df, categoricals=None, columns=FieldAttr(Feature.name), using=None, verbosity='hint', organism=None)

Annotation flow for a DataFrame object.

Parameters:
  • df (DataFrame) – The DataFrame object to annotate.

  • columns (DeferredAttribute, default: FieldAttr(Feature.name)) – The field attribute for the feature column.

  • categoricals (dict[str, DeferredAttribute] | None, default: None) – A dictionary mapping column names to registry_field.

  • using (str | None, default: None) – The reference instance containing registries to validate against.

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

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

Return type:

DataFrameAnnotator

Examples

>>> import bionty as bt
>>> annotate = ln.Annotate.from_df(
        df,
        categoricals={"cell_type_ontology_id": bt.CellType.ontology_id, "donor_id": ln.ULabel.name}
    )

.

classmethod from_mudata(mdata, var_index, categoricals=None, using='default', verbosity='hint', organism=None)

Annotation flow for a MuData object.

Parameters:
  • mdata (MuData) – The MuData object to annotate.

  • var_index (dict[str, dict[str, DeferredAttribute]]) – The registry field for mapping the .var index for each modality. For example: {"modality_1": bt.Gene.ensembl_gene_id, "modality_2": ln.CellMarker.name}

  • categoricals (dict[str, DeferredAttribute] | None, default: None) – A dictionary mapping .obs.columns to a registry field. Use modality keys to specify categoricals for MuData slots such as "rna:cell_type": bt.CellType.name".

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

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

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

Return type:

MuDataAnnotator

Examples

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

.