tiledbsoma.io.to_anndata¶
- tiledbsoma.io.to_anndata(experiment: Experiment, measurement_name: str, *, X_layer_name: str | None = 'data', extra_X_layer_names: Sequence[str] | 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: Sequence[str] | None = None) AnnData¶
Converts the experiment group to AnnData format. Choice of matrix formats is following what we often see in input
.h5adfiles:Xasscipy.sparse.csr_matrixobs,``var`` aspandas.dataframeobsm,``varm`` arrays asnumpy.ndarrayobsp,``varp`` arrays 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. If this isNone, then the return value’sadata.Xwill be None, andadata.layerswill be unpopulated. If this is notNone, thenadata.Xwill be taken from this layer name within the input measurement.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 ingest anyunskeys.Lifecycle
Maturing.