tacco.tools.find_regions

find_regions(adata, key_added='region', batch_key=None, position_weight=3.0, resolution=1.0, annotation_connectivity=None, annotation_key=None, position_connectivity=None, position_key=('x', 'y'), batch_position_distance=None, amplitudes=False, cross_batch_overweight_factor=1, **kw_args)[source]

Find regions in position space defined by proximity in position space and in expression (or annotation) space.

Parameters:
  • adata – An AnnData including expression data in .X and profiles in .varm and/or annotation in .obs or .obsm.

  • key_added – The .obs key where the resulting regions are written to. It is also used to determine where new neighbour and connectivity results should be written to, see parameters connectivity and position_connectivity.

  • batch_key – The .obs key with categorical batch information. The expression connectivity is then balanced within and between batches. If None, a single batch is assumed.

  • position_weight – The weight of the position connectivity compared to the expression connectivity.

  • resolution – The clustering resolution.

  • annotation_connectivity – The .obsp key where the precomputed expression connectivity can be found. If None, a new connectivity is computed with neighbors() and default parameters and then saved under “nn_<key_added>_annotation”.

  • annotation_key – The .obsm key containing data to use instead of expression. If None, use expression data.

  • position_connectivity – The .obsp key where the precomputed position connectivity can be found. If None, a new connectivity is computed with scanpy.pp.neighbors() and default parameters and then saved under “nn_<key_added>_position”.

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

  • batch_position_distance – The additional position distance to apply to observations between batches. If None, it is taken much larger than any distance within a batch.

  • amplitudes – Whether to treat the annotation as probabilities and calculate amplitudes from them

  • cross_batch_overweight_factor – The factor to increase cross batch connection weight over within batch connections.

  • **kw_args – Additional key word arguments are forwarded to neighbors(). Particularly interesting is probably n_neighbors.

Returns:

The updated input adata containing e.g. the obs[key_added] containing the region information.