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.

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

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

  • archive_format (Literal['zip', 'tar', 'tar.gz', 'tgz'], default: None) – Whether the downloaded file is an archive.

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")