ehrapy.io.write#
- ehrapy.io.write(filename, adata, extension=None, compression='gzip', compression_opts=None)[source]#
Write
AnnData
objects to file. It is possbile to either write anAnnData
object to a .csv file or a .h5ad file. The .h5ad file can be used as a cache to save the current state of the object and to retrieve it faster once needed. This preserves the object state at the time of writing. It is possible to write both, encoded and unencoded objects.- Parameters:
filename (
str
|Path
) – File name or path to write the file toadata (
AnnData
) – Annotated data matrix.extension (
Union
[str
,bool
,None
]) – File extension. One of h5ad, csvcompression (
Optional
[Literal
['gzip'
,'lzf'
]]) – Optional file compression. One of gzip, lzfcompression_opts (
Optional
[int
]) – See http://docs.h5py.org/en/latest/high/dataset.html.
- Return type:
Examples
>>> import ehrapy as ep >>> adata = ep.dt.mimic_2(encoded=True) >>> ep.io.write("mimic_2.h5ad", adata)