tacco.tools.fill_regions

fill_regions(adata, region_key='region', batch_key=None, position_key=('x', 'y'), result_key=Ellipsis, k=1)[source]

Fills the region annotation of not annotated observation (i.e. na values) with the majority vote of the annotations of the k annotated spatially closest observations.

Parameters:
  • adata – An AnnData including region and position annotation. Can also be a DataFrame which is then used in place of .obs.

  • region_key – The .obs key where the region annotation is stored.

  • batch_key – The .obs key with categorical batch information. If not None, the filling is performed per batch.

  • position_key – The .obsm key or array-like of .obs keys with the position space coordinates.

  • result_key – The .obs key of adata where to store the resulting annotation. If None, do not write to adata and return the annotation as Series instead. If Ellipsis (i.e. ) the result will overwritte the information contained in region_key. NOTE: The Ellipsis behaviour is kept for backwards compatibility and will be removed in a future release.

  • k – The k of the kNN classifier used for the task.

Returns:

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