ehrapy.io.read_h5ad

ehrapy.io.read_h5ad(dataset_path, backup_url=None, download_dataset_name=None, archive_format=None)[source]

Reads or downloads a desired directory of h5ad files or a single h5ad file.

Parameters:
  • dataset_path (Path | str) – Path to the file or directory to read.

  • download_dataset_name (str | None) – Name of the file or directory in case the dataset is downloaded

  • backup_url (str | None) – URL to download the data file(s) from if not yet existing.

Return type:

AnnData | dict[str, AnnData]

Returns:

An AnnData object or a dict with an identifier (the filename, without extension) for each AnnData object in the dict

Examples

>>> import ehrapy as ep
>>> adata = ep.dt.mimic_2(encoded=True)
>>> ep.io.write("mimic_2.h5ad", adata)
>>> adata_2 = ep.io.read_h5ad("mimic_2.h5ad")