tacco.tools.annotate_OT

annotate_OT(adata, reference, annotation_key=None, counts_location=None, annotation_prior=None, epsilon=0.005, lamb=0.1, decomposition=False, deconvolution=False, **kw_args)[source]

Annotates an AnnData using reference data by semi-balanced optimal transport.

This is the direct interface to this annotation method. In practice using the general wrapper annotate() is recommended due to its higher flexibility.

Parameters:
  • adata – An AnnData including expression data in .X.

  • reference – Reference data to get the annotation definition from.

  • annotation_key – The .obs and/or .varm key where the annotation and/or profiles are stored in the reference. If None, it is inferred from reference, if possible.

  • counts_location – A string or tuple specifying where the count matrix is stored, e.g. ‘X’, (‘raw’,’X’), (‘raw’,’obsm’,’my_counts_key’), (‘layer’,’my_counts_key’), … For details see counts().

  • annotation_prior – A Series containing the annotation prior distribution. This argument is required and will throw a ValueError if it is unset.

  • epsilon – The prefactor for entropy regularization in Optimal Transport. Small values like 5e-3 tend to give only a few or a single annotation category per observation, while large values like 5e-1 give many annotation categories per observation.

  • lamb – The prefactor for prior constraint relaxation by KL divergence in unbalanced Optimal Transport. Smaller values like 1e-2 relax the constraint more than larger ones like 1e0. If None, do not relax the prior constraint and fix the annotation fraction at annotation_prior.

  • decomposition – Whether to decompose the annotation using information from injected in-silico type mixtures.

  • deconvolution

    Which method to use for deconvolution of the cost based on similarity of different annotation profiles. If False, no deconvolution is done. Available methods are:

    • ’nnls’: solves nnls to get only non-negative deconvolved projections

    • ’linear’: solves a linear system to disentangle contributions; can result in negative values which makes sense for general vectors and amplitudes, i.e.

  • **kw_args – Additional keyword arguments are forwarded to prep_distance().

Returns:

Returns the annotation in a DataFrame.