API#

The central class:

AnnData([X, obs, var, uns, obsm, varm, ...])

An annotated data matrix.

Combining#

Combining AnnData objects. See also the section on concatenation.

concat(adatas, *[, axis, join, merge, ...])

Concatenates AnnData objects along an axis.

Reading#

Reading anndata’s native formats .h5ad and zarr.

io.read_h5ad(filename[, backed, as_sparse, ...])

Read .h5ad-formatted hdf5 file.

io.read_zarr(store)

Read from a hierarchical Zarr array store.

Reading individual portions (obs, varm etc.) of the AnnData object.

io.read_elem(elem)

Read an element from a store.

io.sparse_dataset(group)

Generates a backed mode-compatible sparse dataset class.

Reading file formats that cannot represent all aspects of AnnData objects.

Tip

You might have more success by assembling the AnnData object yourself from the individual parts.

io.read_csv(filename[, delimiter, ...])

Read .csv file.

io.read_excel(filename, sheet[, dtype])

Read .xlsx (Excel) file.

io.read_hdf(filename, key)

Read .h5 (hdf5) file.

io.read_loom(filename, *[, sparse, cleanup, ...])

Read .loom-formatted hdf5 file.

io.read_mtx(filename[, dtype])

Read .mtx file.

io.read_text(filename[, delimiter, ...])

Read .txt, .tab, .data (text) file.

io.read_umi_tools(filename[, dtype])

Read a gzipped condensed count matrix from umi_tools.

Writing#

Writing a complete AnnData object to disk in anndata’s native formats .h5ad and zarr.

AnnData.write([filename, compression, ...])

Write .h5ad-formatted hdf5 file.

AnnData.write_zarr(store[, chunks])

Write a hierarchical Zarr array store.

Writing individual portions (obs, varm etc.) of the AnnData object.

io.write_elem(store, k, elem, *[, ...])

Write an element to a storage group using anndata encoding.

Writing formats that cannot represent all aspects of AnnData objects.

AnnData.write_csvs(dirname[, skip_data, sep])

Write annotation to .csv files.

AnnData.write_loom(filename[, write_obsm_varm])

Write .loom-formatted hdf5 file.

Experimental API#

Warning

APIs in the experimental module are currently in development and subject to change at any time.

Two classes for working with batched access to collections of many AnnData objects or .h5ad files. In particular, for pytorch-based models.

experimental.AnnCollection(adatas[, ...])

Lazily concatenate AnnData objects along the obs axis.

experimental.AnnLoader(adatas[, batch_size, ...])

PyTorch DataLoader for AnnData objects.

Out of core concatenation

experimental.concat_on_disk(in_files, ...[, ...])

Concatenates multiple AnnData objects along a specified axis using their corresponding stores or paths, and writes the resulting AnnData object to a target location on disk.

Low level methods for reading and writing elements of an AnnData object to a store:

experimental.read_elem_as_dask(elem[, chunks])

Read an element from a store lazily.

Utilities for customizing the IO process:

experimental.read_dispatched(elem, callback)

Read elem, calling the callback at each sub-element.

experimental.write_dispatched(store, key, ...)

Write elem to store, recursively calling callback at each sub-element.

Types used by the former:

Errors and warnings#

ImplicitModificationWarning

Raised whenever initializing an object or assigning a property changes the type of a part of a parameter or the value being assigned.

Settings#

settings

This manager allows users to customize settings for the anndata package.

settings.override(**overrides)

Provides local override via keyword arguments as a context manager.

Custom Types/Classes for Readable/Writeable Elements#

abc.CSRDataset()

On disk CSR sparse matrix.

abc.CSCDataset()

On disk CSC sparse matrix.

typing.Index

1D or 2D index an AnnData object can be sliced with.

typing.AxisStorable

A serializable object, excluding anndata.AnnData objects i.e., something that can be stored in uns or obsm.

typing.RWAble

A superset of anndata.typing.AxisStorable (i.e., including anndata.AnnData) which is everything can be read/written by anndata.io.read_elem() and anndata.io.write_elem().