cellflow.preprocessing.encode_onehot

cellflow.preprocessing.encode_onehot(adata, covariate_keys, uns_key_added, exclude_values=None, copy=False)[source]

Encodes covariates obs as one-hot vectors and stores them in uns.

Parameters:
  • adata (AnnData) – An AnnData object.

  • covariate_keys (str | Sequence[str]) – Key(s) in obs containing the covariate(s) to encode.

  • uns_key_added (str) – Key in uns to store the one-hot encodings.

  • exclude_values (str | Sequence[Any]) – Value(s) to exclude from the one-hot encoding.

  • copy (bool) – Return a copy of adata instead of updating it in place.

Return type:

None | AnnData

Returns:

: If copy is True, returns a new AnnData object with the one-hot encodings stored in uns. Otherwise, updates adata in place.

Sets the following fields:

  • .uns[uns_key_added]: Dictionary containing the one-hot encodings for each covariate.