tacco.preprocessing.filter_reference

filter_reference(adata, annotation_key=None, fill_na=True, fill_negative=None, return_mask=False, return_view=True, mode=None)[source]

Filter AnnData to include only genes and cells where at least one .varm and .obsm annotation is neither negative nor na.

Parameters:
  • adata – An AnnData containing the annotation to filter on.

  • annotation_key – The .varm and/or .obsm key where the annotation is stored.

  • fill_na – Fills na in the annotation with 0. This is done inplace, so the original adata might be changed. If None and na values are discovered, raises a ValueError.

  • fill_negative – Fills negative values in the annotation with 0. This is done inplace, so the original adata might be changed. If None and negative values are discovered, raises a ValueError.

  • return_mask – Instead of a (view of a) AnnData, return the boolen filter mask.

  • return_view – Instead of a AnnData, return a filtered view into the original adata. If nothing is filtered out, return the original adata.

  • mode – String to indicate whether to restrict filtering on .varm (“profiles”) or on .obsm (“annotation”). If None, do both.

Returns:

Depending on return_mask and return_view returns a filter mask, a filtered view, or a filtered copy of adata. If return_mask and mode is None, returns a tuple (cell_mask,gene_mask).