tacco.tools.annotate_single_molecules

annotate_single_molecules(molecules, reference, annotation_key, result_key=None, bin_size=None, position_keys=['x', 'y'], gene_key='gene', n_shifts=2, verbose=1, **kw_args)[source]

Annotates single molecules in space using reference data.

Parameters:
  • molecules – A DataFrame with columns containing spatial coordinates and molecule species annotation.

  • 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.

  • result_key – The key of molecules where to store the resulting annotation. If None, do not write to molecules and return the annotation as Series instead.

  • bin_size – The spatial size of a bin. Bins are of the same size in all dimensions. A bin should be large enough to contain enough molecules to enable statements about its type composition. If None, use a heuristic to choose a value.

  • position_keys – Array-like of column keys which contain the position of the molecules.

  • gene_key – The name of the column which contains the molecule species annotation.

  • n_shifts – An integer giving the number of independent binnings per dimension. Larger values give a better majority vote for the molecule annotation. But computing time scales with n_shifts**dimension.

  • verbose – Level of verbosity, with 0 (no output), 1 (some output), …

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

Returns:

Depending on result_key, either returns the original molecules with annotation written in the corresponding column, or just the annotation as a new Series.