tiledbsoma.ExperimentAxisQuery.to_anndata

ExperimentAxisQuery.to_anndata(X_name: str | ~tiledbsoma._util.Sentinel | None = <tiledbsoma._util.Sentinel object>, *, column_names: ~somacore.query.query.AxisColumnNames | None = None, X_layers: ~collections.abc.Sequence[str] = (), obsm_layers: ~collections.abc.Sequence[str] = (), obsp_layers: ~collections.abc.Sequence[str] = (), varm_layers: ~collections.abc.Sequence[str] = (), varp_layers: ~collections.abc.Sequence[str] = (), drop_levels: bool = False, dask: ~tiledbsoma._dask.util.SOMADaskConfig | None = None, obs_id_name: str | None = None, var_id_name: str | None = None) AnnData

Exports the query to an in-memory AnnData object.

Parameters:
  • X_name – The X layer to read and return in the X slot. If unspecified (default), and the measurement contains an X layer named "data", it will be used. If None, the returned AnnData will have X=None and layers will be unpopulated. If a string, that layer must exist in the measurement X collection.

  • column_names – The columns in the var and obs dataframes to read.

  • X_layers – Additional X layers to read and return in the layers slot.

  • obsm_layers – Additional obsm layers to read and return in the obsm slot.

  • obsp_layers – Additional obsp layers to read and return in the obsp slot.

  • varm_layers – Additional varm layers to read and return in the varm slot.

  • varp_layers – Additional varp layers to read and return in the varp slot.

  • drop_levels – If true, drop unused categories from the obs and var dataframes. Defaults to False.

  • dask – If not None, load the X layer as a Dask array. See DaskConfig for details.

  • obs_id_name – If specified, set this column as the index in the obs dataframe. If not specified, the default index column (see Notes below) will be determined, and set as the dataframe index.

  • var_id_name – If specified, set this column as the index in the obs dataframe. If not specified, the default index column (see Notes below) will be determined, and set as the dataframe index.

Notes: The default index column for the obs and var dataframes is determined with the following algorithm:

  • if the index column name is explicitly specified (e.g., via obs_id_name), it will be used as the index.

  • if the original index column was written to the DataFrame metadata (e.g., during ingestion from AnnData), this will be used as the index.

  • if the dataframe contains a column named obs_id (for obs) or var_id (for var), this will be used as the index.

  • otherwise, the default Pandas index will be used.

Lifecycle: experimental