The tiledbsoma.io module

Functions

Data conversion to/from TileDB-SOMA

tiledbsoma.io.from_h5ad

Reads an .h5ad file and writes it to an Experiment.

tiledbsoma.io.from_anndata

Writes an AnnData object to an Experiment.

tiledbsoma.io.to_h5ad

Converts the experiment group to AnnData format and writes it to the specified .h5ad file.

tiledbsoma.io.to_anndata

Converts the experiment group to AnnData format.

Updating values within a TileDB-SOMA Experiment

tiledbsoma.io.add_X_layer

This is useful for adding X data, for example from Scanpy's scanpy.pp.normalize_total, scanpy.pp.log1p, etc.

tiledbsoma.io.add_matrix_to_collection

This is useful for adding X/obsp/varm/etc data, for example from Scanpy's scanpy.pp.normalize_total, scanpy.pp.log1p, etc.

tiledbsoma.io.create_from_matrix

Create and populate the soma_matrix from the contents of matrix.

tiledbsoma.io.update_obs

Given a new Pandas dataframe with desired contents, updates the SOMA experiment's entire obs to incorporate the changes (this is distinct from append_obs which adds new rows, while allowing no schema/column changes).

tiledbsoma.io.update_var

Given a new Pandas dataframe with desired contents, updates the SOMA experiment's specified measurement's entire var to incorporate the changes (this is distinct from append_var which adds new rows, while allowing no schema/column changes).

tiledbsoma.io.update_matrix

Given a SparseNDArray or DenseNDArray already opened for write, writes the new data.

Growing a TileDB-SOMA Experiment

tiledbsoma.io.register_anndatas

Extends registration data from the baseline, already-written SOMA experiment to include multiple H5AD input files.

tiledbsoma.io.register_h5ads

Extends registration data from the baseline, already-written SOMA experiment to include multiple H5AD input files.

tiledbsoma.io.append_X

Appends new data to an existing X matrix.

tiledbsoma.io.append_obs

Writes new rows to an existing obs dataframe (this is distinct from update_obs which mutates the entirety of the obs dataframe, e.g. to add/remove columns).

tiledbsoma.io.append_var

Writes new rows to an existing var dataframe (this is distinct from update_var which mutates the entirety of the var dataframe, e.g. to add/remove columns).

tiledbsoma.io.get_experiment_shapes

Returns the current shapes of the elements in the Experiment.

tiledbsoma.io.show_experiment_shapes

Outputs the current shapes of the elements in the Experiment.

tiledbsoma.io.upgrade_experiment_shapes

Upgrade the elements inside a SOMA Experiment to use the shape feature introduced in TileDB-SOMA 1.15.

tiledbsoma.io.resize_experiment

Resize the elements in the SOMA Experiment to fit the requested number of observations and variables.

Classes

class tiledbsoma.io.ExperimentAmbientLabelMapping(*, obs_axis: AxisAmbientLabelMapping, var_axes: dict[str, AxisAmbientLabelMapping], prepared: bool = False)

For all the to-be-appended AnnData/H5AD inputs in SOMA multi-file append-mode ingestion, this class contains information required to perform ingestion via from_h5ad or from_anndata.

This class tracks the mapping from input-data obs or var ID-column name (barcode ID, gene symbol) to SOMA join IDs for SOMA experiment obs or var, as well as any dictionary/enumeration values.

Methods

prepare_experiment(experiment_uri[, context])

Prepare experiment for ingestion.

subset_for_anndata(adata)

Return a copy of this object containing only the information necessary to ingest the specified AnnData.

subset_for_h5ad(h5ad_path)

Subset this plan to only contain ID maps useful for this H5AD.