Perform an axis-based query against a SOMAExperiment.
SOMAExperimentAxisQuery allows easy selection and extraction of data from a
single SOMAMeasurement in a SOMAExperiment, by obs/var (axis)
coordinates and/or value filter. The primary use for this class is slicing
SOMAExperiment X layers by obs or var value and/or coordinates.
(lifecycle: maturing)
X Layer Support
Slicing on SOMASparseNDArray X matrices is supported;
slicing on SOMADenseNDArray is not supported at this time.
Active bindings
experimentThe parent
SOMAExperimentobject.indexerThe
SOMAAxisIndexerobject.obs_queryThe
obsSOMAAxisQueryobject.var_queryThe
varSOMAAxisQueryobject.n_obsThe number of
obsaxis query results.n_varsThe number of
varaxis query results.obs_dfThe
obsSOMADataFrameobject.var_dfThe
varSOMADataFrameobject for the specifiedmeasurement_name.msThe
SOMAMeasurementobject for the specifiedmeasurement_name.
Methods
Method new()
Create a new SOMAExperimentAxisQuery object.
Usage
SOMAExperimentAxisQuery$new(
  experiment,
  measurement_name,
  obs_query = NULL,
  var_query = NULL
)Arguments
experimentA
SOMAExperimentobject.measurement_nameThe name of the measurement to query.
obs_query, var_queryAn
SOMAAxisQueryobject for the obs/var axis.
Method obs()
Retrieve obs TableReadIter
Method var()
Retrieve var arrow::Table
Method obs_joinids()
Retrieve soma_joinids as an arrow::Array for obs.
Method var_joinids()
Retrieve soma_joinids as an arrow::Array for var.
Method X()
Retrieves an X layer as a SOMASparseNDArrayRead
Method obsm()
Retrieves an obsm layer as a
SOMASparseNDArrayRead
Method varm()
Retrieves a varm layer as a
SOMASparseNDArrayRead
Method obsp()
Retrieves an obsp layer as a
SOMASparseNDArrayRead
Method varp()
Retrieves a varp layer as a
SOMASparseNDArrayRead
Method read()
Reads the entire query result as a list of
arrow::Tables. This is a low-level routine intended to be used by
loaders for other in-core formats, such as Seurat, which can be created
from the resulting Tables.
Method to_sparse_matrix()
Retrieve a collection layer as a sparse matrix with named dimensions.
Load any layer from the X, obsm, varm, obsp, or varp
collections as a sparse matrix.
By default the matrix dimensions are named using the soma_joinid values
in the specified layer's dimensions (e.g., soma_dim_0). However,
dimensions can be named using values from any obs or var column that
uniquely identifies each record by specifying the obs_index and
var_index arguments.
For layers in obsm or varm, the column axis (the axis not
indexed by “obs” or “var”) is set to the
range of values present in “soma_dim_1”; this ensures
that gaps in this axis are preserved (eg. when a query for
“obs” that results in selecting entries that are all zero
for a given PC)
Usage
SOMAExperimentAxisQuery$to_sparse_matrix(
  collection,
  layer_name,
  obs_index = NULL,
  var_index = NULL
)Arguments
collectionThe
SOMACollectioncontaining the layer of interest, either:"X","obsm","varm","obsp", or"varp".layer_nameName of the layer to retrieve from the
collection.obs_index, var_indexName of the column in
obsorvar(var_index) containing values that should be used as dimension labels in the resulting matrix. Whether the values are used as row or column labels depends on the selectedcollection:Collection obs_indexvar_indexXrow names column names obsmrow names ignored varmignored row names obsprow and column names ignored varpignored row and column names 
Method to_seurat()
Loads the query as a
Seurat object
Usage
SOMAExperimentAxisQuery$to_seurat(
  X_layers = c(counts = "counts", data = "logcounts"),
  obs_index = NULL,
  var_index = NULL,
  obs_column_names = NULL,
  var_column_names = NULL,
  obsm_layers = NULL,
  varm_layers = NULL,
  obsp_layers = NULL,
  drop_levels = FALSE,
  version = NULL
)Arguments
X_layersA named character of X layers to add to the Seurat assay where the names are the names of Seurat slots and the values are the names of layers within
X; names should be one of:“
counts” to add the layer ascounts“
data” to add the layer asdata“
scale.data” to add the layer asscale.data
At least one of “
counts” or “data” is requiredobs_indexName of column in
obsto add as cell names; usespaste0("cell", obs_joinids())by defaultvar_indexName of column in
varto add as feature names; usespaste0("feature", var_joinids())by defaultobs_column_namesNames of columns in
obsto add as cell-level meta data; by default, loads all columnsvar_column_namesNames of columns in
varto add as feature-level meta data; by default, loads all columnsobsm_layersNames of arrays in
obsmto add as the cell embeddings; passFALSEto suppress loading in any dimensional reductions; by default, loads all dimensional reduction informationvarm_layersNamed vector of arrays in
varmto load in as the feature loadings; names must be names of arrays inobsm(eg.varm_layers = c(X_pca = "PCs")); passFALSEto suppress loading in any feature loadings; will try to determinevarm_layersfromobsm_layersobsp_layersNames of arrays in
obspto load in asGraphs; by default, loads all graphsdrop_levelsDrop unused levels from
obsandvarfactor columnsversionAssay version to read query in as; by default, will try to infer assay type from the measurement itself
Returns
A Seurat object
Method to_seurat_assay()
Loads the query as a Seurat Assay
Usage
SOMAExperimentAxisQuery$to_seurat_assay(
  X_layers = c(counts = "counts", data = "logcounts"),
  obs_index = NULL,
  var_index = NULL,
  var_column_names = NULL,
  drop_levels = FALSE,
  version = NULL
)Arguments
X_layersA named character of X layers to add to the Seurat assay where the names are the names of Seurat slots and the values are the names of layers within
X; names should be one of:“
counts” to add the layer ascounts“
data” to add the layer asdata“
scale.data” to add the layer asscale.data
At least one of “
counts” or “data” is requiredobs_indexName of column in
obsto add as cell names; usespaste0("cell", obs_joinids())by defaultvar_indexName of column in
varto add as feature names; usespaste0("feature", var_joinids())by defaultvar_column_namesNames of columns in
varto add as feature-level meta data; by default, loads all columnsdrop_levelsDrop unused levels from
varfactor columnsversionAssay version to read query in as; by default, will try to infer assay type from the measurement itself
Returns
An Assay object
Method to_seurat_reduction()
Loads the query as a Seurat dimensional reduction
Usage
SOMAExperimentAxisQuery$to_seurat_reduction(
  obsm_layer,
  varm_layer = NULL,
  obs_index = NULL,
  var_index = NULL
)Arguments
obsm_layerName of array in
obsmto load as the cell embeddingsvarm_layerName of the array in
varmto load as the feature loadings; by default, will try to determinevarm_layerfromobsm_layerobs_indexName of column in
obsto add as cell names; usespaste0("cell", obs_joinids())by defaultvar_indexName of column in
varto add as feature names; usespaste0("feature", var_joinids())by default
Returns
A DimReduc object
Method to_seurat_graph()
Loads the query as a Seurat graph
Arguments
obsp_layerName of array in
obspto load as the graphobs_indexName of column in
obsto add as cell names; usespaste0("cell", obs_joinids())by default
Returns
A Graph object
Method to_single_cell_experiment()
Loads the query as a
SingleCellExperiment object
Usage
SOMAExperimentAxisQuery$to_single_cell_experiment(
  X_layers = NULL,
  obs_index = NULL,
  var_index = NULL,
  obs_column_names = NULL,
  var_column_names = NULL,
  obsm_layers = NULL,
  obsp_layers = NULL,
  varp_layers = NULL,
  drop_levels = FALSE
)Arguments
X_layersA character vector of X layers to add as assays in the main experiment; may optionally be named to set the name of the resulting assay (eg.
X_layers = c(counts = "raw")will load in X layer “raw” as assay “counts”); by default, loads in all X layersobs_indexName of column in
obsto add as cell names; usespaste0("cell", obs_joinids())by defaultvar_indexName of column in
varto add as feature names; usespaste0("feature", var_joinids())by defaultobs_column_namesNames of columns in
obsto add ascolData; by default, loads all columnsvar_column_namesNames of columns in
varto add asrowData; by default, loads all columnsobsm_layersNames of arrays in
obsmto add as the reduced dimensions; passFALSEto suppress loading in any reduced dimensions; by default, loads all reduced dimensionsobsp_layersNames of arrays in
obspto load in asSelfHits; by default, loads all graphsvarp_layersNames of arrays in
varpto load in asSelfHits; by default, loads all networksdrop_levelsDrop unused levels from
obsandvarfactor columns