anndata.acc.ItemAcc#
- class anndata.acc.ItemAcc[R: AdRef](path, *, ref_class, scope=None)[source]#
Bases:
ScopeAcc[R,AnnDataLikeMetadataOnly]Accessor for (possibly nested) items in
.uns(A.uns[k]).Indexing it with a key descends further into the item (treating it as a mapping). It can’t create references itself, as items in
.unsaren’t aligned to any dimension, but it can be cast into a type with arrays inside (.AD,.DF).Examples
>>> from anndata.acc import A, ItemAcc >>> assert isinstance(A.uns["foo"], ItemAcc) >>> A.uns["foo"]["bar"] A.uns['foo']['bar'] >>> A.uns["baz"].AD.obs["x"] A.uns['baz'].AD.obs['x'] >>> A.uns["df"].DF["col"] A.uns['df'].DF['col']
Attributes
- property AD: AdAcc[R][source]#
Treat the item as a nested AnnData object, e.g.
A.uns['a'].AD.obs['x'].
- 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']]
- 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: