ehrdata.io.read_zarr

Contents

ehrdata.io.read_zarr#

ehrdata.io.read_zarr(filename, *, harmonize_missing_values=True, cast_variables_to_float=True)#

Read a zarr store into an EHRData object.

Can also read AnnData Zarr stores. In this case, a default .tem field is created in the ehrdata object.

Parameters:
filename

The filename, or a Zarr storage class.

harmonize_missing_values default: True

Whether to call ehrdata.harmonize_missing_values on all detected layers.

cast_variables_to_float default: True

For non-numeric arrays, try to cast the values for each variable to dtype np.float64. If the cast fails for the values of one variable, then the values of these variable remain unaltered. This can be helpful to recover arrays that were of dtype object when they were written to disk.

Examples

>>> import ehrdata as ed
>>> edata = ed.dt.mimic_2()
>>> ed.io.write_zarr("mimic_2.zarr", edata)
>>> edata_from_zarr = ed.io.read_zarr("mimic_2.zarr")