scanpy.write

Contents

scanpy.write#

scanpy.write(filename, adata, *, ext=None, convert_strings_to_categoricals=True, compression='gzip', compression_opts=None)[source]#

Write AnnData objects to file.

Parameters:
filename PathLike[str] | str

If the filename has no file extension, it is interpreted as a key for generating a filename via sc.settings.writedir / (filename + sc.settings.file_format_data). This is the same behavior as in read().

adata AnnData

Annotated data matrix.

ext Union[Literal['h5ad', 'zarr'], Literal['csv'], None] (default: None)

File extension from which to infer file format. If None, defaults to sc.settings.file_format_data.

convert_strings_to_categoricals bool (default: True)

If anndata supports it, setting this to False will avoid converting string columns to categorical arrays when writing.

compression Optional[Literal['gzip', 'lzf']] (default: 'gzip')

See https://docs.h5py.org/en/latest/high/dataset.html.

compression_opts int | None (default: None)

See https://docs.h5py.org/en/latest/high/dataset.html.

Return type:

None