anndata.acc.LayerAcc#

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

Bases: RefAcc[R, Idx2D, AnnData]

Reference accessor for arrays in layers (A.layers).

Examples

>>> from anndata.acc import A, LayerAcc
>>> assert isinstance(A.layers["counts"], LayerAcc)
>>> A.layers["counts"]["cell-1", :]
A.layers['counts']['cell-1', :]

Attributes

k: str | None[source]#

Key this accessor refers to, e.g. A.layers['counts'].k == 'counts'.

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

Methods

dims(idx, /)[source]#

Get along which dimensions the referenced array is.

Return type:

set[Literal['obs', 'var']]

get(adata, idx=NO_IDX, /)[source]#
Overloads:
  • self, adata (AnnData) → _XDataType

  • self, adata (AnnData), idx (Idx2D) → 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(idx)[source]#

Get a string representation of the index.

Return type:

str

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

Check if the referenced array is in the AnnData object.

Return type:

bool