tacco.preprocessing.construct_reference_profiles

construct_reference_profiles(adata, annotation_key=None, counts_location=None, inplace=True, normalize=True, target_sum=None, trafo=None)[source]

Constructs reference profiles from categorical annotations.

Parameters:
  • adata – An AnnData including expression data in .X and a categorical annotation in .obs.

  • annotation_key – The .obs key where the annotation is stored; this will also be used as a .varm key to store the resulting annotation profiles.

  • counts_location – A string or tuple specifying where the count matrix is stored, e.g. ‘X’, (‘raw’,’X’), (‘raw’,’obsm’,’my_counts_key’), (‘layer’,’my_counts_key’), … For details see counts().

  • inplace – Whether to update the input AnnData or return a copy.

  • normalize – Whether to normalize the reference annotation and profiles.

  • target_sum – The number of counts to normalize every observation to before computing profiles. If None, no normalization is performed.

  • trafo

    What transformation to apply to the expression before computing the profiles. After the computation, the transformation is inverted to get profiles in the same units as the expression. Possible values are:

    • ”log1p”: log(x+1)

    • ”sqrt”: sqrt(x)

    • None: no transformation

Returns:

Returns an AnnData containing the constructed profiles depending on inplace either as copy or as a reference to the original adata.