ehrapy.anndata.get_obs_df

ehrapy.anndata.get_obs_df(adata, keys=(), obsm_keys=(), *, layer=None, features=None)[source]

Return values for observations in adata.

Parameters:
  • adata (AnnData) – AnnData object to get values from.

  • keys (Iterable[str], default: ()) – Keys from either .var_names, .var[gene_symbols], or .obs.columns.

  • obsm_keys (Iterable[tuple[str, int]], default: ()) – Tuple of (key from obsm, column index of obsm[key]).

  • layer (str, default: None) – Layer of adata.

  • features (str, default: None) – Column of adata.var to search for keys in.

Returns:

A dataframe with adata.obs_names as index, and values specified by keys and obsm_keys.

Examples

>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=True)
>>> ages = ep.ad.get_obs_df(adata, keys=["age"])