snapatac2.AnnData#

class snapatac2.AnnData(*, filename, X=None, obs=None, var=None, obsm=None, varm=None, uns=None, backend=None)#

An annotated data matrix.

AnnData stores a data matrix X together with annotations of observations obs (obsm, obsp), variables var (varm, varp), and unstructured annotations uns. AnnData is stored as a HDF5 file. Opening/creating an AnnData object does not read data from the HDF5 file. Data is copied to memory only when individual element is requested (or when cache is turned on).

Parameters:
  • X – A #observations × #variables data matrix. A view of the data is used if the data type matches, otherwise, a copy is made.

  • obs – Key-indexed one-dimensional observations annotation of length #observations.

  • var – Key-indexed one-dimensional variables annotation of length #variables.

  • uns – Key-indexed unstructured annotation.

  • obsm – Key-indexed multi-dimensional observations annotation of length #observations. If passing a ndarray, it needs to have a structured datatype.

  • varm – Key-indexed multi-dimensional variables annotation of length #variables. If passing a ndarray, it needs to have a structured datatype.

  • filename – Name of backing file.

Note

This is a backed AnnData. You can use to_memory to convert it to an in-memory AnnData object. See here for the documentation of in-memory AnnData objects.

See also

read, read_mtx, read_csv

Attributes

X

Data matrix of shape n_obs × n_vars.

backend

filename

Filename of the backing .h5ad file.

isbacked

Whether the AnnData object is backed.

layers

n_obs

Number of observations.

n_vars

Number of variables/features.

obs

Observation annotations.

obs_names

Names of observations.

obsm

obsp

shape

Shape of data matrix (n_obs, n_vars).

uns

Unstructured annotation (ordered dictionary).

var

Variable annotations.

var_names

Names of variables.

varm

varp

Methods

chunked_X([chunk_size])

Return an iterator over the rows of the data matrix X.

close()

Close the AnnData object.

copy(filename, backend)

Copy the AnnData object.

is_closed()

If the AnnData object has been closed.

obs_ix(names)

open([mode])

Reopen a closed AnnData object.

subset([obs_indices, var_indices, out, ...])

Subsetting the AnnData object.

to_memory()

Return a new AnnData object with all backed arrays loaded into memory.

var_ix(names)

write(filename, backend)

Write .h5ad-formatted hdf5 file.