anndata.acc.GraphAcc#
- class anndata.acc.GraphAcc[R: AdRef[Idx2D, AnnDataLikeMetadataOnly]](dim, k, *, ref_class, scope=None)[source]#
Bases:
RefAcc[R,Idx2D,AnnDataLikeMetadataOnly,AlignedArray,InMemoryArray|ExtensionArray|Variable]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
- scope: ScopeAcc | None = None#
Accessor for the element whose
.ADcast this accessor is in, e.g.A.uns['a']forA.uns['a'].AD.obsm['x'].DF.If
None, this accessor refers into the object passed toget()/set()/isin()itself.
Methods
- dims(idx, /)[source]#
Get along which dimensions the referenced array is.
- Return type:
Collection[Literal['obs','var']]
- get(data, idx=NO_IDX, /)[source]#
Get the indexed array or element from the AnnData object at
idx.- Overloads:
data (
AnnDataLikeMetadataOnly), / →AlignedArraydata (
AnnDataLikeMetadataOnly), idx (Idx2D), / →InMemoryArray
When
idxis omitted (i.e.,idxisNO_IDX), return the full array one level up instead. This has the same semantics as theAdRefpath but one level up:adata[A.obs]returns the fullDataFrame,adata[A.obsm["pca"]]the fullnumpy.ndarray, andadata[A.layers]the fullMapping. The first two both have definedshape-like properties (orawkward.Array), butlayersor similar do not.
- isin(data, idx=None)[source]#
Check if the referenced array is in the AnnData object.
Returns
Falseifscope(orframe_acc) isn’t indataor doesn’t have the type this accessor casts it to (.AD/.DF).The base implementation only checks
scope. Subclasses should returnFalseifsuper().isin(data, idx)does, socontainer()won’t fail afterwards.- Return type: