anndata.acc.LayerAcc#
- class anndata.acc.LayerAcc[R: AdRef[Idx2D, AnnDataLike]](k, *, ref_class, scope=None)[source]#
Bases:
RefAcc[R,Idx2D,AnnDataLike,AlignedArray,InMemoryArray|ExtensionArray|Variable]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
- 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
- container(data, /)[source]#
Get the AnnData object this accessor indexes into.
That is
dataitself, or the elementscoperefers to indata. Call this inget(),set(), andisin()so your subclass works when nested.Examples
>>> from anndata import AnnData >>> from anndata.acc import A >>> adata = AnnData(shape=(3, 2), uns={"n": AnnData(shape=(5, 4))}) >>> A.obs.container(adata) is adata True >>> A.uns["n"].AD.obs.container(adata) is adata.uns["n"] True
- get(adata, idx=NO_IDX, /)[source]#
Get the indexed array or element from the AnnData object at
idx.- Overloads:
adata (
AnnDataLike), / →AlignedArrayadata (
AnnDataLike), 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(adata, 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: