anndata.acc.GraphAcc#

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

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

Reference accessor for arrays from graph containers (A.obsp/A.varp).

Examples

>>> from anndata.acc import A, GraphAcc
>>> assert isinstance(A.obsp["distances"], GraphAcc)
>>> A.obsp["distances"][:, "cell-1"]
A.obsp['distances'][:, 'cell-1']

Attributes

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

Axis this accessor refers to, e.g. A.varp[k].dim == "var".

k: str[source]#

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

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

Methods

dims(idx, /)[source]#

Get along which dimensions the referenced array is.

Return type:

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

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

  • self, data (MuData | 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(data, idx=None)[source]#

Check if the referenced array is in the AnnData object.

Return type:

bool

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

tuple[str | slice, slice] | tuple[slice, str | slice]