cellflow.preprocessing.annotate_compounds

cellflow.preprocessing.annotate_compounds(adata, compound_keys, control_category='control', query_id_type='name', obs_key_prefixes=None, copy=False)[source]

Annotates compounds in adata using pertpy and PubChem.

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

  • compound_keys (str | Sequence[str]) – Key(s) in obs containing the compound identifiers.

  • control_category (str) – Category to exclude from the annotation.

  • query_id_type (Literal['name', 'cid']) – Type of the compound identifiers. Either 'name' or 'cid'.

  • obs_key_prefixes (str | Sequence[str] | None) – Prefix for the keys in obs to store the annotations. If None, uses compound_keys as prefixes.

  • 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 compound annotations stored in obs. Otherwise, updates adata in place.

Sets the following fields for each value in compound_keys:

  • .obs[f"{obs_key_prefix}_pubchem_name"]: Name of the compound.

  • .obs[f"{obs_key_prefix}_pubchem_ID"]: PubChem CID of the compound.

  • .obs[f"{obs_key_prefix}_smiles"]: SMILES representation of the compound.