fetch#

adata_query._core._fetcher.fetch(adata: AnnData, key: str, groupby: str | None = None, torch: bool = False, device: device = device(type='cpu'), as_dict: bool = True, *args, **kwargs) Tensor | ndarray | List[Tensor | ndarray] | Dict[str | int, Tensor | ndarray][source]#

Fetch and format data [over indicated groups] for the desired key.

Parameters:
  • adata (anndata.AnnData) – The [annotated] single-cell data matrix of shape: [n_obs × n_vars]. Rows correspond to cells and columns to genes. [1].

  • key (str) – Key to access a matrix in adata. For example, if you wanted to access adata.obsm['X_pca'], you would pass: "X_pca".

  • groupby (Optional[str]) – Optionally, one may choose to group data according to a cell-specific annotation in adata.obs. This would invoke returning data as List. - Default: None

  • torch (Optional[bool]) – indicates whether data should be formatted as torch.Tensor. If False (default), data formatted as np.ndarray. - Default: False

  • device (Optional[torch.device]) – description. - Default: autodevice.AutoDevice()

  • as_dict (Optional[bool]) – Only relevant when groupby is not None. Indicates whether data should be returned as Dict where the key for each value corresponds to the respective groupby value or, if False, returns List. - Default: True

Returns:

data

Return type:

Union[Tensor,ndarray,List[Union[Tensor,ndarray]],Dict[Union[str, int],Union[Tensor,ndarray]]]