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 = (), 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) AnnData

Convience wrapper around soma.Experiment query, to build and execute a query, and return it as an anndata.AnnData object.

Parameters:
  • census – The census object, usually returned by cellxgene_census.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 SOMA value_filter syntax.

  • obs_coords – Coordinates for the obs axis, which is indexed by the soma_joinid value. May be an int, a list of int, 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 SOMA value_filter syntax.

  • var_coords – Coordinates for the var axis, which is indexed by the soma_joinid value. May be an int, a list of int, or a slice. The default, None, selects all.

  • column_names – Columns to fetch for obs and var dataframes.

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

Returns:

An anndata.AnnData object containing the census slice.

Lifecycle

maturing

Examples

>>> get_anndata(census, "Mus musculus", obs_value_filter="tissue_general in ['brain', 'lung']")
>>> get_anndata(census, "Homo sapiens", column_names={"obs": ["tissue"]})
>>> get_anndata(census, "Homo sapiens", obs_coords=slice(0, 1000))