ehrapy.tools.add_medcat_annotation_to_obs

ehrapy.tools.add_medcat_annotation_to_obs(adata, name, use_key='medcat_annotations', added_colname=None, copy=False)[source]

Add info extracted from free text as a binary column to obs.

Indicates whether the specific entity to color by has been found in that row or not.

Parameters:
  • adata (AnnData) – AnnData object that holds the data to annotate.

  • name (Iterable[str] | str) – Name of the entity to add as a column to obs.

  • use_key (str) – Key to use for the annotated results.

  • added_colname (Iterable[str] | str | None) – Name of the column to add to obs. If None, name will be used.

  • copy (bool) – Whether to copy adata or not.

Return type:

AnnData | None

Returns:

Returns None if copy=False, else returns an AnnData object. Sets the following fields;

adata.obs[name | added_coname]pandas.DataFrame

Added column(s) to adata.obs, indicating whether the specific entity to color by has been found in that row or not.