tiledbsoma.io.to_anndata¶
- tiledbsoma.io.to_anndata(experiment: ~tiledbsoma._experiment.Experiment, measurement_name: str, *, X_layer_name: str | ~tiledbsoma._util.Sentinel | None = <tiledbsoma._util.Sentinel object>, extra_X_layer_names: ~typing.Sequence[str] | ~typing.KeysView[str] | None = None, obs_id_name: str | None = None, var_id_name: str | None = None, obsm_varm_width_hints: dict[str, dict[str, int]] | None = None, uns_keys: ~typing.Sequence[str] | None = None, dask: ~tiledbsoma._dask.util.SOMADaskConfig | None = None) AnnData¶
Converts the experiment group to AnnData format.
The choice of matrix formats is following what we often see in input
.h5adfiles:Xasscipy.sparse.csr_matrixobs,varaspandas.dataframeobsm,varmarrays asnumpy.ndarrayobsp,varparrays asscipy.sparse.csr_matrix
The
X_layer_nameis the name of the TileDB-SOMA measurement’sXcollection which will be outgested to the resulting AnnData object’sadata.X. IfX_layer_nameis unspecified, and the Measurement contains an X layer named “data”, it will be returned. IfX_layer_nameisNone, then the return value’sadata.Xwill be None, andadata.layerswill be unpopulated. IfX_layer_nameis a string, thenadata.Xwill be taken from this layer name within the input measurement, and it will be an error if the measurement’sXdoes not contain that layer name.The
extra_X_layer_namesare used to specify how the outputadataobject’sadata.layersis populated. The default behavior –extra_X_layer_namesbeingNone– means thatadata.layerswill be empty. Ifextra_X_layer_namesis a provided list these will be used for populatingadata.layers. If you want all the layers to be outgested, without having to name them individually, you can useextra_X_layer_names=experiment.ms[measurement_name].X.keys(). To make this low-friction for you, we introduce one more feature: we’ll ignoreX_layer_namewhen populatingadata.layers. For example, if X keys are"a","b","c","d", and you sayX_layer_name="b"andextra_X_layer_names=experiment.ms[measurement_name].X.keys(), we’ll not write"b"toadata.layers.The
obs_id_nameandvar_id_nameare columns within the TileDB-SOMA experiment which will become index names within the resulting AnnData object’sobs/vardataframes. If not specified as arguments, the TileDB-SOMA’s dataframes will be checked for an original-index-name key. When that also is unavailable, these default to"obs_id"and"var_id", respectively.The
obsm_varm_width_hintsis optional. If provided, it should be of the form{"obsm":{"X_tSNE":2}}to aid with export errors.If
uns_keysis provided, only the specified top-levelunskeys are extracted. The default is to extract them all. Useuns_keys=[]to not outgest anyunskeys.If
daskis present, theXmatrix is returned as a Dask array, and thedaskconfigs apply to that conversion and resulting array (lifecycle: experimental).Lifecycle
Maturing.