ehrapy.anndata.move_to_obs

ehrapy.anndata.move_to_obs(adata, to_obs, copy_obs=False)[source]

Move inplace or copy features from X to obs.

Note that columns containing boolean values (either 0/1 or True(true)/False(false)) will be stored as boolean columns whereas the other non numerical columns will be stored as categorical.

Parameters:
  • adata (AnnData) – The AnnData object

  • to_obs (list[str] | str) – The columns to move to obs

  • copy_obs (bool) – The values are copied to obs (and therefore kept in X) instead of moved completely

Return type:

AnnData

Returns:

The original AnnData object with moved or copied columns from X to obs

Examples

>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=True)
>>> ep.ad.move_to_obs(adata, ["age"], copy_obs=False)