donordata 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- donordata-0.1.0/.github/workflows/build.yaml +28 -0
- donordata-0.1.0/.github/workflows/release.yaml +28 -0
- donordata-0.1.0/.github/workflows/run_notebooks.yaml +37 -0
- donordata-0.1.0/.github/workflows/test.yaml +138 -0
- donordata-0.1.0/.gitignore +28 -0
- donordata-0.1.0/.pre-commit-config.yaml +32 -0
- donordata-0.1.0/.readthedocs.yaml +14 -0
- donordata-0.1.0/CHANGELOG.md +77 -0
- donordata-0.1.0/CITATION.cff +12 -0
- donordata-0.1.0/DESIGN.md +37 -0
- donordata-0.1.0/LICENSE +201 -0
- donordata-0.1.0/PKG-INFO +375 -0
- donordata-0.1.0/README.md +118 -0
- donordata-0.1.0/ci/min_deps.py +26 -0
- donordata-0.1.0/docs/_static/img/donordata_logo.png +0 -0
- donordata-0.1.0/docs/_static/img/donordata_logo.svg +1 -0
- donordata-0.1.0/docs/_static/img/donordata_logo_dark.svg +1 -0
- donordata-0.1.0/docs/_static/img/donordata_logo_mark.svg +1 -0
- donordata-0.1.0/docs/_static/img/donordata_overview.png +0 -0
- donordata-0.1.0/docs/_static/img/donordata_schema.png +0 -0
- donordata-0.1.0/docs/_templates/autosummary/class.rst +59 -0
- donordata-0.1.0/docs/api.md +101 -0
- donordata-0.1.0/docs/changelog.md +2 -0
- donordata-0.1.0/docs/conf.py +77 -0
- donordata-0.1.0/docs/index.md +27 -0
- donordata-0.1.0/docs/install.md +42 -0
- donordata-0.1.0/docs/io/spec.md +132 -0
- donordata-0.1.0/docs/tutorials/ehr_cohort.ipynb +871 -0
- donordata-0.1.0/docs/tutorials/getting_started.ipynb +1431 -0
- donordata-0.1.0/docs/tutorials/patient_cohort.ipynb +2224 -0
- donordata-0.1.0/docs/tutorials/perturbation_screen.ipynb +1267 -0
- donordata-0.1.0/pyproject.toml +183 -0
- donordata-0.1.0/src/donordata/__init__.py +26 -0
- donordata-0.1.0/src/donordata/_core/__init__.py +0 -0
- donordata-0.1.0/src/donordata/_core/_getter.py +110 -0
- donordata-0.1.0/src/donordata/_core/_namespace.py +56 -0
- donordata-0.1.0/src/donordata/_core/_repr.py +112 -0
- donordata-0.1.0/src/donordata/_core/_utils.py +501 -0
- donordata-0.1.0/src/donordata/_core/_write.py +279 -0
- donordata-0.1.0/src/donordata/_core/donordata.py +1953 -0
- donordata-0.1.0/src/donordata/_core/fields.py +33 -0
- donordata-0.1.0/src/donordata/_core/io.py +254 -0
- donordata-0.1.0/src/donordata/_core/merge.py +120 -0
- donordata-0.1.0/src/donordata/_core/schema.py +73 -0
- donordata-0.1.0/src/donordata/io.py +3 -0
- donordata-0.1.0/src/donordata/ml/__init__.py +3 -0
- donordata-0.1.0/src/donordata/ml/_dataset.py +335 -0
- donordata-0.1.0/src/donordata/pp.py +128 -0
- donordata-0.1.0/tests/conftest.py +111 -0
- donordata-0.1.0/tests/test_donordata.py +1024 -0
- donordata-0.1.0/tests/test_io.py +418 -0
- donordata-0.1.0/tests/test_levels.py +407 -0
- donordata-0.1.0/tests/test_merge_pp.py +92 -0
- donordata-0.1.0/tests/test_missing_ids.py +305 -0
- donordata-0.1.0/tests/test_ml.py +100 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Check Build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
package:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.12"
|
|
21
|
+
cache: "pip"
|
|
22
|
+
cache-dependency-path: "**/pyproject.toml"
|
|
23
|
+
- name: Install build dependencies
|
|
24
|
+
run: python -m pip install --upgrade pip wheel twine build
|
|
25
|
+
- name: Build package
|
|
26
|
+
run: python -m build
|
|
27
|
+
- name: Check package
|
|
28
|
+
run: twine check --strict dist/*.whl
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
release:
|
|
9
|
+
name: Upload release to PyPI
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
environment:
|
|
12
|
+
name: pypi
|
|
13
|
+
url: https://pypi.org/p/donordata
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
filter: blob:none
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
- uses: actions/setup-python@v4
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.x"
|
|
24
|
+
cache: "pip"
|
|
25
|
+
- run: pip install build
|
|
26
|
+
- run: python -m build
|
|
27
|
+
- name: Publish package distributions to PyPI
|
|
28
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Run Notebooks
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
run:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
strategy:
|
|
20
|
+
fail-fast: false
|
|
21
|
+
matrix:
|
|
22
|
+
notebook:
|
|
23
|
+
- "docs/tutorials/getting_started.ipynb"
|
|
24
|
+
- "docs/tutorials/ehr_cohort.ipynb"
|
|
25
|
+
- "docs/tutorials/patient_cohort.ipynb"
|
|
26
|
+
- "docs/tutorials/perturbation_screen.ipynb"
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: "3.13"
|
|
32
|
+
- name: Install uv
|
|
33
|
+
run: pip install uv
|
|
34
|
+
- name: Install donordata and notebook dependencies
|
|
35
|
+
run: uv pip install --system ".[ehr,ml,tutorials]" "patpy @ git+https://github.com/lueckenlab/patpy.git@cellink_integration" nbconvert ipykernel
|
|
36
|
+
- name: Run ${{ matrix.notebook }}
|
|
37
|
+
run: jupyter nbconvert --to notebook --execute ${{ matrix.notebook }}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request: # every pull request, also one into another branch
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: "0 5 1,15 * *"
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
concurrency:
|
|
12
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
13
|
+
cancel-in-progress: true
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
# Read the test environments from [[tool.hatch.envs.hatch-test.matrix]] in pyproject.toml,
|
|
20
|
+
# so CI runs the same environments as `hatch test` locally. Follows the scverse cookiecutter template.
|
|
21
|
+
get-environments:
|
|
22
|
+
runs-on: ubuntu-slim
|
|
23
|
+
outputs:
|
|
24
|
+
envs: ${{ steps.get-envs.outputs.envs }}
|
|
25
|
+
steps:
|
|
26
|
+
- &clone
|
|
27
|
+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
28
|
+
with:
|
|
29
|
+
filter: blob:none
|
|
30
|
+
fetch-depth: 0
|
|
31
|
+
persist-credentials: false
|
|
32
|
+
- &setup-uv
|
|
33
|
+
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
|
|
34
|
+
- name: Get test environments
|
|
35
|
+
id: get-envs
|
|
36
|
+
run: |
|
|
37
|
+
ENVS_JSON=$(uvx hatch env show --json | jq -c 'to_entries
|
|
38
|
+
| map(
|
|
39
|
+
select(.key | startswith("hatch-test"))
|
|
40
|
+
| {
|
|
41
|
+
name: .key,
|
|
42
|
+
label: (if (.key | contains("pre")) then .key + " (PRE-RELEASE DEPENDENCIES)" else .key end),
|
|
43
|
+
python: .value.python
|
|
44
|
+
}
|
|
45
|
+
)')
|
|
46
|
+
echo "envs=${ENVS_JSON}" | tee $GITHUB_OUTPUT
|
|
47
|
+
|
|
48
|
+
test:
|
|
49
|
+
needs: get-environments
|
|
50
|
+
strategy:
|
|
51
|
+
fail-fast: false
|
|
52
|
+
matrix:
|
|
53
|
+
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
|
|
54
|
+
name: ${{ matrix.env.label }}
|
|
55
|
+
runs-on: ubuntu-latest
|
|
56
|
+
continue-on-error: ${{ contains(matrix.env.name, 'pre') }} # a pre-release failure warns but does not block
|
|
57
|
+
env:
|
|
58
|
+
UV_PYTHON: ${{ matrix.env.python }}
|
|
59
|
+
# CPU-only torch wheels for the ml extra
|
|
60
|
+
UV_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu
|
|
61
|
+
UV_INDEX_STRATEGY: unsafe-best-match
|
|
62
|
+
steps:
|
|
63
|
+
- *clone
|
|
64
|
+
- *setup-uv
|
|
65
|
+
- name: Create hatch environment
|
|
66
|
+
run: uvx hatch env create ${{ matrix.env.name }}
|
|
67
|
+
- name: List installed package versions
|
|
68
|
+
run: uvx hatch run ${{ matrix.env.name }}:uv pip list
|
|
69
|
+
- name: Run tests
|
|
70
|
+
env:
|
|
71
|
+
MPLBACKEND: agg
|
|
72
|
+
run: uvx hatch run ${{ matrix.env.name }}:run-cov -v --color=yes --report-log=pytest-log.jsonl
|
|
73
|
+
- name: Report coverage
|
|
74
|
+
run: |
|
|
75
|
+
test -f .coverage || uvx hatch run ${{ matrix.env.name }}:cov-combine
|
|
76
|
+
uvx hatch run ${{ matrix.env.name }}:cov-report
|
|
77
|
+
- name: Mark a scheduled run that failed before the tests started, which leaves no test log
|
|
78
|
+
if: failure() && github.event_name == 'schedule' && hashFiles('pytest-log.jsonl') == ''
|
|
79
|
+
run: touch no-test-log
|
|
80
|
+
- name: Upload the test log of a failed scheduled run
|
|
81
|
+
if: failure() && github.event_name == 'schedule'
|
|
82
|
+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
83
|
+
with:
|
|
84
|
+
name: pytest-log-${{ matrix.env.name }}
|
|
85
|
+
path: |
|
|
86
|
+
pytest-log.jsonl
|
|
87
|
+
no-test-log
|
|
88
|
+
|
|
89
|
+
# One required check for branch protection, independent of how many environments exist.
|
|
90
|
+
check:
|
|
91
|
+
name: Tests pass in all hatch environments
|
|
92
|
+
if: always()
|
|
93
|
+
needs: [get-environments, test]
|
|
94
|
+
runs-on: ubuntu-latest
|
|
95
|
+
steps:
|
|
96
|
+
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
|
|
97
|
+
with:
|
|
98
|
+
jobs: ${{ toJSON(needs) }}
|
|
99
|
+
|
|
100
|
+
# Open or update one GitHub issue per environment that failed in a scheduled run, as xarray does.
|
|
101
|
+
# A separate job, so the tests (which run nightly dependencies) never get a token that can write issues.
|
|
102
|
+
create-issue:
|
|
103
|
+
name: Report failed scheduled run
|
|
104
|
+
needs: [get-environments, test]
|
|
105
|
+
if: always() && github.event_name == 'schedule' && github.repository_owner == 'theislab'
|
|
106
|
+
strategy:
|
|
107
|
+
fail-fast: false
|
|
108
|
+
matrix:
|
|
109
|
+
env: ${{ fromJSON(needs.get-environments.outputs.envs) }}
|
|
110
|
+
runs-on: ubuntu-slim
|
|
111
|
+
permissions:
|
|
112
|
+
issues: write
|
|
113
|
+
steps:
|
|
114
|
+
- name: Download the test log, which exists only if this environment failed
|
|
115
|
+
id: download
|
|
116
|
+
continue-on-error: true
|
|
117
|
+
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
|
118
|
+
with:
|
|
119
|
+
name: pytest-log-${{ matrix.env.name }}
|
|
120
|
+
path: logs/
|
|
121
|
+
- name: Open or update the issue
|
|
122
|
+
if: steps.download.outcome == 'success' && hashFiles('logs/pytest-log.jsonl') != ''
|
|
123
|
+
uses: scientific-python/issue-from-pytest-log-action@35b4e0a9e06f8e7e261778289cf4b968b722662d # v1.6.2
|
|
124
|
+
with:
|
|
125
|
+
log-path: logs/pytest-log.jsonl
|
|
126
|
+
issue-title: "Scheduled CI failed: ${{ matrix.env.name }}"
|
|
127
|
+
- name: Open an issue when the run failed before the tests started
|
|
128
|
+
if: steps.download.outcome == 'success' && hashFiles('logs/pytest-log.jsonl') == ''
|
|
129
|
+
env:
|
|
130
|
+
GH_TOKEN: ${{ github.token }}
|
|
131
|
+
TITLE: "Scheduled CI failed before the tests: ${{ matrix.env.name }}"
|
|
132
|
+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
|
133
|
+
run: |
|
|
134
|
+
open=$(gh issue list --repo "$GITHUB_REPOSITORY" --state open --search "in:title \"$TITLE\"" --json number --jq length)
|
|
135
|
+
if [ "$open" = "0" ]; then
|
|
136
|
+
gh issue create --repo "$GITHUB_REPOSITORY" --title "$TITLE" \
|
|
137
|
+
--body "The environment could not be created or the tests did not start. See $RUN_URL."
|
|
138
|
+
fi
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
*.egg-info/
|
|
4
|
+
.eggs/
|
|
5
|
+
build/
|
|
6
|
+
dist/
|
|
7
|
+
.venv/
|
|
8
|
+
venv/
|
|
9
|
+
.env
|
|
10
|
+
|
|
11
|
+
.coverage
|
|
12
|
+
.coverage.*
|
|
13
|
+
coverage.xml
|
|
14
|
+
htmlcov/
|
|
15
|
+
.*cache/
|
|
16
|
+
.ipynb_checkpoints
|
|
17
|
+
lightning_logs/
|
|
18
|
+
|
|
19
|
+
/.idea/
|
|
20
|
+
/.vscode/
|
|
21
|
+
.DS_Store
|
|
22
|
+
|
|
23
|
+
/docs/_build/
|
|
24
|
+
/docs/generated/
|
|
25
|
+
/docs/tutorials/data/
|
|
26
|
+
|
|
27
|
+
# generated by ci/min_deps.py
|
|
28
|
+
ci/min-deps.txt
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
fail_fast: false
|
|
2
|
+
default_language_version:
|
|
3
|
+
python: python3
|
|
4
|
+
default_stages:
|
|
5
|
+
- pre-commit
|
|
6
|
+
- pre-push
|
|
7
|
+
minimum_pre_commit_version: 2.16.0
|
|
8
|
+
repos:
|
|
9
|
+
- repo: https://github.com/tox-dev/pyproject-fmt
|
|
10
|
+
rev: "v2.6.0"
|
|
11
|
+
hooks:
|
|
12
|
+
- id: pyproject-fmt
|
|
13
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
14
|
+
rev: v0.12.12
|
|
15
|
+
hooks:
|
|
16
|
+
- id: ruff
|
|
17
|
+
types_or: [python, pyi, jupyter]
|
|
18
|
+
args: [--fix, --exit-non-zero-on-fix]
|
|
19
|
+
- id: ruff-format
|
|
20
|
+
types_or: [python, pyi, jupyter]
|
|
21
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
22
|
+
rev: v6.0.0
|
|
23
|
+
hooks:
|
|
24
|
+
- id: detect-private-key
|
|
25
|
+
- id: check-ast
|
|
26
|
+
- id: end-of-file-fixer
|
|
27
|
+
- id: mixed-line-ending
|
|
28
|
+
args: [--fix=lf]
|
|
29
|
+
- id: trailing-whitespace
|
|
30
|
+
- id: check-case-conflict
|
|
31
|
+
- id: check-merge-conflict
|
|
32
|
+
args: [--assume-in-merge]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog][],
|
|
6
|
+
and this project adheres to [Semantic Versioning][].
|
|
7
|
+
|
|
8
|
+
[keep a changelog]: https://keepachangelog.com/en/1.1.0/
|
|
9
|
+
[semantic versioning]: https://semver.org/spec/v2.0.0.html
|
|
10
|
+
|
|
11
|
+
## [0.1.0] - 2026-11-20
|
|
12
|
+
|
|
13
|
+
First release of DonorData as a package of its own, split from cellink.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Donors, samples and cells whose donor or sample identifier is missing are dropped with a warning that names
|
|
18
|
+
them. Before, a missing identifier became a donor or sample called `"nan"` or `"None"`. A string that stands for
|
|
19
|
+
a missing value (`""`, `"NA"`, `"N/A"`, `"<NA>"`, `"nan"`, `"NaT"`, `"None"` or `"null"`, in any case) counts as
|
|
20
|
+
missing too and has to be renamed if it is a real name.
|
|
21
|
+
- `nest` and `collapse` drop donors whose grouping value is missing, with a warning.
|
|
22
|
+
- `train_test_split`, `kfold` and `subsample_cells` treat a missing `stratify`, `groups` or `groupby` value as a group
|
|
23
|
+
of its own.
|
|
24
|
+
- `composition` and `pseudobulk` count cells whose `groupby` value is missing as the group `"nan"`;
|
|
25
|
+
`filter_donors_by_cells` only requires that group when it is listed in `groups`.
|
|
26
|
+
- `train_test_split` and `kfold` match a `stratify` given as a `pandas.Series` to the donors by name. Before, they
|
|
27
|
+
read it by position, which assigned wrong classes when the Series was in another order than the donors.
|
|
28
|
+
- Selections, splits, `nest`, `flatten`, `collapse` and `subsample_cells` return objects that do not share levels or
|
|
29
|
+
`uns` with the original.
|
|
30
|
+
- The constructor and the level setters leave their inputs unchanged; a rejected assignment leaves the object
|
|
31
|
+
unchanged; replacing a table keeps the matrices of the remaining units.
|
|
32
|
+
- Identifiers are text in the index and the identifier column; whole-number floats match integer identifiers.
|
|
33
|
+
- `from_anndata` gives a cell without a donor the donor of its sample.
|
|
34
|
+
- MuData modalities are matched by name in `aggregate`, `pseudobulk`, `get_df` and `MILDataset`.
|
|
35
|
+
- `get_df` gives one column per time point for an EHRData variable.
|
|
36
|
+
- `concat(join="outer")` keeps all columns of donor and sample matrices; `concat` rejects EHRData levels.
|
|
37
|
+
- The `filter_*` methods accept a set of names.
|
|
38
|
+
- Requires Python 3.12 or newer and anndata 0.13.1 or newer, with the numpy (2.1), pandas (2.3), scipy (1.14) and h5py
|
|
39
|
+
(3.11) versions that anndata 0.13 needs.
|
|
40
|
+
- Selections and the constructor keep the levels as views instead of copying them. Assigning `X` of a level copies
|
|
41
|
+
that level first, as anndata 0.13 does for every view, so the original never changes.
|
|
42
|
+
- Views of a donor-level AnnData keep all categories of `obs` and `var`, so selecting donors, cells or genes costs no
|
|
43
|
+
more than reading the selected genotypes.
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- `DonorData` with a donor level `D`, an optional sample level `S` and the cells `C`, where each level can be a
|
|
48
|
+
table, an `AnnData`, a `MuData`, or for donors and samples an `EHRData`.
|
|
49
|
+
- Selection at every level with `filter_donors`, `filter_samples`, `filter_cells`, `filter_donors_by_cells` and
|
|
50
|
+
`subsample_cells`, and `coverage` and `complete_cases` for `MuData` cells with assays on different cells.
|
|
51
|
+
- `get_df`, `infer_levels`, `push_obs`, `pull_obs`, `push_obsm` and `to_anndata` to move information between
|
|
52
|
+
levels.
|
|
53
|
+
- `aggregate`, `pseudobulk`, `composition` and `cell_weights`.
|
|
54
|
+
- `nest`, `flatten` and `collapse` to change the levels.
|
|
55
|
+
- `train_test_split` and `kfold` over donors, with stratification and groups.
|
|
56
|
+
- `donordata.io` with `read_dd`, `read_h5_dd` and `read_zarr_dd`, and the on-disk format 0.3.0. `read_zarr_dd` and
|
|
57
|
+
`read_h5_dd(lazy=True)` keep `X` and layers on disk; `read_zarr_dd(lazy=False)` reads them into memory.
|
|
58
|
+
Writing to a file or store that a lazily read object still reads from raises an error.
|
|
59
|
+
- `concat`, `validate` and `register_donordata_namespace`. `concat` returns sparse `obsm` matrices as scipy sparse
|
|
60
|
+
arrays (`csr_array`), since scipy 2 deprecates sparse matrices (`csr_matrix`).
|
|
61
|
+
- `donordata.ml.MILDataset` with bags per donor or per sample.
|
|
62
|
+
- Reading of files in the versions 0.1.0 and 0.2.0 written by cellink. Their donor level `G` is read into `D`
|
|
63
|
+
with a warning.
|
|
64
|
+
|
|
65
|
+
### Fixed
|
|
66
|
+
|
|
67
|
+
- `sel`, `dd[...]`, `D_var` and `C_var` match a boolean `pandas.Series` to the axis by name, as `filter_donors`,
|
|
68
|
+
`filter_samples` and `filter_cells` already do. Before, they applied it by position, which selected the wrong
|
|
69
|
+
samples or cells when the Series was built from the input tables, because `DonorData` reorders samples and
|
|
70
|
+
cells. A Series whose index does not contain the names of the axis, such as the default index 0, 1, 2, ..., now
|
|
71
|
+
raises a `ValueError` instead of selecting by position, also when the cells have no real names and are
|
|
72
|
+
called `"0"`, `"1"`, .... Boolean arrays and lists are still applied by position. A missing entry (NA) of a
|
|
73
|
+
mask counts as `False`.
|
|
74
|
+
- `dd[mask, ...]` with an ellipsis and a boolean array or Series no longer raises an error.
|
|
75
|
+
- `filter_donors`, `filter_samples` and `filter_cells` raise a `KeyError` for a name that does not exist, as `sel`
|
|
76
|
+
and `dd[...]` do. Before, they ignored it. They raise a `TypeError` for integers, which they used to read as
|
|
77
|
+
names, and for slices. Names are given as text; positions are selected with `dd[...]` or `sel`.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it as below."
|
|
3
|
+
authors:
|
|
4
|
+
- family-names: "Arnoldt"
|
|
5
|
+
given-names: "Lucas"
|
|
6
|
+
- family-names: "Engelmann"
|
|
7
|
+
given-names: "Jan"
|
|
8
|
+
- family-names: "Holtkamp"
|
|
9
|
+
given-names: "Eva"
|
|
10
|
+
title: "DonorData"
|
|
11
|
+
version: 0.1.0
|
|
12
|
+
url: "https://github.com/theislab/donordata"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Designing `DonorData`
|
|
2
|
+
|
|
3
|
+
This document outlines design considerations and some technical details about the `DonorData` implementation.
|
|
4
|
+
|
|
5
|
+
## Levels as containers
|
|
6
|
+
|
|
7
|
+
`DonorData` stores data at several levels: donors, optionally samples, and cells. Every level is a fully functional
|
|
8
|
+
`AnnData` or `MuData` object that can be used on its own, and the levels are linked by identifiers instead of being
|
|
9
|
+
merged into one matrix. This follows the container approach of `MuData`, which keeps every modality as an `AnnData`.
|
|
10
|
+
A donor table plays a similar role to the global `obs` of a `MuData`, one level up. A donor can be any unit that groups cells, for example a patient, a target gene in a CRISPR screen or a compound in a drug screen.
|
|
11
|
+
|
|
12
|
+
An `EHRData` from ehrdata, an `AnnData` with a time axis, fits the same scheme: it can be the donor or the sample
|
|
13
|
+
level, for example to hold the clinical record of every patient next to the cells.
|
|
14
|
+
|
|
15
|
+
## The sample level
|
|
16
|
+
|
|
17
|
+
Some cohorts have several samples per donor, for example blood drawn on two days, two tissues or several
|
|
18
|
+
stimulation conditions. Without a sample level there are two options, and both lose information. With the patient
|
|
19
|
+
as the donor, the samples are pooled and can no longer be compared. With the sample as the donor, patient covariates
|
|
20
|
+
are repeated for every sample, and a split can put two samples of the same patient into training and test data.
|
|
21
|
+
|
|
22
|
+
The optional sample level `S` sits between donors and cells. `D` has one row per donor, `S` one row per sample with
|
|
23
|
+
the donor of every sample, and `C` the cells with the sample of every cell. Analyses can use either level, and splits
|
|
24
|
+
are always drawn over donors. Without `S`, cells are linked to donors directly and nothing else changes.
|
|
25
|
+
|
|
26
|
+
## Order of units
|
|
27
|
+
|
|
28
|
+
Samples are stored grouped by donor in the row order of `D`, and cells grouped by sample, or by donor, in the row
|
|
29
|
+
order of the level above. The cells of a unit are therefore one contiguous block of `C`, which makes selecting the
|
|
30
|
+
cells of a unit, building bags of cells for multiple instance learning and aggregating cells to units simple slicing
|
|
31
|
+
or a single pass over integer codes. The order is restored on construction and whenever a level is replaced, and
|
|
32
|
+
`validate` checks it.
|
|
33
|
+
|
|
34
|
+
## Storage
|
|
35
|
+
|
|
36
|
+
A `DonorData` is written with one group per level, `D`, `S` and `C`, each with the `AnnData` or `MuData` encoding, so
|
|
37
|
+
every level can be read with AnnData alone. See the [specification](docs/io/spec.md) for the full layout.
|
donordata-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License Version 2.0
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright (c) 2025, Jan Engelmann and Lucas Arnoldt and Eva Holtkamp and the Theislab
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|