Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose main properties of anndata (or mudata) to base dance data #282

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
hooks:
- id: docformatter
name: Format docstring
args: [--config, ./pyproject.toml]
args: [--config, pyproject.toml]

- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
Expand Down
9 changes: 9 additions & 0 deletions dance/data/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]] = {}
Expand Down