tacco.utils.spatial_split

spatial_split(adata, position_key=('x', 'y'), position_split=2, sample_key=None, min_obs=0, result_key=None)[source]

Splits a dataset into spatial patches balancing the number of observations per split. NOTE: This function is deprecated. New code should use the updated split_spatial_samples().

Parameters:
  • adata – An AnnData with annotation in .obs (and .obsm). Can also be a DataFrame which is then used in place of .obs.

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

  • position_split – The number of splits per spatial dimension. Can be a tuple with the spatial dimension as length to assign a different split per dimension. If None, no position splits are performed. See also min_obs.

  • sample_key – The .obs key with categorical sample information: every sample is split separately. Can also be a Series containing the sample information. If None, assume a single sample.

  • min_obs – This limits the number of position_split by stopping the split if the split would decrease the number of observations below this threshold.

  • result_key – The .obs key to write the split sample annotation to. If None, returns the split sample annotation as Series.

Returns:

Depending on result_key returns either a Series containing the split sample annotation or the inpt adata with the split sample annotation written to adata.obs[result_key].