tacco.utils.AnnData_query¶
- AnnData_query(self, expr, **kw_args)[source]¶
Query the columns of .obs of an
AnnDatawith a boolean expression and use the result to subset theAnnData. This provides a convenient shorthand notation for subsetting: E.g. adata.query(‘A>4 & B==@value’) effectively expands to adata[(adata.obs[‘A’]>4) & (adata.obs[‘B’]==value)]. This is analogous to the functionality ofpandas.DataFrame.query()and implemented bypandas.DataFrame.eval(), so similar restrictions apply. This function is implemented as a monkey patch and should be called as a method of anAnnDatainstance.- Parameters:
expr – The query on .obs columns to subset an
AnnData. Column names and literals are referenced directly, variables in python scope by a preceeding “@”.**kw_args – Additional keyword arguments are forwarded to the call to
pandas.DataFrame.eval().
- Returns:
Returns a view of the subsetted
AnnDatainstance.