anndata.acc.MultiAcc#

class anndata.acc.MultiAcc(dim, k, *, ref_class)[source]#

Bases: RefAcc[R, int, MuData | AnnData]

Reference accessor for arrays from multi-dimensional containers (A.obsm/A.varm).

Examples

>>> from anndata.acc import A, MultiAcc
>>> assert isinstance(A.obsm["pca"], MultiAcc)
>>> A.obsm["pca"][:, 0]
A.obsm['pca'][:, 0]

Note that something like this is invalid, as it references an array that isn’t aligned to an anndata dimension.

A.varm["PCs"]["cell-0", :]

Attributes

dim: Literal['obs', 'var'][source]#

Dimension this accessor refers to, e.g. A.obsm[k].dim == 'obs'.

k: str[source]#

Key this accessor refers to, e.g. A.varm['x'].k == 'x'.

ref_class: type[AdRef[Hashable, MuData | AnnData]][source]#

Methods

dims(i, /)[source]#

Get along which dimensions the referenced array is.

Return type:

Collection[Literal['obs', 'var']]

get(data, i=NO_IDX, /)[source]#
Overloads:
  • self, data (MuData | AnnData) → FullArray

  • self, data (MuData | AnnData), i (int) → InMemoryArray

Get the indexed array from the AnnData object at idx.

When idx is omitted (i.e., idx is NO_IDX), return the full array one level up instead. This has the same semantics as the AdRef path but one level up: adata[A.obs] returns the full DataFrame and adata[A.obsm["pca"]] the full numpy.ndarray. These both have defined shape-like properties (or awkward.Array), unlike, for example, obsm or similar.

idx_repr(i)[source]#

Get a string representation of the index.

Return type:

str

isin(data, idx=None)[source]#

Check if the referenced array is in the AnnData object.

Return type:

bool

static process_idx(i, /)[source]#
Return type:

int | list[int] | pd.Index[int]