spac.utils.check_annotation(adata, annotations=None, parameter_name=None, should_exist=True)[source]

Perform common error checks for annotations in anndata related objects.

Parameters:
  • adata (anndata.AnnData) – The AnnData object to be checked.

  • annotations (str or list of str, optional) – The annotation(s) to check for existence in adata.obs.

  • should_exist (bool, optional (default=True)) – Determines whether to check if elements exist in the target list (True), or if they should not exist (False).

Raises:
  • TypeError – If adata is not an instance of anndata.AnnData.

  • ValueError – If any of the specified layers, annotations, or features do not exist.