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 accessadata.obsm['X_pca'], you would pass:"X_pca".groupby (
Optional[str]) – Optionally, one may choose to group data according to a cell-specific annotation inadata.obs. This would invoke returningdataasList. - Default:Nonetorch (
Optional[bool]) – indicates whether data should be formatted astorch.Tensor. IfFalse(default),dataformatted asnp.ndarray. - Default:Falsedevice (
Optional[torch.device]) – description. - Default:autodevice.AutoDevice()as_dict (
Optional[bool]) – Only relevant whengroupbyis notNone. Indicates whetherdatashould be returned asDictwhere the key for each value corresponds to the respectivegroupbyvalue or, ifFalse, returnsList. - Default:True
- Returns:
data- Return type:
Union[Tensor,ndarray,List[Union[Tensor,ndarray]],Dict[Union[str, int],Union[Tensor,ndarray]]]