ehrapy.anndata.move_to_x

ehrapy.anndata.move_to_x(adata, to_x, copy_x=False)[source]

Move features from obs to X inplace.

Parameters:
  • adata (AnnData) – The AnnData object

  • to_x (list[str] | str) – The columns to move to X

  • copy_x (bool, default: False) – The values are copied to X (and therefore kept in obs) instead of moved completely

Return type:

AnnData

Returns:

A new AnnData object with moved columns from obs to X. This should not be used for datetime columns currently.

Examples

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