cellxgene_census.get_anndata
- cellxgene_census.get_anndata(census: Collection, organism: str, measurement_name: str = 'RNA', X_name: str = 'raw', X_layers: Sequence[str] | None = (), obsm_layers: Sequence[str] | None = (), obsp_layers: Sequence[str] | None = (), varm_layers: Sequence[str] | None = (), varp_layers: Sequence[str] | None = (), obs_value_filter: str | None = None, obs_coords: None | bytes | Slice[bytes] | Sequence[bytes] | float | Slice[float] | Sequence[float] | int | Slice[int] | Sequence[int] | slice | Slice[slice] | Sequence[slice] | str | Slice[str] | Sequence[str] | datetime64 | Slice[datetime64] | Sequence[datetime64] | TimestampType | Slice[TimestampType] | Sequence[TimestampType] | Array | ChunkedArray | ndarray[Any, dtype[integer]] | ndarray[Any, dtype[datetime64]] = None, var_value_filter: str | None = None, var_coords: None | bytes | Slice[bytes] | Sequence[bytes] | float | Slice[float] | Sequence[float] | int | Slice[int] | Sequence[int] | slice | Slice[slice] | Sequence[slice] | str | Slice[str] | Sequence[str] | datetime64 | Slice[datetime64] | Sequence[datetime64] | TimestampType | Slice[TimestampType] | Sequence[TimestampType] | Array | ChunkedArray | ndarray[Any, dtype[integer]] | ndarray[Any, dtype[datetime64]] = None, column_names: AxisColumnNames | None = None, obs_embeddings: Sequence[str] | None = (), var_embeddings: Sequence[str] | None = (), obs_column_names: Sequence[str] | None = None, var_column_names: Sequence[str] | None = None) AnnData
Convenience wrapper around
tiledbsoma.Experiment
query, to build and execute a query, and return it as ananndata.AnnData
object.- Parameters:
census – The census object, usually returned by
open_soma()
.organism – The organism to query, usually one of
"Homo sapiens
or"Mus musculus"
.measurement_name – The measurement object to query. Defaults to
"RNA"
.X_name – The
X
layer to query. Defaults to"raw"
.X_layers – Additional layers to add to
anndata.AnnData.layers
.obs_value_filter – Value filter for the
obs
metadata. Value is a filter query written in the SOMAvalue_filter
syntax.obs_coords – Coordinates for the
obs
axis, which is indexed by thesoma_joinid
value. May be anint
, a list ofint
, or a slice. The default,None
, selects all.var_value_filter – Value filter for the
var
metadata. Value is a filter query written in the SOMAvalue_filter
syntax.var_coords – Coordinates for the
var
axis, which is indexed by thesoma_joinid
value. May be anint
, a list ofint
, or a slice. The default,None
, selects all.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.obs_embeddings – Additional embeddings to be returned as part of the
obsm
slot. Useget_all_available_embeddings()
to retrieve available embeddings for this Census version and organism.var_embeddings – Additional embeddings to be returned as part of the
varm
slot. Useget_all_available_embeddings()
to retrieve available embeddings for this Census version and organism.obs_column_names – Columns to fetch for
obs
dataframe.var_column_names – Columns to fetch for
var
dataframe.
- Returns:
An
anndata.AnnData
object containing the census slice.
Lifecycle
experimental
Examples
>>> get_anndata(census, "Mus musculus", obs_value_filter="tissue_general in ['brain', 'lung']")
>>> get_anndata(census, "Homo sapiens", obs_column_names=["tissue"])
>>> get_anndata(census, "Homo sapiens", obs_coords=slice(0, 1000))