From e5358987f19aaacbc961557b1b7227ce0fd30eae Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 23 Jun 2023 18:00:04 -0400 Subject: [PATCH 1/2] expose main properties of anndata (or mudata) to the base dance data object --- .pre-commit-config.yaml | 2 +- dance/data/base.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53fab540..1ad58a18 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: hooks: - id: docformatter name: Format docstring - args: [--config, ./pyproject.toml] + args: [--wrap-summaries, "88", --wrap-descriptions, "88", --in-place, --blank] - repo: https://github.com/executablebooks/mdformat rev: 0.7.16 diff --git a/dance/data/base.py b/dance/data/base.py index ed0df664..c6cb2abf 100644 --- a/dance/data/base.py +++ b/dance/data/base.py @@ -55,6 +55,11 @@ class BaseData(ABC): >>> adata = anndata.AnnData(...) >>> ddata = dance.data.Data(adata.copy()) + Note + ---- + You can directly access some main properties of :class:`~anndata.AnnData` (or :class:`~mudata.MuData` depending on + which type of data you passed in), such as ``X``, ``obs``, ``var``, and etc. + Parameters ---------- data @@ -77,7 +82,11 @@ def __init__(self, data: Union[anndata.AnnData, mudata.MuData], train_size: Opti full_split_name: Optional[str] = None): super().__init__() + # Store data and pass through some main properties over self._data = data + for prop in self._DATA_CHANNELS + ["X"]: + assert not hasattr(self, prop) + setattr(self, prop, getattr(data, prop)) # TODO: move _split_idx_dict into data.uns self._split_idx_dict: Dict[str, Sequence[int]] = {} From 84804c9eb11d94071139d009e404ab588cdd478b Mon Sep 17 00:00:00 2001 From: Remy Date: Fri, 23 Jun 2023 18:01:07 -0400 Subject: [PATCH 2/2] expose main properties of anndata (or mudata) to the base dance data object --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1ad58a18..dc35161a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,7 +37,7 @@ repos: hooks: - id: docformatter name: Format docstring - args: [--wrap-summaries, "88", --wrap-descriptions, "88", --in-place, --blank] + args: [--config, pyproject.toml] - repo: https://github.com/executablebooks/mdformat rev: 0.7.16