tiledbsoma.ExperimentAxisQuery¶
- class tiledbsoma.ExperimentAxisQuery(experiment: ~somacore.query.query._Exp, measurement_name: str, *, obs_query: ~somacore.query.axis.AxisQuery = AxisQuery(value_filter=None, coords=()), var_query: ~somacore.query.axis.AxisQuery = AxisQuery(value_filter=None, coords=()), index_factory: ~typing.Callable[[~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.int64]]], IndexLike] = <class 'pandas.core.indexes.base.Index'>)¶
Axis-based query against a SOMA Experiment.
ExperimentAxisQuery allows easy selection and extraction of data from a single
Measurementin anExperiment, by obs/var (axis) coordinates and/or value filter.The primary use for this class is slicing
ExperimentXlayers by obs or var value and/or coordinates. Slicing onSparseNDArrayXmatrices is supported;DenseNDArrayis not supported at this time.IMPORTANT: this class is not thread-safe.
IMPORTANT: this query class assumes it can store the full result of both axis dataframe queries in memory, and only provides incremental access to the underlying X NDArray. API features such as
n_obsandn_varscodify this in the API.IMPORTANT: you must call
close()on any instance of this class to release underlying resources. The ExperimentAxisQuery is a context manager, and it is recommended that you use the following pattern to make this easy and safe:with ExperimentAxisQuery(...) as query: ...
This base query implementation is designed to work against any SOMA implementation that fulfills the basic APIs. A SOMA implementation may include a custom query implementation optimized for its own use.
Lifecycle: maturing
- __init__(experiment: ~somacore.query.query._Exp, measurement_name: str, *, obs_query: ~somacore.query.axis.AxisQuery = AxisQuery(value_filter=None, coords=()), var_query: ~somacore.query.axis.AxisQuery = AxisQuery(value_filter=None, coords=()), index_factory: ~typing.Callable[[~numpy.ndarray[~typing.Any, ~numpy.dtype[~numpy.int64]]], IndexLike] = <class 'pandas.core.indexes.base.Index'>)¶
Methods
X(layer_name, *[, batch_size, partitions, ...])Returns an
Xlayer as a sparse read.__init__(experiment, measurement_name, *[, ...])close()Releases resources associated with this query.
obs(*[, column_names, batch_size, ...])Returns
obsas an Arrow table iterator.obs_joinids()Returns
obssoma_joinidsas an Arrow array.obsm(layer)Returns an
obsmlayer as a sparse read.obsp(layer)Returns an
obsplayer as a sparse read.to_anndata(X_name, *[, column_names, ...])Executes the query and return result as an
AnnDatain-memory object.var(*[, column_names, batch_size, ...])Returns
varas an Arrow table iterator.var_joinids()Returns
varsoma_joinidsas an Arrow array.varm(layer)Returns a
varmlayer as a sparse read.varp(layer)Returns a
varplayer as a sparse read.Attributes
indexerA
soma_joinidindexer for bothobsandvaraxes.n_obsThe number of
obsaxis query results.n_varsThe number of
varaxis query results.