anndata.acc.DFAcc#
- class anndata.acc.DFAcc[R: AdRef](*, ref_class, scope=None, frame_acc=None)[source]#
Bases:
RefAcc[R,str|None,AnnDataLikeMetadataOnly,DataFrame|Dataset2D,InMemoryArray|ExtensionArray|Variable]Reference accessor for columns of a data frame in an AnnData object.
Created by casting another accessor to a data frame (
.DF), which becomes itsframe_acc.MetaAcc(A.obs/A.var) is a subclass.Examples
>>> from anndata.acc import A, DFAcc >>> assert isinstance(A.obsm["df"].DF, DFAcc) >>> A.obsm["df"].DF["col"] A.obsm['df'].DF['col'] >>> A.uns["df"].DF.index A.uns['df'].DF.index
Attributes
- frame_acc: RefAcc | None = None[source]#
Accessor for the data frame this
.DFcast refers into, e.g.A.obsm['df']forA.obsm['df'].DF.
- 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(k, /)[source]#
Get along which dimensions the referenced array is.
- Return type:
Collection[Literal['obs','var']]
- frame(data, /)[source]#
Get the data frame this accessor refers to.
get(),set(), andisin()use this, so subclasses only need to override this to refer to another frame (e.g.MetaAccreturns.obs/.varofcontainer()).
- get(data, k=NO_IDX, /)[source]#
Get the indexed array or element from the AnnData object at
idx.- Overloads:
data (
AnnDataLikeMetadataOnly), / →DataFrame|Dataset2Ddata (
AnnDataLikeMetadataOnly), k (str|None), / →ExtensionArray|Variable
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: