pase-framework 1.1.1__tar.gz → 1.2.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 (45) hide show
  1. {pase_framework-1.1.1 → pase_framework-1.2.0}/CHANGELOG.md +8 -0
  2. {pase_framework-1.1.1 → pase_framework-1.2.0}/CITATION.cff +2 -2
  3. {pase_framework-1.1.1 → pase_framework-1.2.0}/PKG-INFO +29 -26
  4. {pase_framework-1.1.1 → pase_framework-1.2.0}/README.md +28 -25
  5. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/inputs.md +26 -18
  6. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/outputs.md +3 -0
  7. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/quickstart.md +3 -3
  8. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/release.md +9 -7
  9. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/reporting-policy.md +4 -5
  10. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/reproducibility.md +3 -3
  11. {pase_framework-1.1.1 → pase_framework-1.2.0}/pyproject.toml +1 -1
  12. {pase_framework-1.1.1 → pase_framework-1.2.0}/scripts/prepare_bioconda.py +1 -1
  13. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/__init__.py +1 -1
  14. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/_reporting.py +5 -10
  15. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/association.py +31 -9
  16. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase_framework.egg-info/PKG-INFO +29 -26
  17. {pase_framework-1.1.1 → pase_framework-1.2.0}/tests/test_association.py +44 -1
  18. {pase_framework-1.1.1 → pase_framework-1.2.0}/.github/workflows/publish.yml +0 -0
  19. {pase_framework-1.1.1 → pase_framework-1.2.0}/.github/workflows/tests.yml +0 -0
  20. {pase_framework-1.1.1 → pase_framework-1.2.0}/.readthedocs.yaml +0 -0
  21. {pase_framework-1.1.1 → pase_framework-1.2.0}/LICENSE +0 -0
  22. {pase_framework-1.1.1 → pase_framework-1.2.0}/MANIFEST.in +0 -0
  23. {pase_framework-1.1.1 → pase_framework-1.2.0}/THIRD_PARTY_DATA.md +0 -0
  24. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/api.rst +0 -0
  25. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/conf.py +0 -0
  26. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/index.md +0 -0
  27. {pase_framework-1.1.1 → pase_framework-1.2.0}/docs/statistics.md +0 -0
  28. {pase_framework-1.1.1 → pase_framework-1.2.0}/examples/build_gse234933_subset.py +0 -0
  29. {pase_framework-1.1.1 → pase_framework-1.2.0}/examples/gse234933_quickstart.ipynb +0 -0
  30. {pase_framework-1.1.1 → pase_framework-1.2.0}/scripts/check_docs.py +0 -0
  31. {pase_framework-1.1.1 → pase_framework-1.2.0}/scripts/run_tutorial.py +0 -0
  32. {pase_framework-1.1.1 → pase_framework-1.2.0}/setup.cfg +0 -0
  33. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/_statistics.py +0 -0
  34. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/data/DATA_NOTICE.md +0 -0
  35. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/data/gse234933_demo.npz +0 -0
  36. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/data/gse234933_demo_manifest.json +0 -0
  37. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/data/gse234933_demo_obs.tsv +0 -0
  38. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/datasets.py +0 -0
  39. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase/result.py +0 -0
  40. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase_framework.egg-info/SOURCES.txt +0 -0
  41. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase_framework.egg-info/dependency_links.txt +0 -0
  42. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase_framework.egg-info/requires.txt +0 -0
  43. {pase_framework-1.1.1 → pase_framework-1.2.0}/src/pase_framework.egg-info/top_level.txt +0 -0
  44. {pase_framework-1.1.1 → pase_framework-1.2.0}/tests/test_datasets.py +0 -0
  45. {pase_framework-1.1.1 → pase_framework-1.2.0}/tests/test_reporting.py +0 -0
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.0
4
+
5
+ - Added `standardize_before_mask` to `associate()`. The default estimates
6
+ patient-specific module means and sample SDs before applying the cell mask,
7
+ matching the order in the manuscript. Pass `False` for PASE 1.1.x behavior.
8
+ - Recorded the chosen standardization order and reference set in result
9
+ metadata. Ungated and single-gene association estimates are unchanged.
10
+
3
11
  ## 1.1.1
4
12
 
5
13
  - Corrected the environment commands for Windows, macOS and Linux.
@@ -2,9 +2,9 @@ cff-version: 1.2.0
2
2
  message: "Please cite this software and the version-specific release URL or DOI accompanying the version used."
3
3
  type: software
4
4
  title: "PASE: patient-level association estimation"
5
- version: 1.1.1
5
+ version: 1.2.0
6
6
  repository-code: "https://github.com/tjw0613-cell/pase-software"
7
- url: "https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1"
7
+ url: "https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0"
8
8
  authors:
9
9
  - family-names: Tang
10
10
  given-names: Jinwei
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pase-framework
3
- Version: 1.1.1
3
+ Version: 1.2.0
4
4
  Summary: Patient-level association estimates for multi-patient single-cell studies
5
5
  Author: Jinwei Tang, Yunfan Lin, Linrui Cai, Yali Wen, Guangyang Chen, Li Huang
6
6
  License-Expression: MIT
@@ -53,30 +53,28 @@ for installation, the API and the statistical meaning of each parameter.
53
53
  ## Installation
54
54
 
55
55
  Use Python 3.10 or later in a fresh environment. Install the published release
56
- from [PyPI](https://pypi.org/project/pase-framework/1.1.1/):
56
+ from [PyPI](https://pypi.org/project/pase-framework/1.2.0/).
57
57
 
58
58
  Windows PowerShell:
59
59
 
60
60
  ```powershell
61
61
  python -m venv .venv
62
- .\.venv\Scripts\python.exe -m pip install pase-framework==1.1.1
62
+ .\.venv\Scripts\python.exe -m pip install pase-framework==1.2.0
63
63
  ```
64
64
 
65
65
  macOS or Linux:
66
66
 
67
67
  ```bash
68
68
  python3 -m venv .venv
69
- .venv/bin/python -m pip install pase-framework==1.1.1
69
+ .venv/bin/python -m pip install pase-framework==1.2.0
70
70
  ```
71
71
 
72
- These commands use the new environment directly; activation is not required.
73
- Version 1.1.1 updates the documentation and packaging only. Statistical code
74
- and bundled data are unchanged from 1.1.0, which was used for the manuscript.
72
+ These commands run Python directly from the new environment.
75
73
 
76
74
  The distribution is named **pase-framework**, but the Python import is `pase`.
77
75
  The unrelated audio package named `pase` on PyPI uses the same import name;
78
76
  do not install both in one environment. The
79
- [v1.1.1 release](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1)
77
+ [v1.2.0 release](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0)
80
78
  is also available on GitHub. For development, clone this repository and use
81
79
  `python -m pip install -e ".[test]"`.
82
80
 
@@ -102,12 +100,10 @@ Run it with `.\.venv\Scripts\python.exe quickstart.py` on Windows or
102
100
  `.venv/bin/python quickstart.py` on macOS/Linux. It prints the cohort summary
103
101
  and patient table and saves a forest plot as `association.pdf`.
104
102
 
105
- The bundled GSE234933 subset contains real cells and works without a download.
106
- The four-gene target above illustrates the interface; it is not the current
107
- manuscript's 15-gene signature. The
108
- [tutorial notebook](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/examples/gse234933_quickstart.ipynb)
109
- uses the 15-gene list on this small teaching subset. For the complete cohort
110
- analyses, use the [RNA workflow](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/rna).
103
+ The example uses four genes from the bundled GSE234933 teaching dataset.
104
+ The [tutorial notebook](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/examples/gse234933_quickstart.ipynb)
105
+ uses the manuscript's 15-gene score on the same subset. For the complete
106
+ cohort analyses, use the [RNA workflow](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/rna).
111
107
  See the [quick-start guide](https://pase-software.readthedocs.io/en/latest/quickstart.html)
112
108
  for notebook installation and execution.
113
109
 
@@ -126,6 +122,14 @@ genes. `associate` does not normalize raw counts.
126
122
  | `adata.obs["myeloid"]` | Boolean cell-selection column. Patients with no selected cells remain in the output. |
127
123
  | `anchor` | One gene name. |
128
124
  | `target` | One gene name, or a list whose within-patient gene z scores are averaged. |
125
+ | `standardize_before_mask` | `True` uses all input cells with complete expression in each patient as the standardization reference. `False` uses the mask-selected cells. |
126
+
127
+ For the gated manuscript analysis, supply the ungated myeloid population as
128
+ the input and pass the detection gate as `cell_mask`. In version 1.2.0 the
129
+ module score uses the same reference population in the ungated and gated fits
130
+ by default. Set `standardize_before_mask=False` to recover the masked-score
131
+ behavior of PASE 1.1.x. This option changes only the scaling of masked gene
132
+ lists. See [score construction](https://pase-software.readthedocs.io/en/latest/inputs.html#scores-covariates-and-missing-values).
129
133
 
130
134
  Covariates enter a separate least-squares model for each patient, with an
131
135
  intercept. Encode categorical covariates as numeric dummy variables; integer
@@ -175,32 +179,31 @@ power, and is not provided for Fisher or EB targets.
175
179
  ## Reproduce the manuscript
176
180
 
177
181
  The [reproduction repository](https://github.com/tjw0613-cell/pase-reproducibility)
178
- contains figure commands and the full 15-gene RNA workflow. The software
179
- tutorial above is a smaller example, not a reproduction of all paper results.
182
+ contains figure commands and the full 15-gene RNA workflow.
183
+ The [public API example](https://github.com/tjw0613-cell/pase-reproducibility/blob/main/workflows/h/public_api_example.py)
184
+ recreates the manuscript's RNA associations from the prepared cohort caches.
185
+ Use the [workflow instructions](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/h)
186
+ to download the GEO data, build those caches and run the comparison.
180
187
 
181
188
  - [Simulation protocol, version 2.0.0](https://doi.org/10.5281/zenodo.24010816):
182
189
  the design archived before the formal simulations.
183
190
  - [Core results and reproducibility materials](https://doi.org/10.5281/zenodo.24015713):
184
191
  the subsequent code and results archive, including PASE 1.1.0.
185
- - Supplementary Data S1 and S2 accompany the revised manuscript. They contain
186
- the detection-matched gene analysis and unequal-yield native count benchmark,
187
- respectively, and are not included in the core-results DOI above.
192
+ - Supplementary Data S1 contains the detection-matched gene analysis.
193
+ Supplementary Data S2 contains the unequal-yield native count benchmark.
188
194
 
189
195
  See [reproduction instructions](https://pase-software.readthedocs.io/en/latest/reproducibility.html)
190
196
  for the scope of each workflow and the software test commands.
191
197
 
192
198
  ## Citation
193
199
 
194
- For this code, cite the authors, PASE software version **1.1.1**, and its
195
- [release URL](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1).
200
+ For this code, cite the authors, PASE software version **1.2.0**, and its
201
+ [release URL](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0).
196
202
  Machine-readable author information is in
197
- [CITATION.cff](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/CITATION.cff).
198
- An earlier analysis archive is
199
- available at [Zenodo v3](https://doi.org/10.5281/zenodo.23032874); that DOI does
200
- not identify this 1.1.1 software release.
203
+ [CITATION.cff](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/CITATION.cff).
201
204
 
202
205
  Code is distributed under the MIT License. The real-data example retains its
203
206
  source attribution and third-party terms; see
204
- [THIRD_PARTY_DATA.md](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/THIRD_PARTY_DATA.md).
207
+ [THIRD_PARTY_DATA.md](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/THIRD_PARTY_DATA.md).
205
208
  Report software problems through [GitHub Issues](https://github.com/tjw0613-cell/pase-software/issues).
206
209
 
@@ -8,30 +8,28 @@ for installation, the API and the statistical meaning of each parameter.
8
8
  ## Installation
9
9
 
10
10
  Use Python 3.10 or later in a fresh environment. Install the published release
11
- from [PyPI](https://pypi.org/project/pase-framework/1.1.1/):
11
+ from [PyPI](https://pypi.org/project/pase-framework/1.2.0/).
12
12
 
13
13
  Windows PowerShell:
14
14
 
15
15
  ```powershell
16
16
  python -m venv .venv
17
- .\.venv\Scripts\python.exe -m pip install pase-framework==1.1.1
17
+ .\.venv\Scripts\python.exe -m pip install pase-framework==1.2.0
18
18
  ```
19
19
 
20
20
  macOS or Linux:
21
21
 
22
22
  ```bash
23
23
  python3 -m venv .venv
24
- .venv/bin/python -m pip install pase-framework==1.1.1
24
+ .venv/bin/python -m pip install pase-framework==1.2.0
25
25
  ```
26
26
 
27
- These commands use the new environment directly; activation is not required.
28
- Version 1.1.1 updates the documentation and packaging only. Statistical code
29
- and bundled data are unchanged from 1.1.0, which was used for the manuscript.
27
+ These commands run Python directly from the new environment.
30
28
 
31
29
  The distribution is named **pase-framework**, but the Python import is `pase`.
32
30
  The unrelated audio package named `pase` on PyPI uses the same import name;
33
31
  do not install both in one environment. The
34
- [v1.1.1 release](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1)
32
+ [v1.2.0 release](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0)
35
33
  is also available on GitHub. For development, clone this repository and use
36
34
  `python -m pip install -e ".[test]"`.
37
35
 
@@ -57,12 +55,10 @@ Run it with `.\.venv\Scripts\python.exe quickstart.py` on Windows or
57
55
  `.venv/bin/python quickstart.py` on macOS/Linux. It prints the cohort summary
58
56
  and patient table and saves a forest plot as `association.pdf`.
59
57
 
60
- The bundled GSE234933 subset contains real cells and works without a download.
61
- The four-gene target above illustrates the interface; it is not the current
62
- manuscript's 15-gene signature. The
63
- [tutorial notebook](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/examples/gse234933_quickstart.ipynb)
64
- uses the 15-gene list on this small teaching subset. For the complete cohort
65
- analyses, use the [RNA workflow](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/rna).
58
+ The example uses four genes from the bundled GSE234933 teaching dataset.
59
+ The [tutorial notebook](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/examples/gse234933_quickstart.ipynb)
60
+ uses the manuscript's 15-gene score on the same subset. For the complete
61
+ cohort analyses, use the [RNA workflow](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/rna).
66
62
  See the [quick-start guide](https://pase-software.readthedocs.io/en/latest/quickstart.html)
67
63
  for notebook installation and execution.
68
64
 
@@ -81,6 +77,14 @@ genes. `associate` does not normalize raw counts.
81
77
  | `adata.obs["myeloid"]` | Boolean cell-selection column. Patients with no selected cells remain in the output. |
82
78
  | `anchor` | One gene name. |
83
79
  | `target` | One gene name, or a list whose within-patient gene z scores are averaged. |
80
+ | `standardize_before_mask` | `True` uses all input cells with complete expression in each patient as the standardization reference. `False` uses the mask-selected cells. |
81
+
82
+ For the gated manuscript analysis, supply the ungated myeloid population as
83
+ the input and pass the detection gate as `cell_mask`. In version 1.2.0 the
84
+ module score uses the same reference population in the ungated and gated fits
85
+ by default. Set `standardize_before_mask=False` to recover the masked-score
86
+ behavior of PASE 1.1.x. This option changes only the scaling of masked gene
87
+ lists. See [score construction](https://pase-software.readthedocs.io/en/latest/inputs.html#scores-covariates-and-missing-values).
84
88
 
85
89
  Covariates enter a separate least-squares model for each patient, with an
86
90
  intercept. Encode categorical covariates as numeric dummy variables; integer
@@ -130,32 +134,31 @@ power, and is not provided for Fisher or EB targets.
130
134
  ## Reproduce the manuscript
131
135
 
132
136
  The [reproduction repository](https://github.com/tjw0613-cell/pase-reproducibility)
133
- contains figure commands and the full 15-gene RNA workflow. The software
134
- tutorial above is a smaller example, not a reproduction of all paper results.
137
+ contains figure commands and the full 15-gene RNA workflow.
138
+ The [public API example](https://github.com/tjw0613-cell/pase-reproducibility/blob/main/workflows/h/public_api_example.py)
139
+ recreates the manuscript's RNA associations from the prepared cohort caches.
140
+ Use the [workflow instructions](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/h)
141
+ to download the GEO data, build those caches and run the comparison.
135
142
 
136
143
  - [Simulation protocol, version 2.0.0](https://doi.org/10.5281/zenodo.24010816):
137
144
  the design archived before the formal simulations.
138
145
  - [Core results and reproducibility materials](https://doi.org/10.5281/zenodo.24015713):
139
146
  the subsequent code and results archive, including PASE 1.1.0.
140
- - Supplementary Data S1 and S2 accompany the revised manuscript. They contain
141
- the detection-matched gene analysis and unequal-yield native count benchmark,
142
- respectively, and are not included in the core-results DOI above.
147
+ - Supplementary Data S1 contains the detection-matched gene analysis.
148
+ Supplementary Data S2 contains the unequal-yield native count benchmark.
143
149
 
144
150
  See [reproduction instructions](https://pase-software.readthedocs.io/en/latest/reproducibility.html)
145
151
  for the scope of each workflow and the software test commands.
146
152
 
147
153
  ## Citation
148
154
 
149
- For this code, cite the authors, PASE software version **1.1.1**, and its
150
- [release URL](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1).
155
+ For this code, cite the authors, PASE software version **1.2.0**, and its
156
+ [release URL](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0).
151
157
  Machine-readable author information is in
152
- [CITATION.cff](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/CITATION.cff).
153
- An earlier analysis archive is
154
- available at [Zenodo v3](https://doi.org/10.5281/zenodo.23032874); that DOI does
155
- not identify this 1.1.1 software release.
158
+ [CITATION.cff](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/CITATION.cff).
156
159
 
157
160
  Code is distributed under the MIT License. The real-data example retains its
158
161
  source attribution and third-party terms; see
159
- [THIRD_PARTY_DATA.md](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/THIRD_PARTY_DATA.md).
162
+ [THIRD_PARTY_DATA.md](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/THIRD_PARTY_DATA.md).
160
163
  Report software problems through [GitHub Issues](https://github.com/tjw0613-cell/pase-software/issues).
161
164
 
@@ -39,28 +39,36 @@ retain one inference unit per independent patient. Missing IDs are an error.
39
39
 
40
40
  `cell_mask` is either a boolean `obs` column or a boolean vector in the same
41
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.
42
+ mask values are rejected. All observed patient IDs remain in the output even
43
+ when none of their cells satisfy the mask. Use `patient_ids` to retain patients
44
+ whose cells were removed before calling PASE.
45
45
 
46
46
  ## Scores, covariates and missing values
47
47
 
48
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.
49
+ standardizing each component within the patient using its sample standard
50
+ deviation (`ddof=1`) and averaging the z scores. A measured gene that is
51
+ constant in the standardization population contributes zero. Missing genes
52
+ raise an error.
53
+
54
+ By default, `standardize_before_mask=True` uses all cells in each patient's
55
+ input with finite anchor and target expression to calculate means and standard
56
+ deviations. The mask then defines which cells enter the association fit. Use
57
+ this order to compare the ungated and gated associations on the same score.
58
+ For example, provide an AnnData object already restricted to quality-filtered
59
+ myeloid cells, and pass the outcome-detection gate as `cell_mask`. Include
60
+ absent patients with `patient_ids` when you prefilter the reference population.
61
+
62
+ Set `standardize_before_mask=False` to compute the score only from the
63
+ mask-selected finite-expression cells, as in PASE 1.1.x. This is useful when
64
+ the mask defines the population in which you want to standardize. The two
65
+ settings agree for ungated fits and for single-gene string targets.
66
+
67
+ In both orders, covariate complete-case filtering follows standardization.
68
+ PASE residualizes the anchor and score on the same numeric covariates and
69
+ intercept within each patient, then correlates the residuals and applies the
70
+ eligibility rules. The caller supplies any outcome-detection gate. PASE accepts
71
+ numeric covariates, including explicit dummy variables.
64
72
  For a categorical covariate, create numeric dummy variables with a reference
65
73
  category. Passing integer labels such as 0, 1 and 2 instead fits a numeric trend.
66
74
  Within each patient's complete cases, nuisance columns are centered and scaled
@@ -68,6 +68,9 @@ individual intervals in the equal or random-effects forest plot.
68
68
 
69
69
  ## Saving tables and metadata
70
70
 
71
+ `result.metadata` records `standardize_before_mask` and the cell population
72
+ used to construct the score in `score_standardization`.
73
+
71
74
  ```python
72
75
  import json
73
76
  result.summary().to_csv("summary.tsv", sep="\t", index=False)
@@ -7,14 +7,14 @@ Windows PowerShell:
7
7
 
8
8
  ```powershell
9
9
  python -m venv .venv
10
- .\.venv\Scripts\python.exe -m pip install "pase-framework[tutorial]==1.1.1"
10
+ .\.venv\Scripts\python.exe -m pip install "pase-framework[tutorial]==1.2.0"
11
11
  ```
12
12
 
13
13
  macOS or Linux:
14
14
 
15
15
  ```bash
16
16
  python3 -m venv .venv
17
- .venv/bin/python -m pip install "pase-framework[tutorial]==1.1.1"
17
+ .venv/bin/python -m pip install "pase-framework[tutorial]==1.2.0"
18
18
  ```
19
19
 
20
20
  The package distribution is `pase-framework`; the Python module is `pase`.
@@ -42,7 +42,7 @@ This is an interface example using real cells, not a full-cohort analysis.
42
42
  The four-gene target demonstrates module input; the revised manuscript's main
43
43
  biological analysis uses a separately sourced 15-gene signature.
44
44
 
45
- Download [the tutorial notebook](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/examples/gse234933_quickstart.ipynb)
45
+ Download [the tutorial notebook](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/examples/gse234933_quickstart.ipynb)
46
46
  into the working directory, then open it with JupyterLab:
47
47
 
48
48
  ```powershell
@@ -2,15 +2,17 @@
2
2
 
3
3
  ## Release records
4
4
 
5
- Version 1.1.1 corrects documentation and packaging. Statistical code, reporting
6
- defaults and bundled data are unchanged from 1.1.0, the version used for the
7
- manuscript analyses.
5
+ Version 1.2.0 adds the `standardize_before_mask` option. Its default implements
6
+ the manuscript's score-before-gate order. Set it to `False` to reproduce the
7
+ masked module behavior of the 1.1 series.
8
+
9
+ Version 1.1.1 corrected documentation and packaging for 1.1.0.
8
10
 
9
11
  Version 1.1.0 changes reporting defaults and adds precision warnings and a
10
- model-based planning MDE. See [the changelog](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/CHANGELOG.md)
12
+ model-based planning MDE. See [the changelog](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/CHANGELOG.md)
11
13
  and [reporting policy](reporting-policy.md) before upgrading an existing workflow.
12
- Release artifacts are indexed on [PyPI](https://pypi.org/project/pase-framework/1.1.1/)
13
- and [GitHub](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1).
14
+ Release artifacts are indexed on [PyPI](https://pypi.org/project/pase-framework/1.2.0/)
15
+ and [GitHub](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0).
14
16
  Check the actual [release workflow results](https://github.com/tjw0613-cell/pase-software/actions/workflows/publish.yml)
15
17
  for cross-platform tests and upload status; the configuration alone is not proof
16
18
  that a run passed.
@@ -56,7 +58,7 @@ verify the project page, download the published distribution and repeat the
56
58
  quick example in a fresh environment using:
57
59
 
58
60
  ```bash
59
- python -m pip install pase-framework==1.1.1
61
+ python -m pip install pase-framework==1.2.0
60
62
  ```
61
63
 
62
64
  Repeat the clean installation check for each future version before updating
@@ -1,6 +1,6 @@
1
1
  # Reporting policy
2
2
 
3
- Version 1.1.0 uses the number of **eligible patients for the selected method**
3
+ PASE uses the number of **eligible patients for the selected method**
4
4
  to decide what to report. The attempted cohort size cannot satisfy this check.
5
5
  These defaults are result-informed reporting choices, not validated guarantees.
6
6
 
@@ -41,10 +41,9 @@ registered floor-2/4/6 counts. This verifies the extraction of the policy
41
41
  evidence, not the statistical adequacy of the chosen reporting rules.
42
42
 
43
43
  The formal main workflow used a fixed 15-gene outcome and depth-only
44
- adjustment. Arbitrary API gene sets, covariates, normalization choices or
45
- outcome-dependent masks are outside a universal calibration claim. In
46
- particular, `cell_mask` is applied before within-patient score standardization;
47
- it does not reproduce the formal outcome gate applied after score construction.
44
+ adjustment. Other choices of genes, covariates, normalization and cell masks
45
+ can change coverage. PASE 1.2.0 defaults to standardizing before applying
46
+ `cell_mask`, the order used in the manuscript's gated analysis.
48
47
 
49
48
  ## Planning MDE
50
49
 
@@ -8,10 +8,11 @@ scripts and the inputs used by those scripts.
8
8
 
9
9
  | Material | Where to find it | What it covers |
10
10
  |---|---|---|
11
- | PASE 1.1.1 software | [GitHub release](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1) and [PyPI](https://pypi.org/project/pase-framework/1.1.1/) | The reusable API and teaching dataset; documentation-only update of the 1.1.0 software used in the manuscript. |
11
+ | PASE 1.2.0 software | [GitHub release](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0) and [PyPI](https://pypi.org/project/pase-framework/1.2.0/) | The reusable API and teaching dataset. The public API supports the manuscript's reference population and score-then-gate order. |
12
12
  | Simulation protocol 2.0.0 | [Zenodo 24010816](https://doi.org/10.5281/zenodo.24010816) | The design archived before the formal simulations. |
13
13
  | Core results and reproduction materials | [Zenodo 24015713](https://doi.org/10.5281/zenodo.24015713) | The subsequent software and results deposit; it includes PASE 1.1.0. |
14
14
  | Full 15-gene RNA analyses | [RNA workflow](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/rna) | Input downloads, signature source, preprocessing, fitting and result comparisons for the three cohorts. |
15
+ | Public API reproduction | [Example script](https://github.com/tjw0613-cell/pase-reproducibility/blob/main/workflows/h/public_api_example.py) and [workflow instructions](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/h) | Compares the public API with archived patient effects and cohort summaries using caches built from the GEO data. |
15
16
  | Supplementary Data S1 and S2 | Files accompanying the revised manuscript | Detection-matched gene controls and the unequal-yield native count benchmark. These later analyses are not in the core-results DOI above. |
16
17
 
17
18
  The four-gene README example demonstrates the interface. The notebook uses
@@ -30,8 +31,7 @@ python -m pytest
30
31
  Tests cover independent calculation examples, sparse/dense parity, patient
31
32
  exclusions, cell duplication, model boundaries, input validation and lack of
32
33
  input mutation. The CI configuration requests Linux, macOS and Windows runs
33
- across Python versions. A workflow file is not evidence that those remote runs
34
- have passed; use the actual run logs for that claim.
34
+ across Python versions. See the [CI run logs](https://github.com/tjw0613-cell/pase-software/actions/workflows/tests.yml).
35
35
 
36
36
  ## Run the tutorial
37
37
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pase-framework"
7
- version = "1.1.1"
7
+ version = "1.2.0"
8
8
  description = "Patient-level association estimates for multi-patient single-cell studies"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -12,7 +12,7 @@ import tarfile
12
12
  from urllib.parse import urlparse
13
13
  from urllib.request import urlopen
14
14
 
15
- VERSION = "1.1.1"
15
+ VERSION = "1.2.0"
16
16
 
17
17
 
18
18
  def main():
@@ -4,5 +4,5 @@ from .association import associate
4
4
  from .result import AssociationResult
5
5
  from . import datasets
6
6
 
7
- __version__ = "1.1.1"
7
+ __version__ = "1.2.0"
8
8
  __all__ = ["associate", "AssociationResult", "datasets", "__version__"]
@@ -14,15 +14,10 @@ DEFAULT_MIN_PATIENTS = 6
14
14
  SMALL_COHORT_WARNING_BELOW = 20
15
15
  VALIDATION_SCOPE = (
16
16
  "A simulation-informed reporting policy, not a calibration guarantee. "
17
- "The default floor of six was a registered reporting candidate, not an "
18
- "independently validated minimum for reliable inference. The warning below "
19
- "20 eligible patients is a post-result risk flag; reaching 20 does not certify "
20
- "coverage. The formal main simulation used a fixed 15-gene score and "
21
- "depth-only adjustment. Arbitrary modules, covariates and masks in this API "
22
- "are not covered by that validation. This API standardizes modules after "
23
- "cell_mask selection; the formal outcome-gating experiment standardized "
24
- "before its gate. The configurable interval-width tolerance is a reporting "
25
- "preference, not a simulation-calibrated cutoff."
17
+ "The default floor of six and warning below 20 eligible patients were chosen "
18
+ "after examining the simulations. The formal main simulation used a fixed "
19
+ "15-gene score and depth-only adjustment. Coverage can differ with other "
20
+ "scores, covariates and masks. The interval-width tolerance is configurable."
26
21
  )
27
22
  MDE_SCOPE = (
28
23
  "Planning calculation for a two-sided one-sample t test of a zero equal-patient "
@@ -203,7 +198,7 @@ def add_reporting(summary, patients, metadata, *, max_ci_width,
203
198
  "small_cohort_warning_below": SMALL_COHORT_WARNING_BELOW,
204
199
  "width_tolerance": max_ci_width,
205
200
  "protocol_doi": "10.5281/zenodo.24010816",
206
- "policy_basis": "registered candidate floor; post-result risk warning; configurable width preference",
201
+ "policy_basis": "simulation-informed reporting defaults and configurable width tolerance",
207
202
  },
208
203
  )
209
204
  metadata["warnings"].extend(messages)
@@ -92,7 +92,8 @@ def _partial_correlation(x, y, design):
92
92
  return correlation, rank, residual_df, None
93
93
 
94
94
 
95
- def _patient_effect(pid, indices, mask, expression, covariate_values, module, min_cells):
95
+ def _patient_effect(pid, indices, mask, expression, covariate_values, module, min_cells,
96
+ standardize_before_mask):
96
97
  selected = indices[mask[indices]]
97
98
  result = dict(patient_id=pid, n_total=len(indices), n_selected=len(selected),
98
99
  n_expression_complete=0, n_complete=0, n_cells=0,
@@ -117,9 +118,13 @@ def _patient_effect(pid, indices, mask, expression, covariate_values, module, mi
117
118
  x = values[:, 0]
118
119
  if module:
119
120
  outcomes = values[:, 1:]
120
- centered = outcomes - outcomes.mean(axis=0)
121
- scale = outcomes.std(axis=0, ddof=1) if len(outcomes) > 1 else np.zeros(outcomes.shape[1])
122
- varying = np.ptp(outcomes, axis=0) != 0
121
+ reference = outcomes
122
+ if standardize_before_mask and result["n_selected"] != len(indices):
123
+ patient_expression = expression[indices]
124
+ reference = patient_expression[np.isfinite(patient_expression).all(axis=1), 1:]
125
+ centered = outcomes - reference.mean(axis=0)
126
+ scale = reference.std(axis=0, ddof=1) if len(reference) > 1 else np.zeros(outcomes.shape[1])
127
+ varying = np.ptp(reference, axis=0) != 0
123
128
  standardized = np.divide(centered, scale, out=np.zeros_like(centered),
124
129
  where=varying & (scale > 0))
125
130
  y = standardized.mean(axis=1)
@@ -155,7 +160,7 @@ def _patient_effect(pid, indices, mask, expression, covariate_values, module, mi
155
160
 
156
161
  def associate(adata, anchor, target, patient_key, covariates=None, cell_mask=None,
157
162
  aggregate="equal", min_cells=30, min_patients=DEFAULT_MIN_PATIENTS, layer=None,
158
- alpha=0.05, patient_ids=None, *, max_ci_width=0.2,
163
+ alpha=0.05, patient_ids=None, *, standardize_before_mask=True, max_ci_width=0.2,
159
164
  minimum_relevant_effect=None, planning_sd=None, planning_power=0.8,
160
165
  planning_sd_source=None):
161
166
  """Estimate an association within each patient and summarize across patients.
@@ -200,6 +205,14 @@ def associate(adata, anchor, target, patient_key, covariates=None, cell_mask=Non
200
205
  patient_ids : sequence, optional
201
206
  Additional patient IDs to retain even if they have no observed cells.
202
207
  Observed IDs are always retained. Output IDs are strings.
208
+ standardize_before_mask : bool, keyword-only, default True
209
+ Calculate the within-patient module means and sample SDs in all input
210
+ cells with finite anchor and target expression, then use ``cell_mask``
211
+ to select cells for fitting. Pass the intended reference population as
212
+ ``adata`` (for example, quality-filtered myeloid cells). Set False to
213
+ estimate module means and SDs in the selected cells, as in PASE 1.1.x.
214
+ This option affects masked analyses of gene lists. In both modes,
215
+ standardization precedes covariate complete-case filtering.
203
216
  max_ci_width : float or None, keyword-only, default 0.2
204
217
  Warn when an available cohort interval exceeds this correlation-scale
205
218
  width. Must be positive and finite; None disables this warning. The
@@ -228,8 +241,9 @@ def associate(adata, anchor, target, patient_key, covariates=None, cell_mask=Non
228
241
  Notes
229
242
  -----
230
243
  Cells with nonfinite anchor or target expression are excluded before module
231
- construction. Nonfinite covariates are then excluded. There is no outcome
232
- detection gate. Fisher variance is approximated as 1/(n-k-3), with k equal
244
+ construction. Nonfinite covariates are excluded when fitting the nuisance
245
+ models. An outcome-detection gate can be supplied as ``cell_mask``. Fisher
246
+ variance is approximated as 1/(n-k-3), with k equal
233
247
  to design rank minus one; its independent-cell assumptions may not hold for
234
248
  all single-cell data. Raw patient correlations remain visible when cohort
235
249
  inference is withheld. Inputs are not modified.
@@ -242,6 +256,9 @@ def associate(adata, anchor, target, patient_key, covariates=None, cell_mask=Non
242
256
  """
243
257
  min_cells = _integer(min_cells, "min_cells", 1)
244
258
  min_patients = _integer(min_patients, "min_patients", 2)
259
+ if not isinstance(standardize_before_mask, (bool, np.bool_)):
260
+ raise TypeError("standardize_before_mask must be a boolean.")
261
+ standardize_before_mask = bool(standardize_before_mask)
245
262
  if isinstance(alpha, (bool, np.bool_)) or not isinstance(alpha, Real) or not 0 < alpha < 1:
246
263
  raise ValueError("alpha must be a finite number strictly between zero and one.")
247
264
  (max_ci_width, minimum_relevant_effect, planning_sd,
@@ -310,7 +327,7 @@ def associate(adata, anchor, target, patient_key, covariates=None, cell_mask=Non
310
327
  for index, pid in enumerate(ids):
311
328
  groups[pid].append(index)
312
329
  records = [_patient_effect(pid, np.asarray(indices, dtype=int), selected_mask,
313
- expression, nuisance, module, min_cells)
330
+ expression, nuisance, module, min_cells, standardize_before_mask)
314
331
  for pid, indices in groups.items()]
315
332
  # The statistical kernel retains the verified rank-aware Fisher variance
316
333
  # and equal-r / REML / HK calculations used by the standalone implementation.
@@ -385,13 +402,18 @@ def associate(adata, anchor, target, patient_key, covariates=None, cell_mask=Non
385
402
  warnings.append("EB intervals condition on fitted population parameters and omit their estimation uncertainty.")
386
403
  if patients.n_nonfinite_expression.sum() or patients.n_nonfinite_covariates.sum():
387
404
  warnings.append("Nonfinite expression or covariates excluded cells; see per-patient complete-case counts.")
405
+ score_standardization = "Not applicable to a single-gene target"
406
+ if module:
407
+ reference = "All input cells" if standardize_before_mask else "Mask-selected cells"
408
+ score_standardization = f"{reference} with finite anchor and all target genes; before covariate complete cases"
388
409
  metadata = dict(anchor=anchor, target_genes=targets,
389
410
  target_label=targets[0] if not module else "mean z score (" + ", ".join(targets) + ")",
390
411
  target_definition=target_definition,
391
412
  target_score="within-patient mean z score; ddof=1; constant genes contribute zero" if module else "single transformed gene",
392
413
  expression="Pretransformed input; no normalization performed",
393
414
  expression_source="X" if layer is None else f"layers[{layer!r}]",
394
- score_standardization="Selected cells with finite anchor and all target genes; before covariate complete cases",
415
+ standardize_before_mask=standardize_before_mask,
416
+ score_standardization=score_standardization,
395
417
  patient_key=patient_key, covariates=covariates, cell_mask=cell_mask if isinstance(cell_mask, str) else "provided vector" if cell_mask is not None else None,
396
418
  covariate_standardization="Centered and scaled within patient complete cases; constant columns omitted",
397
419
  aggregate=aggregate, min_cells=min_cells, min_patients=min_patients,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pase-framework
3
- Version: 1.1.1
3
+ Version: 1.2.0
4
4
  Summary: Patient-level association estimates for multi-patient single-cell studies
5
5
  Author: Jinwei Tang, Yunfan Lin, Linrui Cai, Yali Wen, Guangyang Chen, Li Huang
6
6
  License-Expression: MIT
@@ -53,30 +53,28 @@ for installation, the API and the statistical meaning of each parameter.
53
53
  ## Installation
54
54
 
55
55
  Use Python 3.10 or later in a fresh environment. Install the published release
56
- from [PyPI](https://pypi.org/project/pase-framework/1.1.1/):
56
+ from [PyPI](https://pypi.org/project/pase-framework/1.2.0/).
57
57
 
58
58
  Windows PowerShell:
59
59
 
60
60
  ```powershell
61
61
  python -m venv .venv
62
- .\.venv\Scripts\python.exe -m pip install pase-framework==1.1.1
62
+ .\.venv\Scripts\python.exe -m pip install pase-framework==1.2.0
63
63
  ```
64
64
 
65
65
  macOS or Linux:
66
66
 
67
67
  ```bash
68
68
  python3 -m venv .venv
69
- .venv/bin/python -m pip install pase-framework==1.1.1
69
+ .venv/bin/python -m pip install pase-framework==1.2.0
70
70
  ```
71
71
 
72
- These commands use the new environment directly; activation is not required.
73
- Version 1.1.1 updates the documentation and packaging only. Statistical code
74
- and bundled data are unchanged from 1.1.0, which was used for the manuscript.
72
+ These commands run Python directly from the new environment.
75
73
 
76
74
  The distribution is named **pase-framework**, but the Python import is `pase`.
77
75
  The unrelated audio package named `pase` on PyPI uses the same import name;
78
76
  do not install both in one environment. The
79
- [v1.1.1 release](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1)
77
+ [v1.2.0 release](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0)
80
78
  is also available on GitHub. For development, clone this repository and use
81
79
  `python -m pip install -e ".[test]"`.
82
80
 
@@ -102,12 +100,10 @@ Run it with `.\.venv\Scripts\python.exe quickstart.py` on Windows or
102
100
  `.venv/bin/python quickstart.py` on macOS/Linux. It prints the cohort summary
103
101
  and patient table and saves a forest plot as `association.pdf`.
104
102
 
105
- The bundled GSE234933 subset contains real cells and works without a download.
106
- The four-gene target above illustrates the interface; it is not the current
107
- manuscript's 15-gene signature. The
108
- [tutorial notebook](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/examples/gse234933_quickstart.ipynb)
109
- uses the 15-gene list on this small teaching subset. For the complete cohort
110
- analyses, use the [RNA workflow](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/rna).
103
+ The example uses four genes from the bundled GSE234933 teaching dataset.
104
+ The [tutorial notebook](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/examples/gse234933_quickstart.ipynb)
105
+ uses the manuscript's 15-gene score on the same subset. For the complete
106
+ cohort analyses, use the [RNA workflow](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/rna).
111
107
  See the [quick-start guide](https://pase-software.readthedocs.io/en/latest/quickstart.html)
112
108
  for notebook installation and execution.
113
109
 
@@ -126,6 +122,14 @@ genes. `associate` does not normalize raw counts.
126
122
  | `adata.obs["myeloid"]` | Boolean cell-selection column. Patients with no selected cells remain in the output. |
127
123
  | `anchor` | One gene name. |
128
124
  | `target` | One gene name, or a list whose within-patient gene z scores are averaged. |
125
+ | `standardize_before_mask` | `True` uses all input cells with complete expression in each patient as the standardization reference. `False` uses the mask-selected cells. |
126
+
127
+ For the gated manuscript analysis, supply the ungated myeloid population as
128
+ the input and pass the detection gate as `cell_mask`. In version 1.2.0 the
129
+ module score uses the same reference population in the ungated and gated fits
130
+ by default. Set `standardize_before_mask=False` to recover the masked-score
131
+ behavior of PASE 1.1.x. This option changes only the scaling of masked gene
132
+ lists. See [score construction](https://pase-software.readthedocs.io/en/latest/inputs.html#scores-covariates-and-missing-values).
129
133
 
130
134
  Covariates enter a separate least-squares model for each patient, with an
131
135
  intercept. Encode categorical covariates as numeric dummy variables; integer
@@ -175,32 +179,31 @@ power, and is not provided for Fisher or EB targets.
175
179
  ## Reproduce the manuscript
176
180
 
177
181
  The [reproduction repository](https://github.com/tjw0613-cell/pase-reproducibility)
178
- contains figure commands and the full 15-gene RNA workflow. The software
179
- tutorial above is a smaller example, not a reproduction of all paper results.
182
+ contains figure commands and the full 15-gene RNA workflow.
183
+ The [public API example](https://github.com/tjw0613-cell/pase-reproducibility/blob/main/workflows/h/public_api_example.py)
184
+ recreates the manuscript's RNA associations from the prepared cohort caches.
185
+ Use the [workflow instructions](https://github.com/tjw0613-cell/pase-reproducibility/tree/main/workflows/h)
186
+ to download the GEO data, build those caches and run the comparison.
180
187
 
181
188
  - [Simulation protocol, version 2.0.0](https://doi.org/10.5281/zenodo.24010816):
182
189
  the design archived before the formal simulations.
183
190
  - [Core results and reproducibility materials](https://doi.org/10.5281/zenodo.24015713):
184
191
  the subsequent code and results archive, including PASE 1.1.0.
185
- - Supplementary Data S1 and S2 accompany the revised manuscript. They contain
186
- the detection-matched gene analysis and unequal-yield native count benchmark,
187
- respectively, and are not included in the core-results DOI above.
192
+ - Supplementary Data S1 contains the detection-matched gene analysis.
193
+ Supplementary Data S2 contains the unequal-yield native count benchmark.
188
194
 
189
195
  See [reproduction instructions](https://pase-software.readthedocs.io/en/latest/reproducibility.html)
190
196
  for the scope of each workflow and the software test commands.
191
197
 
192
198
  ## Citation
193
199
 
194
- For this code, cite the authors, PASE software version **1.1.1**, and its
195
- [release URL](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.1.1).
200
+ For this code, cite the authors, PASE software version **1.2.0**, and its
201
+ [release URL](https://github.com/tjw0613-cell/pase-software/releases/tag/v1.2.0).
196
202
  Machine-readable author information is in
197
- [CITATION.cff](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/CITATION.cff).
198
- An earlier analysis archive is
199
- available at [Zenodo v3](https://doi.org/10.5281/zenodo.23032874); that DOI does
200
- not identify this 1.1.1 software release.
203
+ [CITATION.cff](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/CITATION.cff).
201
204
 
202
205
  Code is distributed under the MIT License. The real-data example retains its
203
206
  source attribution and third-party terms; see
204
- [THIRD_PARTY_DATA.md](https://github.com/tjw0613-cell/pase-software/blob/v1.1.1/THIRD_PARTY_DATA.md).
207
+ [THIRD_PARTY_DATA.md](https://github.com/tjw0613-cell/pase-software/blob/v1.2.0/THIRD_PARTY_DATA.md).
205
208
  Report software problems through [GitHub Issues](https://github.com/tjw0613-cell/pase-software/issues).
206
209
 
@@ -61,6 +61,48 @@ def test_module_standardized_before_covariate_missingness():
61
61
  assert out.patients.iloc[0].n_complete == 30
62
62
 
63
63
 
64
+ def test_masked_module_matches_preselection_scaling_and_legacy_order():
65
+ adata = fixture_data()
66
+ adata.obs.iloc[25:40, adata.obs.columns.get_loc("myeloid")] = False
67
+ adata.X[25:40, 1] *= 20
68
+ adata.X[26, 2] = np.nan
69
+ adata.X[0, 0] = np.inf
70
+ adata.obs.loc["cell1", "log_depth"] = np.nan
71
+ options = dict(covariates=["log_depth"], cell_mask="myeloid", min_cells=15)
72
+ default = pase.associate(adata, "A", ["B", "C", "constant"], "donor", **options)
73
+ legacy = pase.associate(adata, "A", ["B", "C", "constant"], "donor",
74
+ standardize_before_mask=False, **options)
75
+ selected = np.arange(2, 25)
76
+ a = adata.X[:40]
77
+ expression_complete = np.isfinite(a).all(axis=1)
78
+ z = np.column_stack([np.ones(len(selected)), adata.obs.log_depth.to_numpy()[selected]])
79
+ results = []
80
+ for ref in (a[expression_complete, 1:3], a[1:25, 1:3]):
81
+ score = ((a[selected, 1:3] - ref.mean(axis=0)) / ref.std(axis=0, ddof=1)).sum(axis=1) / 3
82
+ pair = np.column_stack([a[selected, 0], score])
83
+ residuals = pair - z @ np.linalg.lstsq(z, pair, rcond=None)[0]
84
+ results.append(np.corrcoef(residuals.T)[0, 1])
85
+
86
+ assert default.patients.iloc[0].r == pytest.approx(results[0], abs=1e-13)
87
+ assert legacy.patients.iloc[0].r == pytest.approx(results[1], abs=1e-13)
88
+ assert abs(results[0] - results[1]) > 0.02
89
+ assert default.patients.iloc[0].n_selected == 25
90
+ assert default.patients.iloc[0].n_complete == legacy.patients.iloc[0].n_complete == 23
91
+ assert default.metadata["standardize_before_mask"] is True
92
+ assert legacy.metadata["standardize_before_mask"] is False
93
+ assert default.metadata["score_standardization"].startswith("All input cells")
94
+ assert legacy.metadata["score_standardization"].startswith("Mask-selected cells")
95
+ pd.testing.assert_frame_equal(default.patients.iloc[1:], legacy.patients.iloc[1:])
96
+
97
+
98
+ def test_mask_standardization_only_changes_gene_list_scores():
99
+ adata = fixture_data()
100
+ adata.obs.iloc[30:40, adata.obs.columns.get_loc("myeloid")] = False
101
+ default = pase.associate(adata, "A", "B", "donor", cell_mask="myeloid")
102
+ legacy = pase.associate(adata, "A", "B", "donor", cell_mask="myeloid", standardize_before_mask=False)
103
+ pd.testing.assert_frame_equal(default.patients, legacy.patients)
104
+
105
+
64
106
  def test_equal_invariant_to_exact_donor_cell_duplication():
65
107
  adata = fixture_data()
66
108
  one = pase.associate(adata, "A", ["B", "C"], "donor", covariates=["log_depth"], min_patients=2)
@@ -197,7 +239,8 @@ def test_series_mask_index_must_match():
197
239
  {"target": ["A", "B"]}, {"min_cells": 1.5},
198
240
  {"min_patients": 1}, {"alpha": True},
199
241
  {"patient_ids": ["p0", "p0"]},
200
- {"aggregate": "unknown"}])
242
+ {"aggregate": "unknown"},
243
+ {"standardize_before_mask": "False"}])
201
244
  def test_invalid_arguments_fail(kwargs):
202
245
  args = dict(anchor="A", target="B", patient_key="donor")
203
246
  args.update(kwargs)
File without changes
File without changes