pase-framework 1.0.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.
Files changed (40) hide show
  1. pase_framework-1.0.0/.github/workflows/publish.yml +61 -0
  2. pase_framework-1.0.0/.github/workflows/tests.yml +57 -0
  3. pase_framework-1.0.0/.readthedocs.yaml +15 -0
  4. pase_framework-1.0.0/CITATION.cff +22 -0
  5. pase_framework-1.0.0/LICENSE +22 -0
  6. pase_framework-1.0.0/MANIFEST.in +11 -0
  7. pase_framework-1.0.0/PKG-INFO +136 -0
  8. pase_framework-1.0.0/README.md +92 -0
  9. pase_framework-1.0.0/THIRD_PARTY_DATA.md +17 -0
  10. pase_framework-1.0.0/docs/api.md +12 -0
  11. pase_framework-1.0.0/docs/conf.py +17 -0
  12. pase_framework-1.0.0/docs/index.md +18 -0
  13. pase_framework-1.0.0/docs/inputs.md +80 -0
  14. pase_framework-1.0.0/docs/outputs.md +53 -0
  15. pase_framework-1.0.0/docs/quickstart.md +37 -0
  16. pase_framework-1.0.0/docs/release.md +74 -0
  17. pase_framework-1.0.0/docs/reproducibility.md +40 -0
  18. pase_framework-1.0.0/docs/statistics.md +98 -0
  19. pase_framework-1.0.0/examples/build_gse234933_subset.py +150 -0
  20. pase_framework-1.0.0/examples/gse234933_quickstart.ipynb +269 -0
  21. pase_framework-1.0.0/pyproject.toml +53 -0
  22. pase_framework-1.0.0/scripts/prepare_bioconda.py +97 -0
  23. pase_framework-1.0.0/scripts/run_tutorial.py +88 -0
  24. pase_framework-1.0.0/setup.cfg +4 -0
  25. pase_framework-1.0.0/src/pase/__init__.py +8 -0
  26. pase_framework-1.0.0/src/pase/_statistics.py +255 -0
  27. pase_framework-1.0.0/src/pase/association.py +368 -0
  28. pase_framework-1.0.0/src/pase/data/DATA_NOTICE.md +37 -0
  29. pase_framework-1.0.0/src/pase/data/gse234933_demo.npz +0 -0
  30. pase_framework-1.0.0/src/pase/data/gse234933_demo_manifest.json +160 -0
  31. pase_framework-1.0.0/src/pase/data/gse234933_demo_obs.tsv +777 -0
  32. pase_framework-1.0.0/src/pase/datasets.py +49 -0
  33. pase_framework-1.0.0/src/pase/result.py +102 -0
  34. pase_framework-1.0.0/src/pase_framework.egg-info/PKG-INFO +136 -0
  35. pase_framework-1.0.0/src/pase_framework.egg-info/SOURCES.txt +38 -0
  36. pase_framework-1.0.0/src/pase_framework.egg-info/dependency_links.txt +1 -0
  37. pase_framework-1.0.0/src/pase_framework.egg-info/requires.txt +23 -0
  38. pase_framework-1.0.0/src/pase_framework.egg-info/top_level.txt +1 -0
  39. pase_framework-1.0.0/tests/test_association.py +276 -0
  40. pase_framework-1.0.0/tests/test_datasets.py +45 -0
@@ -0,0 +1,61 @@
1
+ name: Publish release
2
+ on:
3
+ release:
4
+ types: [published]
5
+ workflow_dispatch:
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ checks:
12
+ uses: ./.github/workflows/tests.yml
13
+ build:
14
+ needs: checks
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v6
18
+ - uses: actions/setup-python@v5
19
+ with:
20
+ python-version: '3.12'
21
+ - name: Check release tag
22
+ if: github.event_name == 'release'
23
+ env:
24
+ RELEASE_TAG: ${{ github.event.release.tag_name }}
25
+ run: python -c "import os,tomllib; v=tomllib.load(open('pyproject.toml','rb'))['project']['version']; assert os.environ['RELEASE_TAG']=='v'+v, 'Release tag and package version differ'"
26
+ - run: python -m pip install build twine
27
+ - run: python -m build
28
+ - run: python -m twine check dist/*
29
+ - uses: actions/upload-artifact@v4
30
+ with:
31
+ name: distributions
32
+ path: dist/*
33
+ testpypi:
34
+ if: github.event_name == 'workflow_dispatch'
35
+ needs: build
36
+ runs-on: ubuntu-latest
37
+ environment: testpypi
38
+ permissions:
39
+ id-token: write
40
+ steps:
41
+ - uses: actions/download-artifact@v4
42
+ with:
43
+ name: distributions
44
+ path: dist/
45
+ - uses: pypa/gh-action-pypi-publish@release/v1
46
+ with:
47
+ repository-url: https://test.pypi.org/legacy/
48
+ pypi:
49
+ if: github.event_name == 'release'
50
+ needs: build
51
+ runs-on: ubuntu-latest
52
+ environment: pypi
53
+ permissions:
54
+ id-token: write
55
+ steps:
56
+ - uses: actions/download-artifact@v4
57
+ with:
58
+ name: distributions
59
+ path: dist/
60
+ - uses: pypa/gh-action-pypi-publish@release/v1
61
+
@@ -0,0 +1,57 @@
1
+ name: Tests
2
+ on:
3
+ push:
4
+ pull_request:
5
+ workflow_call:
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ test:
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ os: [ubuntu-latest, macos-latest, windows-latest]
16
+ python: ['3.10', '3.13']
17
+ runs-on: ${{ matrix.os }}
18
+ defaults:
19
+ run:
20
+ shell: bash
21
+ steps:
22
+ - uses: actions/checkout@v6
23
+ - uses: actions/setup-python@v5
24
+ with:
25
+ python-version: ${{ matrix.python }}
26
+ - name: Build release artifacts
27
+ run: |
28
+ python -m pip install build twine
29
+ python -m build
30
+ python -m twine check dist/*
31
+ - name: Install and test the wheel
32
+ run: |
33
+ python -m pip install dist/*.whl pytest
34
+ python -m pytest --import-mode=importlib --junitxml=verification/tests.xml
35
+ - uses: actions/upload-artifact@v4
36
+ if: always()
37
+ with:
38
+ name: tests-${{ matrix.os }}-${{ matrix.python }}
39
+ path: verification/tests.xml
40
+ documentation-and-tutorial:
41
+ runs-on: ubuntu-latest
42
+ steps:
43
+ - uses: actions/checkout@v6
44
+ - uses: actions/setup-python@v5
45
+ with:
46
+ python-version: '3.12'
47
+ - run: python -m pip install '.[docs,tutorial]'
48
+ - run: python -m sphinx -W --keep-going -b html docs docs/_build/html
49
+ - run: python scripts/run_tutorial.py --output tutorial-output
50
+ - uses: actions/upload-artifact@v4
51
+ if: always()
52
+ with:
53
+ name: documentation-and-tutorial
54
+ path: |
55
+ docs/_build/html
56
+ tutorial-output
57
+
@@ -0,0 +1,15 @@
1
+ version: 2
2
+ build:
3
+ os: ubuntu-24.04
4
+ tools:
5
+ python: "3.12"
6
+ sphinx:
7
+ configuration: docs/conf.py
8
+ fail_on_warning: true
9
+ python:
10
+ install:
11
+ - method: pip
12
+ path: .
13
+ extra_requirements:
14
+ - docs
15
+
@@ -0,0 +1,22 @@
1
+ cff-version: 1.2.0
2
+ message: "Please cite this software and the version-specific release URL or DOI accompanying the version used."
3
+ type: software
4
+ title: "PASE: patient-level association estimation"
5
+ version: 1.0.0
6
+ repository-code: "https://github.com/tjw0613-cell/pase-software"
7
+ authors:
8
+ - family-names: Tang
9
+ given-names: Jinwei
10
+ - family-names: Lin
11
+ given-names: Yunfan
12
+ - family-names: Cai
13
+ given-names: Linrui
14
+ - family-names: Wen
15
+ given-names: Yali
16
+ - family-names: Chen
17
+ given-names: Guangyang
18
+ - family-names: Huang
19
+ given-names: Li
20
+ license: MIT
21
+ abstract: "Software for within-patient molecular associations and equal-patient, random-effects, or individual shrinkage summaries."
22
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jinwei Tang, Yunfan Lin, Linrui Cai, Yali Wen, Guangyang Chen, and Li Huang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,11 @@
1
+ include LICENSE README.md CITATION.cff THIRD_PARTY_DATA.md
2
+ include .readthedocs.yaml
3
+ recursive-include src/pase/data *
4
+ recursive-include docs *.md *.py
5
+ recursive-include examples *.ipynb *.py
6
+ recursive-include tests *.py
7
+ recursive-include scripts *.py
8
+ recursive-include .github/workflows *.yml
9
+ global-exclude *.pyc
10
+ global-exclude __pycache__
11
+
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: pase-framework
3
+ Version: 1.0.0
4
+ Summary: Patient-level association estimates for multi-patient single-cell studies
5
+ Author: Jinwei Tang, Yunfan Lin, Linrui Cai, Yali Wen, Guangyang Chen, Li Huang
6
+ License-Expression: MIT
7
+ Project-URL: Source, https://github.com/tjw0613-cell/pase-software
8
+ Project-URL: Issues, https://github.com/tjw0613-cell/pase-software/issues
9
+ Project-URL: Reproduction, https://github.com/tjw0613-cell/pase-reproducibility
10
+ Keywords: single-cell,association,patient,correlation,meta-analysis
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ License-File: src/pase/data/DATA_NOTICE.md
24
+ Requires-Dist: numpy>=1.24
25
+ Requires-Dist: scipy>=1.10
26
+ Requires-Dist: pandas>=2.0
27
+ Requires-Dist: anndata>=0.10
28
+ Requires-Dist: matplotlib>=3.7
29
+ Provides-Extra: test
30
+ Requires-Dist: pytest>=8; extra == "test"
31
+ Provides-Extra: tutorial
32
+ Requires-Dist: jupyterlab>=4; extra == "tutorial"
33
+ Requires-Dist: nbformat>=5; extra == "tutorial"
34
+ Requires-Dist: nbclient>=0.10; extra == "tutorial"
35
+ Requires-Dist: ipykernel>=6; extra == "tutorial"
36
+ Provides-Extra: docs
37
+ Requires-Dist: sphinx>=7; extra == "docs"
38
+ Requires-Dist: myst-parser>=3; extra == "docs"
39
+ Requires-Dist: sphinx-rtd-theme>=3; extra == "docs"
40
+ Provides-Extra: build
41
+ Requires-Dist: build>=1.2; extra == "build"
42
+ Requires-Dist: twine>=6; extra == "build"
43
+ Dynamic: license-file
44
+
45
+ # PASE
46
+
47
+ PASE estimates molecular associations within individual patients and summarizes them across a single-cell cohort.
48
+
49
+ ## Installation
50
+
51
+ Use Python 3.10 or later in a fresh environment. From this source checkout:
52
+
53
+ ```bash
54
+ git clone https://github.com/tjw0613-cell/pase-software.git
55
+ cd pase-software
56
+ python -m venv .venv
57
+ # Windows: .venv\Scripts\activate
58
+ # macOS/Linux: source .venv/bin/activate
59
+ python -m pip install .
60
+ ```
61
+
62
+ The distribution is named **pase-framework**, but the Python import is `pase`.
63
+ The unrelated audio package named `pase` on PyPI uses the same import name;
64
+ do not install both in one environment. This source release does not by itself
65
+ confirm availability on PyPI.
66
+
67
+ ## Five-line example
68
+
69
+ ```python
70
+ import pase
71
+ adata = pase.datasets.load_gse234933_demo()
72
+ res = pase.associate(adata, anchor="LILRB4", target=["MMP14", "MMP9", "SPP1", "APOE"], patient_key="donor", covariates=["log_depth"], cell_mask="myeloid", aggregate="equal", min_cells=30)
73
+ print(res.summary())
74
+ res.plot_forest()
75
+ ```
76
+
77
+ The bundled GSE234933 subset contains real cells and works without a download.
78
+ The four-gene target above illustrates the interface; it is not the current
79
+ manuscript's published 15-gene signature. The complete tutorial is
80
+ [examples/gse234933_quickstart.ipynb](examples/gse234933_quickstart.ipynb).
81
+ Install the notebook tools with `python -m pip install ".[tutorial]"`, then run
82
+ `jupyter lab examples/gse234933_quickstart.ipynb`.
83
+
84
+ ## Input format
85
+
86
+ Supply an AnnData object with cells in rows and unique gene names in
87
+ `adata.var_names`. `adata.X`, or the requested `layer`, must already contain
88
+ transformed expression. For count data, the tutorial uses
89
+ `log1p(10000 * count / total_counts)` with totals calculated **before** selecting
90
+ genes. `associate` does not normalize raw counts.
91
+
92
+ | Input | Meaning |
93
+ |---|---|
94
+ | `adata.obs["donor"]` | Independent patient ID, with no missing values. Repeated samples from one patient must share an ID. |
95
+ | `adata.obs["log_depth"]` | Numeric covariate; the tutorial uses `log1p(total_counts)` from the full matrix. |
96
+ | `adata.obs["myeloid"]` | Boolean cell-selection column. Patients with no selected cells remain in the output. |
97
+ | `anchor` | One gene name. |
98
+ | `target` | One gene name, or a list whose within-patient gene z scores are averaged. |
99
+
100
+ Covariates enter a separate least-squares model for each patient, with an
101
+ intercept. Numeric categorical encodings must be supplied explicitly.
102
+ Patients absent from the object can be retained using `patient_ids`.
103
+ See [the input guide](docs/inputs.md) for missing values and eligibility rules.
104
+
105
+ ## Outputs and choice of summary
106
+
107
+ `res.patients` reports every patient, cell counts, observed correlation,
108
+ eligibility, exclusion reasons and, where applicable, weights or shrunken effects.
109
+ `res.summary()` returns one row with the selected method, target, estimate,
110
+ interval, P value and status. `res.metadata` records the analysis settings and
111
+ warnings. `res.plot_forest()` returns a Matplotlib Axes.
112
+
113
+ | `aggregate` | What it reports |
114
+ |---|---|
115
+ | `"equal"` | Arithmetic mean of eligible patients' observed correlations, with a t interval. Each eligible patient has equal weight. |
116
+ | `"re_hksj"` | REML random-effects mean on the Fisher-z scale, back-transformed for display, with a classical HKSJ interval. It has a different target from the arithmetic mean. |
117
+ | `"eb"` | Individual patient effects shrunk toward the fitted Fisher-z population mean. Conditional intervals exclude uncertainty in fitted population parameters; no cohort P value is returned. |
118
+
119
+ `min_cells=30` is adjustable. `min_patients=2` is a technical minimum, **not a
120
+ validated recommendation for reliable inference**. Set a stricter reporting
121
+ threshold explicitly, for example `min_patients=6`. When that threshold is not
122
+ met, cohort estimates, intervals and P values are withheld, and the patient
123
+ records remain available. A configurable threshold does not establish its
124
+ statistical adequacy. See [statistical details](docs/statistics.md).
125
+
126
+ ## Citation
127
+
128
+ For this code, cite the authors, PASE software version **1.0.0**, and the release
129
+ URL or version DOI that accompanies the copy used. Machine-readable author
130
+ information is in [CITATION.cff](CITATION.cff). An earlier analysis archive is
131
+ available at [Zenodo v3](https://doi.org/10.5281/zenodo.23032874); that DOI does
132
+ not identify this 1.0.0 software release.
133
+
134
+ Code is distributed under the MIT License. The real-data example retains its
135
+ source attribution and third-party terms; see [THIRD_PARTY_DATA.md](THIRD_PARTY_DATA.md).
136
+
@@ -0,0 +1,92 @@
1
+ # PASE
2
+
3
+ PASE estimates molecular associations within individual patients and summarizes them across a single-cell cohort.
4
+
5
+ ## Installation
6
+
7
+ Use Python 3.10 or later in a fresh environment. From this source checkout:
8
+
9
+ ```bash
10
+ git clone https://github.com/tjw0613-cell/pase-software.git
11
+ cd pase-software
12
+ python -m venv .venv
13
+ # Windows: .venv\Scripts\activate
14
+ # macOS/Linux: source .venv/bin/activate
15
+ python -m pip install .
16
+ ```
17
+
18
+ The distribution is named **pase-framework**, but the Python import is `pase`.
19
+ The unrelated audio package named `pase` on PyPI uses the same import name;
20
+ do not install both in one environment. This source release does not by itself
21
+ confirm availability on PyPI.
22
+
23
+ ## Five-line example
24
+
25
+ ```python
26
+ import pase
27
+ adata = pase.datasets.load_gse234933_demo()
28
+ res = pase.associate(adata, anchor="LILRB4", target=["MMP14", "MMP9", "SPP1", "APOE"], patient_key="donor", covariates=["log_depth"], cell_mask="myeloid", aggregate="equal", min_cells=30)
29
+ print(res.summary())
30
+ res.plot_forest()
31
+ ```
32
+
33
+ The bundled GSE234933 subset contains real cells and works without a download.
34
+ The four-gene target above illustrates the interface; it is not the current
35
+ manuscript's published 15-gene signature. The complete tutorial is
36
+ [examples/gse234933_quickstart.ipynb](examples/gse234933_quickstart.ipynb).
37
+ Install the notebook tools with `python -m pip install ".[tutorial]"`, then run
38
+ `jupyter lab examples/gse234933_quickstart.ipynb`.
39
+
40
+ ## Input format
41
+
42
+ Supply an AnnData object with cells in rows and unique gene names in
43
+ `adata.var_names`. `adata.X`, or the requested `layer`, must already contain
44
+ transformed expression. For count data, the tutorial uses
45
+ `log1p(10000 * count / total_counts)` with totals calculated **before** selecting
46
+ genes. `associate` does not normalize raw counts.
47
+
48
+ | Input | Meaning |
49
+ |---|---|
50
+ | `adata.obs["donor"]` | Independent patient ID, with no missing values. Repeated samples from one patient must share an ID. |
51
+ | `adata.obs["log_depth"]` | Numeric covariate; the tutorial uses `log1p(total_counts)` from the full matrix. |
52
+ | `adata.obs["myeloid"]` | Boolean cell-selection column. Patients with no selected cells remain in the output. |
53
+ | `anchor` | One gene name. |
54
+ | `target` | One gene name, or a list whose within-patient gene z scores are averaged. |
55
+
56
+ Covariates enter a separate least-squares model for each patient, with an
57
+ intercept. Numeric categorical encodings must be supplied explicitly.
58
+ Patients absent from the object can be retained using `patient_ids`.
59
+ See [the input guide](docs/inputs.md) for missing values and eligibility rules.
60
+
61
+ ## Outputs and choice of summary
62
+
63
+ `res.patients` reports every patient, cell counts, observed correlation,
64
+ eligibility, exclusion reasons and, where applicable, weights or shrunken effects.
65
+ `res.summary()` returns one row with the selected method, target, estimate,
66
+ interval, P value and status. `res.metadata` records the analysis settings and
67
+ warnings. `res.plot_forest()` returns a Matplotlib Axes.
68
+
69
+ | `aggregate` | What it reports |
70
+ |---|---|
71
+ | `"equal"` | Arithmetic mean of eligible patients' observed correlations, with a t interval. Each eligible patient has equal weight. |
72
+ | `"re_hksj"` | REML random-effects mean on the Fisher-z scale, back-transformed for display, with a classical HKSJ interval. It has a different target from the arithmetic mean. |
73
+ | `"eb"` | Individual patient effects shrunk toward the fitted Fisher-z population mean. Conditional intervals exclude uncertainty in fitted population parameters; no cohort P value is returned. |
74
+
75
+ `min_cells=30` is adjustable. `min_patients=2` is a technical minimum, **not a
76
+ validated recommendation for reliable inference**. Set a stricter reporting
77
+ threshold explicitly, for example `min_patients=6`. When that threshold is not
78
+ met, cohort estimates, intervals and P values are withheld, and the patient
79
+ records remain available. A configurable threshold does not establish its
80
+ statistical adequacy. See [statistical details](docs/statistics.md).
81
+
82
+ ## Citation
83
+
84
+ For this code, cite the authors, PASE software version **1.0.0**, and the release
85
+ URL or version DOI that accompanies the copy used. Machine-readable author
86
+ information is in [CITATION.cff](CITATION.cff). An earlier analysis archive is
87
+ available at [Zenodo v3](https://doi.org/10.5281/zenodo.23032874); that DOI does
88
+ not identify this 1.0.0 software release.
89
+
90
+ Code is distributed under the MIT License. The real-data example retains its
91
+ source attribution and third-party terms; see [THIRD_PARTY_DATA.md](THIRD_PARTY_DATA.md).
92
+
@@ -0,0 +1,17 @@
1
+ # Third-party data
2
+
3
+ The teaching dataset is derived from public GSE234933 data deposited by its
4
+ original investigators in NCBI GEO. It is not newly generated patient data.
5
+ Source files, checksums, selection rules and original identifiers are recorded
6
+ in the files packaged under `src/pase/data/` and exposed by the tutorial.
7
+
8
+ The MIT License applies to PASE source code. It does not transfer ownership of
9
+ or relicense the original study's data. Users should cite the original study
10
+ and GEO accession, respect source terms, and assess suitability for their use.
11
+ See [GSE234933](https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE234933)
12
+ and [NCBI's GEO disclaimer](https://www.ncbi.nlm.nih.gov/geo/info/disclaimer.html).
13
+
14
+ The bundled data are a small selected myeloid-cell example. They are suitable
15
+ for learning the API, not for reproducing full-cohort findings or estimating
16
+ the original cohort's cell-type proportions.
17
+
@@ -0,0 +1,12 @@
1
+ # API reference
2
+
3
+ ```{autofunction} pase.associate
4
+ ```
5
+
6
+ ```{autoclass} pase.AssociationResult
7
+ :members: summary, plot_forest
8
+ ```
9
+
10
+ ```{autofunction} pase.datasets.load_gse234933_demo
11
+ ```
12
+
@@ -0,0 +1,17 @@
1
+ from importlib.metadata import version as package_version
2
+
3
+ project = "PASE"
4
+ author = "Jinwei Tang, Yunfan Lin, Linrui Cai, Yali Wen, Guangyang Chen, Li Huang"
5
+ copyright = "2026, PASE authors"
6
+ release = package_version("pase-framework")
7
+ version = release
8
+ extensions = ["myst_parser", "sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx.ext.mathjax"]
9
+ source_suffix = {".md": "markdown", ".rst": "restructuredtext"}
10
+ master_doc = "index"
11
+ exclude_patterns = ["_build"]
12
+ html_theme = "sphinx_rtd_theme"
13
+ html_title = f"PASE {release}"
14
+ myst_enable_extensions = ["dollarmath", "colon_fence"]
15
+ autodoc_member_order = "bysource"
16
+ napoleon_numpy_docstring = True
17
+
@@ -0,0 +1,18 @@
1
+ # PASE
2
+
3
+ PASE estimates a molecular association within each patient and then summarizes
4
+ the patient effects. It accepts AnnData objects, preserves exclusions, and
5
+ reports the statistical target of each summary.
6
+
7
+ ```{toctree}
8
+ :maxdepth: 2
9
+
10
+ quickstart
11
+ inputs
12
+ statistics
13
+ api
14
+ outputs
15
+ reproducibility
16
+ release
17
+ ```
18
+
@@ -0,0 +1,80 @@
1
+ # Preparing an AnnData object
2
+
3
+ ## Expression and library size
4
+
5
+ `adata.X` (or `adata.layers[layer]`) contains transformed expression, with cells
6
+ as rows and genes as columns. Gene names must be unique. PASE extracts the
7
+ requested genes and densifies only that submatrix if the input is sparse.
8
+ It does not normalize, select variable genes, or modify the input.
9
+
10
+ For count data, calculate library sizes from all measured genes, then apply
11
+ CP10K and log1p. Do this before restricting the object to the anchor and targets:
12
+
13
+ ```python
14
+ import numpy as np
15
+ from scipy import sparse
16
+
17
+ counts = adata.layers["counts"].astype(float).copy()
18
+ totals = np.asarray(counts.sum(axis=1)).ravel()
19
+ if np.any(totals <= 0):
20
+ raise ValueError("Handle zero-library cells before normalization.")
21
+ if sparse.issparse(counts):
22
+ transformed = counts.multiply((10000 / totals)[:, None]).tocsr()
23
+ transformed.data = np.log1p(transformed.data)
24
+ else:
25
+ transformed = np.log1p(counts * (10000 / totals)[:, None])
26
+ adata.layers["log1p_cp10k"] = transformed
27
+ adata.obs["log_depth"] = np.log1p(totals)
28
+ ```
29
+
30
+ Use `layer="log1p_cp10k"` in the analysis. If a shared sample or library has
31
+ other normalization requirements, choose and document preprocessing before
32
+ calling PASE.
33
+
34
+ ## Patients and cells
35
+
36
+ `patient_key` identifies the independent patient, not a specimen, sequencing
37
+ lane or individual cell. Resolve repeated specimens in the study design and
38
+ retain one inference unit per independent patient. Missing IDs are an error.
39
+
40
+ `cell_mask` is either a boolean `obs` column or a boolean vector in the same
41
+ order as the cells. Strings such as `"False"`, numeric 0/1 values and missing
42
+ mask values are rejected. Do not pre-subset the object if you want patients
43
+ with zero selected cells to remain visible. Use `patient_ids` to add patients
44
+ absent from the object entirely. All observed IDs remain in the output.
45
+
46
+ ## Scores, covariates and missing values
47
+
48
+ A string target selects one transformed gene. A list creates a score by
49
+ standardizing each component within the patient's selected cells (sample
50
+ standard deviation, `ddof=1`) and averaging the z scores. A measured constant
51
+ gene contributes zero. A gene absent from `var_names` is an error.
52
+
53
+ The order is fixed:
54
+
55
+ 1. Select cells using the mask.
56
+ 2. Remove cells with nonfinite anchor or target expression.
57
+ 3. Construct the patient's target score.
58
+ 4. Remove cells with nonfinite covariates.
59
+ 5. Residualize anchor and score using the same numeric covariates and intercept.
60
+ 6. Correlate the residual vectors and apply patient eligibility rules.
61
+
62
+ No outcome-detection gate is applied. The input function accepts numeric
63
+ covariates, including explicit dummy variables, but does not encode categories.
64
+ Within each patient's complete cases, nuisance columns are centered and scaled
65
+ for numerical stability. Constant nuisance columns are omitted; the intercept
66
+ is retained. Rank-deficient designs use their numerical rank. Nonfinite values are counted
67
+ in the patient output instead of being silently replaced with zero.
68
+
69
+ ## Eligibility
70
+
71
+ The selected method requires at least `min_cells` complete cells and at least
72
+ three residual degrees of freedom. Constant residual vectors are not estimable.
73
+ Fisher methods additionally require `abs(r) < 1` and `n - k - 3 > 0`.
74
+ Here `k` is the nuisance design rank minus one (the intercept).
75
+
76
+ Equal and Fisher summaries can therefore have different eligible patients.
77
+ Inspect `equal_eligible`, `fisher_eligible` and both exclusion-reason columns
78
+ before comparing summaries. Small-cell patients are not automatically rescued
79
+ by weighting; the caller must lower `min_cells` explicitly and justify doing so.
80
+
@@ -0,0 +1,53 @@
1
+ # Reading the output
2
+
3
+ ## Summary table
4
+
5
+ `result.summary()` returns a new one-row DataFrame. Its principal fields are:
6
+
7
+ | Field | Interpretation |
8
+ |---|---|
9
+ | `method`, `target` | Selected method and the population quantity it addresses. |
10
+ | `n_patients_total` | All observed patients plus any additional IDs provided. |
11
+ | `n_patients_eligible`, `n_patients_excluded` | Counts for the selected method. |
12
+ | `estimate`, `ci_low`, `ci_high` | Correlation-scale group result, or NaN when withheld or in EB mode. |
13
+ | `p_value` | Two-sided test of zero group effect, where returned. |
14
+ | `standard_error`, `se_scale` | Standard error and its scale; Fisher summaries use z-scale uncertainty. |
15
+ | `df` | Degrees of freedom used by the interval. |
16
+ | `tau2` | Estimated between-patient variance on the Fisher-z scale; not applicable to equal-r summaries. |
17
+ | `status`, `reason` | Whether inference was returned and why it was withheld. |
18
+
19
+ Status `reported` denotes a computed interval, not demonstrated reliability.
20
+ `withheld_policy` means the selected patient threshold was not met.
21
+ `withheld_technical` means an interval was not mathematically estimable.
22
+ `individual_estimates_only` marks EB mode.
23
+
24
+ ## Patient table
25
+
26
+ `result.patients` includes all patients, including those with no selected cells.
27
+ `n_total`, `n_selected`, `n_expression_complete` and `n_complete` follow the
28
+ processing steps. `n_cells` equals `n_complete`. `r` is the observed partial
29
+ correlation; it can be shown descriptively even when the patient falls below
30
+ the minimum cell count. The table includes design rank and residual degrees
31
+ of freedom.
32
+
33
+ `eligible`, `reason` and `status` refer to the selected summary. The
34
+ `equal_eligible`/`equal_reason` and `fisher_eligible`/`fisher_reason` columns
35
+ also reveal differences between the method-specific eligible sets.
36
+ `weight` is the normalized group weight when available. In EB mode,
37
+ `eb_data_weight` is the patient's shrinkage coefficient, not a group weight.
38
+
39
+ EB fields include `eb_estimate`, `eb_ci_low`, `eb_ci_high`,
40
+ `eb_conditional_se_z` and `eb_status`. A missing EB interval at zero estimated
41
+ heterogeneity is intentional. Raw patient correlations do not receive
42
+ individual intervals in the equal or random-effects forest plot.
43
+
44
+ ## Saving tables and metadata
45
+
46
+ ```python
47
+ import json
48
+ result.summary().to_csv("summary.tsv", sep="\t", index=False)
49
+ result.patients.to_csv("patients.tsv", sep="\t", index=False)
50
+ with open("settings.json", "w", encoding="utf-8") as handle:
51
+ json.dump(result.metadata, handle, indent=2)
52
+ ```
53
+
@@ -0,0 +1,37 @@
1
+ # Quick start
2
+
3
+ From the source checkout, create and activate an environment and install PASE:
4
+
5
+ ```bash
6
+ python -m venv .venv
7
+ # Windows: .venv\Scripts\activate
8
+ # macOS/Linux: source .venv/bin/activate
9
+ python -m pip install ".[tutorial]"
10
+ ```
11
+
12
+ The package distribution is `pase-framework`; the Python module is `pase`.
13
+ Use a fresh environment to avoid the unrelated `pase` audio package.
14
+
15
+ ```python
16
+ import pase
17
+ adata = pase.datasets.load_gse234933_demo()
18
+ result = pase.associate(
19
+ adata, anchor="LILRB4", target=["MMP14", "MMP9", "SPP1", "APOE"],
20
+ patient_key="donor", covariates=["log_depth"], cell_mask="myeloid",
21
+ aggregate="equal", min_cells=30,
22
+ )
23
+ print(result.summary().to_string(index=False))
24
+ print(result.patients[["patient_id", "n_cells", "r", "eligible", "reason"]])
25
+ ax = result.plot_forest()
26
+ ax.figure.savefig("association.pdf", bbox_inches="tight")
27
+ ```
28
+
29
+ This is an interface example using real cells, not a full-cohort analysis.
30
+ The four-gene target demonstrates module input; the revised manuscript's main
31
+ biological analysis uses a separately sourced 15-gene signature.
32
+
33
+ Open `examples/gse234933_quickstart.ipynb` with JupyterLab for a complete
34
+ walkthrough of normalization metadata, exclusions, the three summaries,
35
+ threshold sensitivity and saving results. After installation, that notebook
36
+ needs neither network access nor a separate raw-data download.
37
+