tacco.tools.annotate_tangram

annotate_tangram(adata, reference, annotation_key=None, counts_location=None, conda_env=None, result_file=None, cluster_mode=True, verbose=True, **kw_args)[source]

Annotates an AnnData using reference data by Tangram [Biancalani20].

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 key where the annotation is 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().

  • conda_env – The path of a conda environment where tangram is installed and importable as ‘import tangram’.

  • result_file – The name of a file to contain additional results of tangram as .h5ad. If None, nothing except for the returned annotation is retained.

  • cluster_mode – Whether to use tangrams cluster mode for cluster level decomposition, instead of cell level decomposition.

  • verbose – Whether to print stderr and stdout of the tangram run.

  • **kw_args – Additional keyword arguments are forwarded to tangram.map_cells_to_space(). Interesting should be in particular ‘device’ to use a gpu. Note that the arguments ‘mode’ and ‘cluster_label’ are should be used via specifying cluster_mode==True.

Returns:

Returns the annotation in a DataFrame. Depending on result_h5ad might also write additional results in a file.