ehrdata.EHRData

ehrdata.EHRData#

class ehrdata.EHRData(X=None, *, obs=None, var=None, tem=None, uns=None, obsm=None, varm=None, layers=None, raw=None, shape=None, filename=None, filemode=None, asview=False, obsp=None, varp=None, oidx=None, vidx=None, tidx=None)#

Model two and three dimensional electronic health record data.

../_images/ehrdata_logo.png

EHRData stores a data array X together with annotations of observations obs (obsm, obsp), variables var (varm, varp), time tem, and unstructured annotations uns.

Extends AnnData to further support time-series data.

Parameters:
X XDataType | DataFrame | None (default: None)

A #observations × #variables (× #time) data array.

obs DataFrame | Mapping[str, Iterable[Any]] | None (default: None)

Key-indexed one-dimensional observations annotation of length #observations.

var DataFrame | Mapping[str, Iterable[Any]] | None (default: None)

Key-indexed one-dimensional variables annotation of length #variables.

tem DataFrame | None (default: None)

Key-indexed one-dimensional time annotation of length #time.

uns Mapping[str, Any] | None (default: None)

Key-indexed unstructured annotation.

obsm ndarray | Mapping[str, Sequence[Any]] | None (default: None)

Key-indexed multi-dimensional observations annotation of length #observations. If passing a numpy.ndarray, it needs to have a structured datatype.

varm ndarray | Mapping[str, Sequence[Any]] | None (default: None)

Key-indexed multi-dimensional variables annotation of length #variables. If passing a numpy.ndarray, it needs to have a structured datatype.

obsp ndarray | Mapping[str, Sequence[Any]] | None (default: None)

Pairwise annotation of observations, a mutable mapping with array-like values.

varp ndarray | Mapping[str, Sequence[Any]] | None (default: None)

Pairwise annotation of variables/features, a mutable mapping with array-like values.

layers Mapping[str, ndarray] | None (default: None)

Key-indexed multi-dimensional #observations × #variables (× #time) data arrays, aligned to dimensions of X.

shape tuple[int, int] | None (default: None)

Shape tuple (#observations, #variables, #time). Can only be provided if X is None.

filename PathLike[str] | str | None (default: None)

Name of backing file. See h5py.File.

filemode Literal['r', 'r+'] | None (default: None)

Open mode of backing file. See h5py.File.

oidx Index1D | None (default: None)

Observation index for initialising as a view.

vidx Index1D | None (default: None)

Variable index for initialising as a view.

tidx Index1D | None (default: None)

Time index for initialising as a view.

Attributes table#

X

A #observations × #variables (× #time) data array.

filename

Change to backing mode by setting the filename of a .h5ed file.

is_view

True if object is view of another EHRData object, False otherwise.

isbacked

True if object is backed on disk, False otherwise.

layers

Key-indexed multi-dimensional #observations × #variables (× #time) data arrays, aligned to dimensions of X.

n_obs

Number of observations.

n_vars

Number of variables/features.

n_t

Number of time points.

obs

One-dimensional annotation of observations (pd.DataFrame).

obs_names

Names of observations (alias for .obs.index).

obsm

Key-indexed multi-dimensional observations annotation of length #observations.

obsp

Pairwise annotation of observations, a mutable mapping with array-like values.

shape

Shape tuple (#observations, #variables, #time).

tem

One-dimensional annotation of time (pd.DataFrame).

uns

Unstructured annotation (ordered dictionary).

var

One-dimensional annotation of variables/ features (pd.DataFrame).

var_names

Names of variables (alias for .var.index).

varm

Key-indexed multi-dimensional variables annotation of length #variables.

varp

Pairwise annotation of variables/features, a mutable mapping with array-like values.

Methods table#

copy()

Returns a copy of the EHRData object.

from_adata(adata, *[, tem, tidx])

Create an EHRData object from an AnnData object.