jipm 0.1.1__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.
- jipm-0.1.1/MANIFEST.in +10 -0
- jipm-0.1.1/NOTICE.md +5 -0
- jipm-0.1.1/PKG-INFO +86 -0
- jipm-0.1.1/README.md +66 -0
- jipm-0.1.1/README_zh.md +42 -0
- jipm-0.1.1/docs/atr.md +64 -0
- jipm-0.1.1/docs/direction.md +49 -0
- jipm-0.1.1/docs/endpoints.md +45 -0
- jipm-0.1.1/docs/new_screen_zh.md +22 -0
- jipm-0.1.1/docs/nomination.md +102 -0
- jipm-0.1.1/docs/parpi.md +54 -0
- jipm-0.1.1/docs/scientific_scope_zh.md +32 -0
- jipm-0.1.1/docs/validation_zh.md +16 -0
- jipm-0.1.1/examples/atr_minimal.py +29 -0
- jipm-0.1.1/examples/direction.py +10 -0
- jipm-0.1.1/examples/endpoints.py +7 -0
- jipm-0.1.1/examples/nomination/candidate_inputs.csv +102 -0
- jipm-0.1.1/examples/nomination/opposite_replicate.csv +102 -0
- jipm-0.1.1/examples/nomination.py +18 -0
- jipm-0.1.1/examples/response_to_nomination.py +13 -0
- jipm-0.1.1/examples/verify_atr_fold.py +95 -0
- jipm-0.1.1/pyproject.toml +38 -0
- jipm-0.1.1/requirements-paper.txt +5 -0
- jipm-0.1.1/setup.cfg +4 -0
- jipm-0.1.1/src/jipm/__init__.py +25 -0
- jipm-0.1.1/src/jipm/__main__.py +4 -0
- jipm-0.1.1/src/jipm/_parpi/__init__.py +1 -0
- jipm-0.1.1/src/jipm/_parpi/encoding.py +129 -0
- jipm-0.1.1/src/jipm/_parpi/engine.py +146 -0
- jipm-0.1.1/src/jipm/_parpi/kernels.py +49 -0
- jipm-0.1.1/src/jipm/_parpi/solver.py +180 -0
- jipm-0.1.1/src/jipm/atr.py +396 -0
- jipm-0.1.1/src/jipm/cli.py +105 -0
- jipm-0.1.1/src/jipm/comparison.py +72 -0
- jipm-0.1.1/src/jipm/correspondence.py +163 -0
- jipm-0.1.1/src/jipm/demo.py +57 -0
- jipm-0.1.1/src/jipm/direction.py +342 -0
- jipm-0.1.1/src/jipm/endpoints.py +350 -0
- jipm-0.1.1/src/jipm/nomination.py +261 -0
- jipm-0.1.1/src/jipm/parpi.py +233 -0
- jipm-0.1.1/src/jipm/profiles.py +121 -0
- jipm-0.1.1/src/jipm/resources/direction/jonikas_features.npz +0 -0
- jipm-0.1.1/src/jipm/resources/direction/jonikas_reference.npz +0 -0
- jipm-0.1.1/src/jipm/resources/endpoints/coefficients.npz +0 -0
- jipm-0.1.1/src/jipm/resources/endpoints/example.csv +5 -0
- jipm-0.1.1/src/jipm/resources/endpoints/index.json +1 -0
- jipm-0.1.1/src/jipm/resources/endpoints/measurement_map.json +35 -0
- jipm-0.1.1/src/jipm/system.py +136 -0
- jipm-0.1.1/src/jipm.egg-info/PKG-INFO +86 -0
- jipm-0.1.1/src/jipm.egg-info/SOURCES.txt +81 -0
- jipm-0.1.1/src/jipm.egg-info/dependency_links.txt +1 -0
- jipm-0.1.1/src/jipm.egg-info/entry_points.txt +2 -0
- jipm-0.1.1/src/jipm.egg-info/requires.txt +5 -0
- jipm-0.1.1/src/jipm.egg-info/top_level.txt +1 -0
- jipm-0.1.1/tests/test_atr.py +76 -0
- jipm-0.1.1/tests/test_comparison.py +22 -0
- jipm-0.1.1/tests/test_correspondence.py +52 -0
- jipm-0.1.1/tests/test_direction.py +62 -0
- jipm-0.1.1/tests/test_endpoints.py +75 -0
- jipm-0.1.1/tests/test_input_conventions.py +50 -0
- jipm-0.1.1/tests/test_nomination.py +80 -0
- jipm-0.1.1/tests/test_parpi.py +54 -0
- jipm-0.1.1/tests/test_system.py +43 -0
- jipm-0.1.1/validation/README.md +39 -0
- jipm-0.1.1/validation/atr_receipt.json +41 -0
- jipm-0.1.1/validation/check_correspondence_scores.py +81 -0
- jipm-0.1.1/validation/check_nomination.py +220 -0
- jipm-0.1.1/validation/check_parpi.py +78 -0
- jipm-0.1.1/validation/check_parpi_calibration.py +64 -0
- jipm-0.1.1/validation/check_parpi_correspondence.py +86 -0
- jipm-0.1.1/validation/check_parpi_full_fit.py +65 -0
- jipm-0.1.1/validation/correspondence_scores.json +54 -0
- jipm-0.1.1/validation/direction_receipt.json +43 -0
- jipm-0.1.1/validation/direction_retuned_receipt.json +26 -0
- jipm-0.1.1/validation/endpoints_receipt.json +84 -0
- jipm-0.1.1/validation/nomination.json +444 -0
- jipm-0.1.1/validation/parpi_calibration.json +46 -0
- jipm-0.1.1/validation/parpi_correspondence_v521.json +102 -0
- jipm-0.1.1/validation/parpi_full_fit.json +31 -0
- jipm-0.1.1/validation/parpi_receipt.json +25 -0
- jipm-0.1.1/validation/validate_atr.py +68 -0
- jipm-0.1.1/validation/validate_direction.py +55 -0
- jipm-0.1.1/validation/validate_endpoints.py +154 -0
jipm-0.1.1/MANIFEST.in
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
include README.md README_zh.md NOTICE.md requirements-paper.txt
|
|
2
|
+
recursive-include docs *.md
|
|
3
|
+
graft examples
|
|
4
|
+
graft validation
|
|
5
|
+
graft tests
|
|
6
|
+
graft src/jipm/resources
|
|
7
|
+
global-exclude *.py[cod] .DS_Store
|
|
8
|
+
prune examples/__pycache__
|
|
9
|
+
prune validation/__pycache__
|
|
10
|
+
prune tests/__pycache__
|
jipm-0.1.1/NOTICE.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Citation, provenance and reuse
|
|
2
|
+
|
|
3
|
+
JIPM accompanies *When joint interpretation improves prediction from paired perturbation measurements*, manuscript v52.1. This 0.1.1 software release updates JIPM 0.1.0 and was checked against the v17 reference implementation. The authors of the original distribution supply the research software for review and reserve the project-wide license decision. The license identifier LicenseRef-JIPM-Review records that status. The dependency licenses and the original experimental data terms continue to apply.
|
|
4
|
+
|
|
5
|
+
Jonikas inputs derive from the yeast functional study, deletion-expression measurements (GSE42527) and the curated order reference used by Battle and colleagues. Fong coefficients and examples derive from the published multi-cell-line screen. Human drug-screen examples and validation use GSE312636 (ATR inhibitor) and GSE284018 (niraparib) with K562 RNA measurements. Cite the original studies and JIPM when reporting results. References to comparator models in the validation tables are attributed to their original authors.
|
jipm-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jipm
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Joint interpretation of paired perturbation measurements for pathway ordering, endpoint attribution and drug-response prediction
|
|
5
|
+
License-Expression: LicenseRef-JIPM-Review
|
|
6
|
+
Keywords: perturbation,genomics,kernel regression,epistasis,drug response
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Science/Research
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
|
|
11
|
+
Requires-Python: >=3.12
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: NOTICE.md
|
|
14
|
+
Requires-Dist: numpy<3,>=2.3
|
|
15
|
+
Requires-Dist: scipy<2,>=1.16
|
|
16
|
+
Requires-Dist: pandas<3,>=2.2
|
|
17
|
+
Requires-Dist: scikit-learn<2,>=1.7
|
|
18
|
+
Requires-Dist: threadpoolctl<4,>=3.6
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# JIPM · Joint Interpretation of Perturbation Measurements
|
|
22
|
+
|
|
23
|
+
JIPM links measurements by perturbed gene and chooses a predictor that respects the target's response to exchanging the genes. This distribution, `jipm 0.1.1`, accompanies *When joint interpretation improves prediction from paired perturbation measurements* (manuscript v52.1, reproduction bundle v17).
|
|
24
|
+
|
|
25
|
+
## Install and run
|
|
26
|
+
|
|
27
|
+
With Python 3.12 or later, install the distributed wheel. The paper reference configuration uses Python 3.12 and the numerical versions in `requirements-paper.txt` in the source distribution.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
python -m pip install ./jipm-0.1.1-py3-none-any.whl
|
|
31
|
+
jipm --version
|
|
32
|
+
jipm demo endpoints
|
|
33
|
+
jipm demo parpi-correspondence
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The Fong example uses two early culture measurements for each double perturbation and the original fitted model. For ABL1–NOTCH1 the model assigns the day-9 MCF7 response to NOTCH1 and the MDA-MB-231 response to ABL1 in each target culture. Gal15 and Anti15 are the retained column names for these two cell-line endpoints.
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from jipm import JIPM, fong_example
|
|
40
|
+
|
|
41
|
+
calls = JIPM.from_fong().predict(fong_example())
|
|
42
|
+
print(calls[["gene_a", "gene_b", "target", "Gal15_parent", "Anti15_parent"]])
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Choose a task
|
|
46
|
+
|
|
47
|
+
| Argument to `JIPM` | Measurements and target | Paper location |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `direction` | Fit ordered pathway scores using retained expression and phenotype coordinates. The half-difference between the forward and reversed scores gives the direction margin. | Figs. 2–3, S2, S5, S7–S8 |
|
|
50
|
+
| `endpoints` | Predict the closer parent in each Fong cell line. Each cell line uses the mean across two early cultures, culture-specific deviations and parental coefficients shared across partners. | Fig. 5, S14 |
|
|
51
|
+
| `atr` | Predict the treated double in the other replicate. Controls cover source addition, synchronous or independent averaging of parent order, and optional shared parent effects. | Fig. 4, S10–S12 |
|
|
52
|
+
| `parpi-correspondence` | Fit both matched niraparib product kernels to the same training observations and score their predictions for each held-out pair. | Fig. 4b, S11, Tables S71–S72 |
|
|
53
|
+
| `parpi` | Fit a continuous drug-response model with training-side calibration, parent coverage and a signed rank-two component. Use its predictions to nominate one partner per anchor. | Fig. 6, S15–S17 |
|
|
54
|
+
|
|
55
|
+
## Compare the two niraparib kernels on a new screen
|
|
56
|
+
|
|
57
|
+
Fit one batch and one replicate direction at a time. Each row of `train` or `query` includes `gene_a`, `gene_b`, `untreated_a`, `untreated_b`, `treated_a`, `treated_b` and `untreated_ab`. `profiles` is an `RNAProfiles` object. `y_train` contains the treated-double training outcomes in that row order. Score held-out outcomes after predicting.
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from jipm import JIPM
|
|
61
|
+
|
|
62
|
+
contrast = JIPM("parpi-correspondence").fit(train, y_train, profiles=profiles)
|
|
63
|
+
scores = contrast.predict(query)
|
|
64
|
+
print(scores[["gene_a", "gene_b", "pred_sync", "pred_ind", "rms", "high"]])
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`pred_sync` keeps each parent's measurements together. `pred_ind` averages parent order within each assay independently. `rms` measures the difference between their raw kernel representations, and `high` identifies a query above the training median. In the published transfer, excluding pairs shared with ATR left 6,309 niraparib pairs in 2022 and 6,095 in 2023. The MSE reductions relative to independent averaging were 1.03% and 2.31% in 2022 and 2.34% and 2.93% in 2023. On the full panels, the high group had the larger mean reduction in two of the four comparisons. The group flag describes the input representations. Its ability to predict larger gains can be evaluated against held-out measurements.
|
|
68
|
+
|
|
69
|
+
## Predict a response and nominate a partner
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
from jipm import JIPM
|
|
73
|
+
|
|
74
|
+
response_model = JIPM("parpi").fit(train, y_train, profiles=profiles)
|
|
75
|
+
responses = response_model.predict(query)
|
|
76
|
+
components = response_model.model.predict_components(query)
|
|
77
|
+
nominees = response_model.nominate(query)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
For a single source replicate, nomination ranks predicted treated response minus the measured vehicle-double response. Supply the complete eligible pool for each anchor. By default at least ten partners are required. Use `score_nominations` to compare fixed choices with independently measured, control-normalized drug sensitivity. For the S17 cross-batch shortlist, source-replicate rank inputs use the worse rank followed by the rank sum. The separate rank-four upstream fit and all study-specific training protocols are in reproduction bundle v17.
|
|
81
|
+
|
|
82
|
+
## Interfaces and reproduction
|
|
83
|
+
|
|
84
|
+
`jipm demo direction` and `jipm demo endpoints` use real retained measurements. The drug-screen demonstrations use generated inputs to illustrate the interfaces. `jipm predict --help` documents the file interface and `jipm nominate --help` gives the selection options. Use `compare_responses` to join two predictors and observations on the unordered gene pair and the experimental context.
|
|
85
|
+
|
|
86
|
+
The source distribution includes the Chinese guide, task-specific documentation, runnable examples, tests, validation scripts and their reference results. After installing the distribution, run `python -m unittest discover -s tests -v` from the extracted source root. See `validation/README.md` for the inputs needed to reproduce the paper checks. Figures, full experimental datasets, the Hsp12 static and trajectory protocols, and the reference-measurement simulations are available in the companion v17 bundle. Citation and reuse terms are in `NOTICE.md`.
|
jipm-0.1.1/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# JIPM · Joint Interpretation of Perturbation Measurements
|
|
2
|
+
|
|
3
|
+
JIPM links measurements by perturbed gene and chooses a predictor that respects the target's response to exchanging the genes. This distribution, `jipm 0.1.1`, accompanies *When joint interpretation improves prediction from paired perturbation measurements* (manuscript v52.1, reproduction bundle v17).
|
|
4
|
+
|
|
5
|
+
## Install and run
|
|
6
|
+
|
|
7
|
+
With Python 3.12 or later, install the distributed wheel. The paper reference configuration uses Python 3.12 and the numerical versions in `requirements-paper.txt` in the source distribution.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
python -m pip install ./jipm-0.1.1-py3-none-any.whl
|
|
11
|
+
jipm --version
|
|
12
|
+
jipm demo endpoints
|
|
13
|
+
jipm demo parpi-correspondence
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The Fong example uses two early culture measurements for each double perturbation and the original fitted model. For ABL1–NOTCH1 the model assigns the day-9 MCF7 response to NOTCH1 and the MDA-MB-231 response to ABL1 in each target culture. Gal15 and Anti15 are the retained column names for these two cell-line endpoints.
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from jipm import JIPM, fong_example
|
|
20
|
+
|
|
21
|
+
calls = JIPM.from_fong().predict(fong_example())
|
|
22
|
+
print(calls[["gene_a", "gene_b", "target", "Gal15_parent", "Anti15_parent"]])
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Choose a task
|
|
26
|
+
|
|
27
|
+
| Argument to `JIPM` | Measurements and target | Paper location |
|
|
28
|
+
| --- | --- | --- |
|
|
29
|
+
| `direction` | Fit ordered pathway scores using retained expression and phenotype coordinates. The half-difference between the forward and reversed scores gives the direction margin. | Figs. 2–3, S2, S5, S7–S8 |
|
|
30
|
+
| `endpoints` | Predict the closer parent in each Fong cell line. Each cell line uses the mean across two early cultures, culture-specific deviations and parental coefficients shared across partners. | Fig. 5, S14 |
|
|
31
|
+
| `atr` | Predict the treated double in the other replicate. Controls cover source addition, synchronous or independent averaging of parent order, and optional shared parent effects. | Fig. 4, S10–S12 |
|
|
32
|
+
| `parpi-correspondence` | Fit both matched niraparib product kernels to the same training observations and score their predictions for each held-out pair. | Fig. 4b, S11, Tables S71–S72 |
|
|
33
|
+
| `parpi` | Fit a continuous drug-response model with training-side calibration, parent coverage and a signed rank-two component. Use its predictions to nominate one partner per anchor. | Fig. 6, S15–S17 |
|
|
34
|
+
|
|
35
|
+
## Compare the two niraparib kernels on a new screen
|
|
36
|
+
|
|
37
|
+
Fit one batch and one replicate direction at a time. Each row of `train` or `query` includes `gene_a`, `gene_b`, `untreated_a`, `untreated_b`, `treated_a`, `treated_b` and `untreated_ab`. `profiles` is an `RNAProfiles` object. `y_train` contains the treated-double training outcomes in that row order. Score held-out outcomes after predicting.
|
|
38
|
+
|
|
39
|
+
```python
|
|
40
|
+
from jipm import JIPM
|
|
41
|
+
|
|
42
|
+
contrast = JIPM("parpi-correspondence").fit(train, y_train, profiles=profiles)
|
|
43
|
+
scores = contrast.predict(query)
|
|
44
|
+
print(scores[["gene_a", "gene_b", "pred_sync", "pred_ind", "rms", "high"]])
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`pred_sync` keeps each parent's measurements together. `pred_ind` averages parent order within each assay independently. `rms` measures the difference between their raw kernel representations, and `high` identifies a query above the training median. In the published transfer, excluding pairs shared with ATR left 6,309 niraparib pairs in 2022 and 6,095 in 2023. The MSE reductions relative to independent averaging were 1.03% and 2.31% in 2022 and 2.34% and 2.93% in 2023. On the full panels, the high group had the larger mean reduction in two of the four comparisons. The group flag describes the input representations. Its ability to predict larger gains can be evaluated against held-out measurements.
|
|
48
|
+
|
|
49
|
+
## Predict a response and nominate a partner
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from jipm import JIPM
|
|
53
|
+
|
|
54
|
+
response_model = JIPM("parpi").fit(train, y_train, profiles=profiles)
|
|
55
|
+
responses = response_model.predict(query)
|
|
56
|
+
components = response_model.model.predict_components(query)
|
|
57
|
+
nominees = response_model.nominate(query)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
For a single source replicate, nomination ranks predicted treated response minus the measured vehicle-double response. Supply the complete eligible pool for each anchor. By default at least ten partners are required. Use `score_nominations` to compare fixed choices with independently measured, control-normalized drug sensitivity. For the S17 cross-batch shortlist, source-replicate rank inputs use the worse rank followed by the rank sum. The separate rank-four upstream fit and all study-specific training protocols are in reproduction bundle v17.
|
|
61
|
+
|
|
62
|
+
## Interfaces and reproduction
|
|
63
|
+
|
|
64
|
+
`jipm demo direction` and `jipm demo endpoints` use real retained measurements. The drug-screen demonstrations use generated inputs to illustrate the interfaces. `jipm predict --help` documents the file interface and `jipm nominate --help` gives the selection options. Use `compare_responses` to join two predictors and observations on the unordered gene pair and the experimental context.
|
|
65
|
+
|
|
66
|
+
The source distribution includes the Chinese guide, task-specific documentation, runnable examples, tests, validation scripts and their reference results. After installing the distribution, run `python -m unittest discover -s tests -v` from the extracted source root. See `validation/README.md` for the inputs needed to reproduce the paper checks. Figures, full experimental datasets, the Hsp12 static and trajectory protocols, and the reference-measurement simulations are available in the companion v17 bundle. Citation and reuse terms are in `NOTICE.md`.
|
jipm-0.1.1/README_zh.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# JIPM 0.1.1 使用说明
|
|
2
|
+
|
|
3
|
+
本工具包对应论文 v52.1 与复现总包 v17。按受扰动基因关联不同来源的测量,再按预测目标选择估计器。保留原来的方向、Fong、ATR、PARPi 预测和搭档提名接口,新增 S11 中用于 niraparib 的亲本对应关系比较。
|
|
4
|
+
|
|
5
|
+
## 安装与快速运行
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
python -m pip install ./jipm-0.1.1-py3-none-any.whl
|
|
9
|
+
jipm --version
|
|
10
|
+
jipm demo direction
|
|
11
|
+
jipm demo endpoints
|
|
12
|
+
jipm demo atr
|
|
13
|
+
jipm demo parpi
|
|
14
|
+
jipm demo parpi-correspondence
|
|
15
|
+
jipm demo nomination
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
需要 Python 3.12 或以上。前两项预测示例分别使用真实 Jonikas 和 Fong 记录。药物筛选与搭档提名的命令行 demo 使用小型模拟数据。源码包的 examples/nomination.py 另给出两个来自原研究的候选池。正式实验的拟合、封存预测重建与逐对重评分在源码包的 validation 目录中分别记录。
|
|
19
|
+
|
|
20
|
+
| 实际问题 | 从何处开始 |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| 判断注释通路顺序 | `JIPM("direction")`。给出同一基因对两个顺序的表达和表型坐标,输出有符号的方向分差。 |
|
|
23
|
+
| 判断双扰动的两个细胞系读出各接近哪个亲本 | `JIPM.from_fong()` 使用原拟合,`JIPM("endpoints").fit(...)` 在自己的早期与晚期训练数据上估计参数。 |
|
|
24
|
+
| 预测 ATR 抑制剂下另一重复的有药双扰动反应 | `JIPM("atr")`。亲本身份与对应的 RNA 和功能测量一起交换。 |
|
|
25
|
+
| 在新 niraparib 筛选中比较两种亲本对称化方式 | `JIPM("parpi-correspondence")`。对同一批训练数据分别拟合并输出两个预测、原始核差异的大小和按训练中位数确定的分组。 |
|
|
26
|
+
| 从预测的 niraparib 响应中为锚点选搭档 | `JIPM("parpi")` 的 `predict` 和 `nominate`。独立实测的药物敏感度用于事后计分。 |
|
|
27
|
+
|
|
28
|
+
## 读懂新增比较
|
|
29
|
+
|
|
30
|
+
在每个批次、每个重复方向上分别调用。训练和查询使用一行一个基因对的测量,训练目标为相应的有药双扰动表型。
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from jipm import JIPM
|
|
34
|
+
|
|
35
|
+
contrast = JIPM("parpi-correspondence").fit(train, y_train, profiles=rna)
|
|
36
|
+
scores = contrast.predict(query)
|
|
37
|
+
print(scores[["gene_a", "gene_b", "pred_sync", "pred_ind", "rms", "high"]])
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`pred_sync` 保留亲本与测量的配对,`pred_ind` 在两个测量来源内分别对称化。论文剔除与 ATR 面板重叠的基因对后,2022 年剩 6,309 对,2023 年剩 6,095 对。两个重复方向的 MSE 降幅依次为 1.03%、2.31%、2.34%、2.93%。完整面板上,预设高差异组在四个 niraparib 比较中的两个获得更大平均收益。`high` 是由输入计算的组别,某个基因对实际能否改善预测需用独立测量评分。
|
|
41
|
+
|
|
42
|
+
输入格式见 docs/new_screen_zh.md,任务与论文章节对应关系见 docs/scientific_scope_zh.md。完整基准重拟合、Hsp12 的同一 144 对母面板及其静态和轨迹分析协议、图形重建等由 v17 复现包提供。
|
jipm-0.1.1/docs/atr.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# ATR continuous drug response
|
|
2
|
+
|
|
3
|
+
The query contains both parents' RNA profiles, their own single-perturbation measurements under drug and vehicle, and the untreated double from the input replicate. Supply the treated-double outcome from the independent replicate for training. The unit of prediction is one double perturbation. The target and the functional measurements must use the same assay calibration as the training examples.
|
|
4
|
+
|
|
5
|
+
## Interface
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from jipm import JIPM, RNAProfiles
|
|
9
|
+
|
|
10
|
+
profiles = RNAProfiles(gene_ids, expression, control_mean, target_transcript_indices,
|
|
11
|
+
quality, transcript_ids=transcript_ids)
|
|
12
|
+
model = JIPM("atr", parent_penalty="auto", n_landmarks=1536)
|
|
13
|
+
model.fit(train, treated_double_other_replicate, profiles=profiles)
|
|
14
|
+
pred = model.predict(query)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Both tables take `gene_a`, `gene_b`, `untreated_a`, `untreated_b`, `treated_a`, `treated_b`, and `untreated_ab`. Parent IDs refer to rows of `profiles`. The unified interface returns the continuous prediction in `treated_prediction`. Direct `ATRResponseModel.predict` returns a one-dimensional array in query-row order. See `examples/atr_minimal.py` for a runnable illustration.
|
|
18
|
+
|
|
19
|
+
| RNAProfiles field | Coordinates |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| gene_ids | Unique parent identifiers for expression rows. |
|
|
22
|
+
| expression | Parent perturbations × common transcript columns, measured as in training. |
|
|
23
|
+
| control_mean | Baseline expression of each transcript, in the same scale. |
|
|
24
|
+
| target_transcript_indices | Index of each parent's own transcript in the expression columns; use −1 for an absent coordinate. |
|
|
25
|
+
| quality | One row per parent. Columns are filtered cell count, response RMS z versus core controls, source expression-weighted fold, and expression-missing fraction. Pass the raw filtered cell count. |
|
|
26
|
+
| transcript_ids | Names and order of the columns. Supplying names enables new query panels to be checked for exact coordinate correspondence. Without names, column correspondence is positional. |
|
|
27
|
+
|
|
28
|
+
A fitted model accepts a new profile table through `predict(query, profiles=new_profiles)`. Supply all query parents' profiles on the fitted transcript coordinates with the same control mean. Unseen parents receive zero shared-parent coefficient; RNA and measured functional covariates for these parents still enter the joint kernel.
|
|
29
|
+
|
|
30
|
+
## Computation
|
|
31
|
+
|
|
32
|
+
Preprocessing estimates transcript medians, PCA, RNA quality scales, and functional scales from the training parents or training combinations as appropriate. Landmark rows are drawn from training combinations. Each parent carries its RNA, both self/partner transcript responses, and its single-perturbation phenotypes during pair exchange.
|
|
33
|
+
|
|
34
|
+
The primary response uses individually normalized RNA, functional, and synchronously symmetrized product kernels, Nyström ridge regression, and a separately penalized pair of parent effects. `parent_penalty="auto"` selects the parent penalty from 1, 10, 100, 1,000 or infinity on a whole-pair training-side holdout. A Boolean `validation_mask` can supply a predetermined split. The original study also tuned the kernel settings per outer fold. For an exact fold comparison, read its selected configuration and landmark seed as in the validation example. The constructor exposes those settings and does not repeat the whole original kernel-selection search for a new panel. Small panels use the available PCA dimension and landmarks.
|
|
35
|
+
|
|
36
|
+
To compare cross-assay parent correspondence, fit two instances independently on identical training rows. Set `joint_weight=1.0` and `parent_penalty=float("inf")` for both. Choose `correspondence="synchronous"` for the within-parent pairing or `correspondence="separate"` to independently average within each assay. Each arm computes its own training-diagonal normalization and refits its own coefficients. Setting the shared-parent penalty to infinity also permits the corresponding non-parent control for the primary model.
|
|
37
|
+
|
|
38
|
+
For the original nonlinear source-additive comparator, fit `ATRResponseModel(scoring="source_additive", parent_penalty=float("inf"), ...)` with its own training-selected PCA dimension, source widths, mixture, ridge and landmark count. Each source gets its own normalized and whitened feature space and its full landmark budget. The estimator concatenates the source features scaled by the square roots of their mixture weights. On a fitted primary model, `predict_kernel_only` gives the fit without parent effects at the same kernel settings. These are the two predictions compared in the paper's 11.03% / 12.93% MSE calculation.
|
|
39
|
+
|
|
40
|
+
## Check a real fold
|
|
41
|
+
|
|
42
|
+
Install the tool and prepare the original v17 study outside the installed package. From the extracted v17 checkout run `python reproduce.py base atr --out ../atr-results`. The command creates an `atr` subdirectory containing `prepared` and `fits`. From the v0.1.1 source distribution run:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
python examples/verify_atr_fold.py ../atr-results/atr \
|
|
46
|
+
--job r0_f0_D1_Y2 \
|
|
47
|
+
--correspondence-fits /path/to/v17/JIPM/studies/correspondence/atr/engine/fits
|
|
48
|
+
python validation/validate_atr.py ../atr-results/atr \
|
|
49
|
+
/path/to/v17/JIPM/studies/correspondence/atr/engine/fits ../atr-python-check --workers 2
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The full audit refits each outer fold through the package API, compares held-out forecasts against v17 at absolute tolerance 1e−7, checks simultaneous parent reversal, and computes both repeat-direction MSE after fitting. The package refits the matched nonlinear source-additive model with the fold-specific settings from v17. The full hyperparameter-search history and equal-budget tuning protocols are in v17. The measurement and coefficient files of v17 are needed only for paper validation. New-data fitting and prediction work directly with the runtime package.
|
|
53
|
+
|
|
54
|
+
## Published reference validation
|
|
55
|
+
|
|
56
|
+
All twenty outer folds were independently fitted from the original measurements with the Python package. The check covers 63,000 held-out assignments per arm, including two partition assignments per pair in each replicate direction. Both whole-parent orientations produce the same drug-response prediction. The training-side parent penalty matched the recorded selection on all twenty folds. The largest absolute difference among all compared forecasts was 8.50 × 10⁻¹¹ (rounded upward).
|
|
57
|
+
|
|
58
|
+
| Separate comparison | D1 → Y2 MSE reduction | D2 → Y1 MSE reduction |
|
|
59
|
+
| --- | ---: | ---: |
|
|
60
|
+
| Joint fit before parent effects relative to the independently tuned nonlinear source-additive fit | 11.03% | 12.93% |
|
|
61
|
+
| Shared-parent fit relative to the same kernel fitted without parent effects | 1.79% | 1.39% |
|
|
62
|
+
| Synchronous pure product relative to the separately symmetrized pure product | 4.40% | 3.08% |
|
|
63
|
+
|
|
64
|
+
The exact MSE values, comparator identities, numerical differences and held-out counts are in `validation/atr_receipt.json`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Pathway order
|
|
2
|
+
|
|
3
|
+
The Jonikas endpoint is agreement with the annotated order of a yeast gene pair. A positive margin supports the supplied order. For the opposite order the sign reverses. Interpreting this output as direct transcriptional regulation requires a separate reference.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from jipm import JIPM
|
|
7
|
+
from jipm.direction import load_jonikas, PathwayDirection
|
|
8
|
+
|
|
9
|
+
rows, order_labels = load_jonikas()
|
|
10
|
+
held = {"ALG6", "ALG5"}
|
|
11
|
+
train = ~rows.a.isin(held) & ~rows.b.isin(held)
|
|
12
|
+
query = (rows.a == "ALG6") & (rows.b == "ALG5")
|
|
13
|
+
model = JIPM("direction").fit(rows.loc[train], order_labels[train])
|
|
14
|
+
prediction = model.predict(rows.loc[query])
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Supplying a new panel
|
|
18
|
+
|
|
19
|
+
Supply pair records at the same retained-measurement interface used to fit the estimator. Each row specifies one proposed order. Training and query coordinates must have the same definitions, scales and column order. The two roles must travel with their measurements under reversal.
|
|
20
|
+
|
|
21
|
+
| Column | Meaning |
|
|
22
|
+
| --- | --- |
|
|
23
|
+
| `a, b` | Supplied parent order. The unified entry point also accepts `gene_a, gene_b`. |
|
|
24
|
+
| `p` | Frozen signed expression score for this order. |
|
|
25
|
+
| `odd` | Exchange-odd phenotype vector for the linear phenotype kernel. |
|
|
26
|
+
| `xp, xpr` | Nonlinear expression coordinates in the supplied and reversed order. |
|
|
27
|
+
| `xd, xdr` | Nonlinear functional coordinates in the supplied and reversed order. |
|
|
28
|
+
|
|
29
|
+
In a CSV, store each vector as a JSON array. To export the rows returned by `load_jonikas()`, use full-precision values as follows. Add the training label column before writing a training CSV.
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import json
|
|
33
|
+
|
|
34
|
+
csv_rows = rows.copy()
|
|
35
|
+
for column in ("odd", "xp", "xpr", "xd", "xdr"):
|
|
36
|
+
csv_rows[column] = csv_rows[column].map(lambda vector: json.dumps(vector.tolist()))
|
|
37
|
+
csv_rows.loc[train].assign(target=order_labels[train]).to_csv("train.csv", index=False)
|
|
38
|
+
csv_rows.loc[query].to_csv("query.csv", index=False)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
For measurements already in the Jonikas representation, `PathwayDirection.from_retained(a, b, p, expression_context, phenotype_odd, phenotype_context)` builds these columns. When passing pandas Series or DataFrames, use the same index in the same order across inputs. The inputs per row are one signed expression score, seven symmetric expression coordinates, eight odd phenotype coordinates and fifteen symmetric phenotype coordinates. The seven expression summaries cover correlation, cosine, effect overlap, shared/union counts, the variance product and response-count imbalance. The phenotype vectors include inherited transformed information on single and double measurements, missingness and functional context. The helper constructs the nonlinear expression score as `tanh(p/2)`, swaps each odd coordinate's sign and retains invariant coordinates. Raw count or fluorescence matrices require the relevant assay-specific preprocessing and annotation before using this interface. The release ledger in v17 identifies the exact retained data sources.
|
|
42
|
+
|
|
43
|
+
Provide binary reference indicators separately as `fit(rows, labels)`. Supply observed ordered labels under the chosen protocol. Jonikas uses 21 supported-order records and 147 nonordered records from 84 unordered pairs; both orders of a background pair may have label zero. The estimator fits the full ordered scores. The returned `direction` is half the forward minus reverse score, `support` is their half-sum, and `call` equals +1, −1 or 0 for an exact tie. These scores are uncalibrated. The pathway-order estimand differs from the directional-training projection in the Costanzo analysis.
|
|
44
|
+
|
|
45
|
+
By default, each inner validation pair holds **both parents** out of its training fold. The mixture and ridge penalty use the published candidate grid and pair-clustered one-standard-error criterion. You can supply fixed hyperparameters learned solely from an independent training set, for example `JIPM("direction", weights=(.5, 0., .5), regularization=.0003)`. When evaluating held-out parents, exclude all their records from the outer training pool as in the example. A deployment fit on all available training records learns its own parameters.
|
|
46
|
+
|
|
47
|
+
`family="additive"` fits the matched source-additive family with independently selected tuning parameters. `family="product"` fits the pure product control. The v52.1 reference exercise re-estimates every ridge model from the development rows of its outer fold. Run `python validation/validate_direction.py` with the source distribution to check the archived training-only settings, or add `--retune` to repeat selection inside each outer fold. Add `--release ../JIPM` to compare all ordered labels and reference scores with the three original v17 result tables. The documented counts are 20, 16 and 21 correct among 21 annotated pairs for the joint, additive and pure product arms respectively.
|
|
48
|
+
|
|
49
|
+
On the 21 annotated orders, the joint fit retained all 16 orders correctly scored by the matched additive fit and recovered four further orders. The verifier checks the identity and coverage of all 84 outer pairs, the two scores for each ordered row and the fitted choices in all three families.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Two named endpoints and two cultures
|
|
2
|
+
|
|
3
|
+
The Fong adapter estimates which single perturbation the double resembles at day 9, once in MCF7 and once in MDA-MB-231. Within each cell line it fits a mean displacement from the parental midpoint across the two early cultures and a deviation for each culture. Parent identity and early-signature coefficients are reused across partner combinations. The two cell lines share design matrices, with separate ridge coefficients and losses for their day-9 responses. It then compares the displacement with the order of the late single-parent references. Positive margins select the parent in the output `gene_a` column, negative margins select `gene_b`, and exact zeros produce `tie`.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from jipm.endpoints import EndpointModel, fong_example
|
|
7
|
+
|
|
8
|
+
predictions = EndpointModel.from_fong().predict(fong_example())
|
|
9
|
+
print(predictions[["gene_a", "gene_b", "target", "Gal15_parent", "Anti15_parent"]])
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
For ABL1–NOTCH1, both target cultures call NOTCH1 in MCF7 and ABL1 in MDA-MB-231. For ADA–ATR they call ATR at both endpoints. These illustrative inputs come from the held-out Fong set.
|
|
13
|
+
|
|
14
|
+
### Own queries
|
|
15
|
+
|
|
16
|
+
Supply a pandas DataFrame with two rows per pair, one per early culture batch (1, 2). For each of the early conditions in the table below, give three values: `_a` for the `gene_a` single, `_b` for the `gene_b` single and `_ab` for the double. The adapter orders gene names lexicographically with their measurements and returns one row per pair and target culture. The two inputs both contribute to each prediction. `source` and `target` are the original opposite-repeat identifiers.
|
|
17
|
+
|
|
18
|
+
| Field prefix | Measurement represented |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| Glc15 | MCF10A day 4 in each culture |
|
|
21
|
+
| Gal3 | MCF7 day 4 in each culture |
|
|
22
|
+
| Anti3 | MDA-MB-231 day 6 for batch 1, day 3 for batch 2 |
|
|
23
|
+
| Gal15 | MCF7 day 9 outcome (training labels or prediction margin) |
|
|
24
|
+
| Anti15 | MDA-MB-231 day 9 outcome (training labels or prediction margin) |
|
|
25
|
+
|
|
26
|
+
Column prefixes retain the original program's aliases. Supply normalized, plasmid-referenced construct phenotypes on the Fong scale. A late measurement of the query double is not required. Training records contribute late single-parent references to the fitted model. For a new pair, the stored lookup first uses the same parent and early measurement signature. Its fallbacks use that parent's training median and then a fitted early-to-late regression for an unseen gene. The paper validates its named cell-line endpoints; a prediction for any additional biological context requires its own suitable measurements and validation.
|
|
27
|
+
|
|
28
|
+
### Train on your own examples
|
|
29
|
+
|
|
30
|
+
Provide late training rows for the same pairs and cultures, with columns `Gal15_a`, `Gal15_b`, `Gal15_ab`, `Anti15_a`, `Anti15_b`, `Anti15_ab`. Use at least five unique training pairs for the fixed fivefold parent-reference regression. Split the data before calling the estimator.
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
model = EndpointModel().fit(early_training_rows, late_training_rows)
|
|
34
|
+
predictions = model.predict(early_query_rows)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The optional `feature_catalogue` argument accepts unlabeled early records to fix the sparse gene/signature dictionary. The paper used its complete early catalogue and estimated all active coefficients and parent references on the training pairs. The default constructs this dictionary from training pairs only. The source distribution provides `validation/validate_endpoints.py` to repeat both the packaged frozen prediction and the original catalogue-based refit against the v17 hashes.
|
|
38
|
+
|
|
39
|
+
Biological source: Fong et al., Supplementary Data 1, [doi:10.1038/s41588-024-01971-9](https://doi.org/10.1038/s41588-024-01971-9). Software source: JIPM v17 `base/trio/fong/model`. The supplied coefficient and parent-reference files retain their original SHA-256 digests in the v17 reference manifest.
|
|
40
|
+
|
|
41
|
+
### Score strict switches on independently measured outcomes
|
|
42
|
+
|
|
43
|
+
`evaluate_endpoints(predictions, late_evaluation_rows, reference=control_predictions)` joins the outputs to the same measured pair/culture rows. Its one-row-per-pair ledger reports switch, stable, discordant or tied truth; the number of cultures in which both endpoints were correct; and correct predictions across all four measurements. Supplying a comparator adds repaired, broken, retained and wrong-both labels. For the 2,713 held-out pairs in Fig. 5 and SI S14, JIPM recovers 164/326 strict switches and 638/813 confirmed stable pairs. The original one-culture simple rule recovered 133 switches. JIPM repaired 48 of its misses and lost 17 of its hits. The enhanced separate-endpoint control uses both early cultures and parental RNA, and recovers 164 switches. Each method recovers 13 switches missed by the other. The source validator refits the original three controls using the v17 training programs, then computes these changes using the package's pair-level scorer on the held-out late measurements.
|
|
44
|
+
|
|
45
|
+
The Hsp12 static prediction and observed-trajectory analyses in Tables S79–S80 use different assay inputs and protocols. Both static subsets (36 pairs with both parents held out and 56 with one held out) belong to the 144-pair panel. The companion v17 `base e5` command reproduces those analyses. The two-culture Fong API above expects its specified human cell-line measurements.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 用新的筛选数据进行预测和提名
|
|
2
|
+
|
|
3
|
+
下面的命令从训练数据拟合,再对另一张查询表预测。为了让结果可追踪,每个文件对应一个实验条件及一个输入重复。训练表多一列独立有药双扰动目标值 target;查询表只需提供预测前取得的测量。命令使用默认原生模型参数,也可以用 --parameters 指定存放构造参数的 JSON 文件。
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
jipm predict parpi --train train.csv --target target --query query.csv --profiles rna.npz --out predicted.csv
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
训练表与查询表均提供 gene_a、gene_b、untreated_a、untreated_b、treated_a、treated_b、untreated_ab。a 与 b 的各列须始终属于对应亲本。RNA NPZ 用 NumPy 的 np.savez_compressed 写入以下键;字符串标识使用 Unicode 数组。表达和功能值使用同一实验规定、与训练数据相符的尺度。RNA 本身未测得的值沿用各估计器的缺失处理。
|
|
10
|
+
|
|
11
|
+
| NPZ 键 | 内容 |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| gene_ids | 各行亲本的唯一字符串标识 |
|
|
14
|
+
| expression | 亲本扰动数 × 测量转录本数 |
|
|
15
|
+
| control_mean | 相同转录本顺序下的对照表达均值 |
|
|
16
|
+
| target_transcript_indices | 每个亲本靶转录本在矩阵中的列号,从零起算;未测该靶时填 −1 |
|
|
17
|
+
| quality | 每个亲本的四列质量数值,依次为 num_cells_filtered、response_rms_z_vs_core_control、source_fold_expr_weighted、expression_missing_fraction |
|
|
18
|
+
| transcript_ids | 与表达矩阵各列逐一对应的转录本标识。用不同 RNA 档案预测新亲本时应提供相同、已对齐的转录本坐标。 |
|
|
19
|
+
|
|
20
|
+
若后续要分配实验名额,Python 接口 model.nominate(query_pairs) 直接复用这些输入和预测。命令行调用 jipm nominate 时,先把预测和无药双扰动读数按显式组合与重复键连接,形成含 gene_a、gene_b、treated_prediction、untreated_ab 的候选表。目标年的实测药敏保留给最后计分。药物处理预测减去同一组合的无药表型,较小的数值优先;实测强增敏分数 ρ 按原研究定义单独提供。
|
|
21
|
+
|
|
22
|
+
在同一批留出组合比较误差时,将每项预测与独立实测按组合、重复或 guide 主键配对。论文的 6,257 个双批次组合中,预测变动与误差改善的跨批次秩相关分别为 0.503 和 0.109。应用时可用 compare_responses 按相同基因对和实验条件导出误差改善。Fong 早期和晚期指标的结构及列名见 endpoints.md,Jonikas 的表达/表型坐标及其反向构造见 direction.md,固定预算筛选及同池计分见 nomination.md。
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Fixed-budget partner nomination
|
|
2
|
+
|
|
3
|
+
This readout reuses frozen predictions of treated double perturbations. A prediction minus the measured untreated double gives the input-side drug-specific **ranking score**. Experimental validation uses independently measured target-culture ρ, with the assay's controls, guide aggregation, and population-doubling normalization. Smaller values indicate stronger sensitization.
|
|
4
|
+
|
|
5
|
+
## Primary prediction → decision
|
|
6
|
+
|
|
7
|
+
Supply one eligible combination per row for one screen and one input replicate. Use stable gene identifiers (HGNC IDs in the paper). The predictor mean and the vehicle measurement must be on the same assay scale.
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from jipm import nominate_pairs, rank_candidates, score_nominations
|
|
11
|
+
|
|
12
|
+
# A fitted PARPi regressor returns gene_a, gene_b, untreated_ab, treated_prediction.
|
|
13
|
+
candidates = model.predict_components(query)
|
|
14
|
+
choices = nominate_pairs(candidates)
|
|
15
|
+
eligible = rank_candidates(candidates)
|
|
16
|
+
# other_rep_rho contains gene_a, gene_b, rho for the original pool.
|
|
17
|
+
scored = score_nominations(choices, eligible, other_rep_rho)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The default budget is one nomination for each anchor with at least ten eligible partners. Each unordered combination contributes a candidate to each of its two parents' pools. A directed table with `anchor`, `partner` can instead describe anchor-specific eligibility; each row then contributes to its stated pool. The returned `anchor`, `partner`, `pool_size`, `predicted_contrast`, and rank describe each decision. Identifier order resolves tied scores.
|
|
21
|
+
|
|
22
|
+
## Matched controls and shortlist decisions
|
|
23
|
+
|
|
24
|
+
- Supply `single_a` and `single_b` for pair input, or `partner_single` in a directed table. Use source-culture single-gene sensitivity for the partner. `common_pool=True` filters unavailable single measurements before computing eligibility and all ranks. Use this setting for both `rank_candidates` and the JIPM arm when comparing it with partner-only.
|
|
25
|
+
- `rule="partner_single"` picks the partner with the strongest single-perturbation response. `"equal_rank"` minimizes the sum of the single and full-JIPM ranks over the complete eligible pool. Ties use JIPM rank, then identifier.
|
|
26
|
+
- The two source rankings also define a shortlist: the union of the top three of each. `"rank4"` uses source-fitted `rank4_worst` and `rank4_sum` (worst and total full-pool rank across the available source repeats), followed by JIPM rank and identifier. These ranks come from a separate rank-four response model. The native PARPi completion estimator has a rank-two component.
|
|
27
|
+
- Supply `corrected_score` for each shortlisted candidate to use the outcome-free downstream selection policy from S17. Smaller scores have priority. The original functional model ranks its source-fitted responses within each full pool, then uses `1000 * worst_source_rank + sum_source_rank`. `"restricted"` keeps any nomination on which the equal-rank and rank-four rules agree. `"open_diagnostic"` allows the same correction to rerank every shortlist, including agreements. Both resolve remaining corrected-score ties by partner ID. The v17 reference study's `nominations all` command trains the rank-four and functional scores from source-year screens. This decision API consumes those predictions or equivalent new source-fitted scores.
|
|
28
|
+
|
|
29
|
+
## Combining the two source repeats
|
|
30
|
+
|
|
31
|
+
For S16 native transfer, start with the shared pair pool and **average the two
|
|
32
|
+
source drug-minus-vehicle scores** on their original scale. Pass this mean as
|
|
33
|
+
`predicted_contrast` to `nominate_pairs`. The paper also evaluated the external
|
|
34
|
+
K-PMF-b predictions using this rule. Each source batch produces its own choices.
|
|
35
|
+
|
|
36
|
+
For the S17 extension, construct the common directed pools using candidate
|
|
37
|
+
availability in both repeats of both batches. Within each anchor's pool, the
|
|
38
|
+
mean native score and mean partner-single score give the two ranks used by
|
|
39
|
+
`equal_rank` and the top-three union. The **rank-four** and **corrected** predictions
|
|
40
|
+
each supply a separate rank per source repeat over the full pool. Smaller
|
|
41
|
+
predicted responses receive better ranks. The worse repeat rank, followed
|
|
42
|
+
by the sum of the two ranks, gives the transfer ordering. Evaluate the final
|
|
43
|
+
rank-four and corrected choices on the shortlist, using these full-pool ranks.
|
|
44
|
+
|
|
45
|
+
For example, let `data` contain one row per eligible `anchor`, `partner` from a
|
|
46
|
+
single source batch. `predicted_contrast` and `partner_single` hold the two
|
|
47
|
+
source-repeat means. Four further columns supply the source-fitted rank-four
|
|
48
|
+
and corrected predictions for repeats 1 and 2. The following builds the public
|
|
49
|
+
API inputs directly. The lexicographic order for corrected choices gives the
|
|
50
|
+
same ordering as the paper's score-code on its candidate pools.
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
pool = data.sort_values(["anchor", "partner"]).copy()
|
|
54
|
+
rank4 = pool.groupby("anchor")[["rank4_r1", "rank4_r2"]].rank(method="first")
|
|
55
|
+
corr = pool.groupby("anchor")[["correction_r1", "correction_r2"]].rank(method="first")
|
|
56
|
+
pool["rank4_worst"] = rank4.max(axis=1)
|
|
57
|
+
pool["rank4_sum"] = rank4.sum(axis=1)
|
|
58
|
+
pool["corr_worst"] = corr.max(axis=1)
|
|
59
|
+
pool["corr_sum"] = corr.sum(axis=1)
|
|
60
|
+
pool = pool.sort_values(["anchor", "corr_worst", "corr_sum", "partner"])
|
|
61
|
+
pool["corrected_score"] = pool.groupby("anchor").cumcount()
|
|
62
|
+
choices = nominate_pairs(pool, rule="restricted")
|
|
63
|
+
eligible = rank_candidates(pool, common_pool=True)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
In S16 and S17, the same-year analysis uses a single designated input repeat.
|
|
67
|
+
For strict cross-batch evaluation, pass the other batch's independent
|
|
68
|
+
`readouts=("rho1", "rho2")` to `score_nominations`. A strong hit has negative
|
|
69
|
+
ρ and a measured rank no greater than ceil(pool size/10) in each requested
|
|
70
|
+
readout. An exact-best hit has negative ρ and rank one in each. Pass every
|
|
71
|
+
eligible partner for each anchor so the target ranks cover the full pool.
|
|
72
|
+
|
|
73
|
+
## Measured verification
|
|
74
|
+
|
|
75
|
+
`validation/check_nomination.py` checks individual nominee IDs, hit flags and exact-best flags against the v17 ledgers. It accepts the restored v17 repo, the `parpi` study-output directory, the `nominations all` output and a JSON receipt path. On the native full pools, the calibrated predictor, its historical full-strength version and K-PMF-b each reproduced all 1,174 decisions. Relative to K-PMF-b, calibrated predictions gained 22 strong hits and lost 4, while the historical full-strength predictions gained 21 and lost 3 (S16). The two common-pool comparators also reproduced all 1,174 decisions. For five S17 decision rules the check covers all 1,174 within-year and all 582 cross-year slots. Within-year first-place recoveries are 908 (rank four), 915 (restricted), and 934 (open diagnostic). Cross-year equal ranking yields 279 and 264 dual-repeat strong hits; restricted yields 277 and 263. These results pertain to their distinct evaluation targets.
|
|
76
|
+
|
|
77
|
+
Run `python examples/nomination.py` from the source distribution for a measured example that includes a gain and a loss. It ships the full 2022 D1→Y2 candidate and independent second-replicate outcome rows for two anchors. They are the alphabetically first individual gain (BARD1) and loss (CNOT1) in that direction versus partner-single, selected for illustration. In the common pools JIPM selected MLH1 for BARD1 (observed rank 5/52 versus XRCC1 at 8/52) and DCTN5 for CNOT1 (19/47 versus RFC1 at 3/47).
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
## Rescoring the same nominations in two batches
|
|
81
|
+
|
|
82
|
+
The eligible candidates and nominees retain experimental identifiers such as
|
|
83
|
+
`source_year` and `input_rep` when supplied. Select one source context per
|
|
84
|
+
call. Pass the same `choices` and `eligible` to `score_nominations` twice,
|
|
85
|
+
using the respective batch's measured `rho1` and `rho2` for every eligible
|
|
86
|
+
candidate. If the outcome table supplies `year`, each output records that value
|
|
87
|
+
as `scored_year`. Pool digests protect the original partner identities for each
|
|
88
|
+
anchor. For externally supplied choices without a saved digest, the original
|
|
89
|
+
membership can only be established using the archived eligible candidate list.
|
|
90
|
+
|
|
91
|
+
In the v52.1 fixed-choice analysis, each direction has 291 anchors. Across the
|
|
92
|
+
two source batches the restricted rule had four strong hits unique to it under
|
|
93
|
+
source-batch scoring. With the same choices and the same two-replicate criterion,
|
|
94
|
+
target-batch scoring produced three ties with equal ranking and one loss among
|
|
95
|
+
those four decisions. The analysis describes transfer across experimental
|
|
96
|
+
batches, which also differed in drug exposure and sequencing conditions.
|
|
97
|
+
|
|
98
|
+
For the native S16 model the strict cross-batch counts are 277 and 262 for
|
|
99
|
+
calibrated JIPM, and 274 and 263 for K-PMF-b. In S17 the comparison uses
|
|
100
|
+
the restricted shortlist rule (277 and 263) and equal ranking (279 and 264).
|
|
101
|
+
`validation/nomination.json` reports both sets using their own comparison
|
|
102
|
+
methods and candidate pools.
|
jipm-0.1.1/docs/parpi.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# PARPi treated-double response
|
|
2
|
+
|
|
3
|
+
Fit one batch and one replicate direction per `PARPiRegressor`. Each training target is the treated double-perturbation response in the target replicate. The predictors come from the input replicate. Supply one row per training pair, with guide-matched untreated and treated parental singles and the untreated double on the original assay scale. The GSE284018 benchmark uses K562 Perturb-seq profiles with matched coordinates and control normalization.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from jipm import JIPM, RNAProfiles
|
|
7
|
+
|
|
8
|
+
# train and candidates have gene_a, gene_b, untreated_a, untreated_b,
|
|
9
|
+
# treated_a, treated_b and untreated_ab. y_train follows train row order.
|
|
10
|
+
system = JIPM("parpi", gene_penalty=3.0).fit(train, y_train, profiles=rna)
|
|
11
|
+
response = system.predict(candidates)
|
|
12
|
+
audit = system.model.predict_components(candidates)
|
|
13
|
+
nominations = system.nominate(candidates)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
For a parent whose RNA arrives later, pass `profiles=new_rna` to `predict` or `predict_components`. Supply every parent in that query and preserve the training transcript coordinates, control reference and measurement scale. RNA and pair formats are shared with the ATR adapter. Train and query gene IDs use the same namespace. Gene names and their attached measurements travel together under exchange. Native input names may also use `ut_a`, `ut_b`, `drug_a`, `drug_b`, `ut_ab`. Each returned row retains its input orientation and index.
|
|
17
|
+
|
|
18
|
+
## Statistical specification
|
|
19
|
+
|
|
20
|
+
Each ensemble member fits parental intercepts, ten invariant functional coordinates, parental slopes on the untreated interaction and on the partner’s treated single, a signed rank-two pair term and a synchronous RNA-by-functional product kernel. A second fit with the pair term removed re-estimates all remaining coefficients. Both arms use training-parent RNA PCA, canonical parent order, the same landmark seed and the manuscript's profiled penalized objective. The default averages the native three seeds, with up to 1,536 training landmarks and 64 components. For a small panel, the number of components is capped by the number of observed training parents and transcript axes. The actual value is exposed as `n_components_`. The kernel penalty is 0.1. The manuscript’s parental penalty is 3 for three batch/direction tasks and 1 for the 2022 input-replicate-2 task.
|
|
21
|
+
|
|
22
|
+
Let F and N be the ensemble-mean full and reduced predictions. For two parents each represented with other partners during fitting, the output is N + gamma × (F − N). For a new parent the output is N. The result table gives both predictions, the count of represented parents, the coefficient used and the routed output. The model uses the experimental RNA and functional measurements for either coverage class.
|
|
23
|
+
|
|
24
|
+
The default fits gamma using five reproducible training-only whole-pair holdouts. Each evaluation pair retains both parents in the corresponding fitting subset. The squared-error contributions of repeated appearances are averaged within each pair before computing the bounded least-squares coefficient. For an exact existing experiment, supply the original splits as `calibration_splits=[(train_positions, heldout_positions), ...]` to `fit`; arbitrary new data use the package's five sampled holdouts. Alternatively supply an already-fixed `gamma` at construction. A sparse panel with no eligible two-seen-parent calibration pairs requires such an external coefficient. `calibrate_parpi_gain` in `jipm.parpi` also estimates a coefficient from independently prepared out-of-fold predictions.
|
|
25
|
+
|
|
26
|
+
## Verification
|
|
27
|
+
|
|
28
|
+
The bundled validation programs use a separately prepared v17 archive and installed JIPM. `validation/check_parpi.py` compares directly against native refits on 300 real training pairs, 80 held-out pairs, 8,248 RNA coordinates, 64 components, 48 landmarks and all three seeds. The validation includes 15 zero-seen, 55 one-seen and ten two-seen queries. Its fixed coefficient of 0.6 isolates the statistical implementation. `validation/check_parpi_calibration.py` uses the original training-only predictions for the 20 published resplits to test the four batch/direction coefficients and the final coverage-routed predictions. `validation/check_parpi_full_fit.py` provides the full-cohort, full-landmark comparison on the 2022 forward task. These programs report fitted-arm agreement separately from calibration and scoring checks.
|
|
29
|
+
|
|
30
|
+
The full four-task paper reproduction, row-level decision ledgers, source identification and external adapter protocol are in the v17 companion. The partner nomination diagnostic with an independently fitted rank-four reference and wider permission to reorder candidates is described in the paper's SI. Nomination based on this regressor uses the routed treated response and the observed untreated double.
|
|
31
|
+
|
|
32
|
+
## Matched parent correspondence across screens
|
|
33
|
+
|
|
34
|
+
Supplementary Section S11 compares the predictions of two independently fitted product kernels on the same measured pairs. Both use the same RNA and functional inputs, 64 training PCA coordinates and, by default, the three published sets of 1,536 training landmarks. The RNA and functional bandwidth multipliers are 0.1 and 1, respectively. Each arm uses its own mean training diagonal for normalization and fits its own coefficients with a ridge penalty of 0.01 and an unpenalized intercept. The synchronously averaged kernel retains the measured pairings. The independent arm averages each assay over the two gene orders separately. Both yield exchange-invariant predictions. This comparison uses a pure kernel, with no parent offsets, low-rank components or partner nominations.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from jipm import PARPiCorrespondence
|
|
38
|
+
|
|
39
|
+
model = PARPiCorrespondence().fit(train_pairs, opposite_replicate_response, profiles=rna)
|
|
40
|
+
predictions = model.predict(heldout_pairs)
|
|
41
|
+
print(predictions[["pred_sync", "pred_ind", "rms", "high"]])
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Fit one model per experimental batch and input replicate direction. For the paper comparison both query parents occur in training with other partners. The training pairs must be distinct. The two forecast columns have the units of the supplied target. The RMS of the difference between the raw kernels is computed across training landmarks pooled over the seeds. A training pair's own landmark is excluded. The fitted training median `threshold_` defines the prespecified high group by strict exceedance. Group assignment uses the measured inputs and is independent of the held-out outcomes.
|
|
45
|
+
|
|
46
|
+
Among pairs absent from the ATR primary panel, the mean squared error reductions relative to the independently symmetrized arm were 1.03% and 2.31% on 6,309 pairs in 2022, then 2.34% and 2.93% on 6,095 pairs in 2023 (input replicate 1 then 2). Comparing average reductions between the high and low groups on the full panels gives a positive difference in two of four batch-by-direction comparisons. The two calculations have different denominators. The second result describes a comparison of group means.
|
|
47
|
+
|
|
48
|
+
For the actual twelve seed fits and row-level checks, prepare the external v17 release and run the program in the source distribution:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python validation/check_parpi_correspondence.py /path/to/v17/JIPM --out correspondence.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The program checks the two forecasts and group assignments before calculating relative MSE reductions. See `validation/parpi_correspondence_v521.json` for the current release's results.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# JIPM 的四条预测路径
|
|
2
|
+
|
|
3
|
+
JIPM 的共同输入单位是一对基因及其已取得的扰动测量。先确定预测目标,再确定交换 A、B 时,哪些记录要一起移动,输出应否变号。下表按 v52.1 方法与补充材料 S1 的四个拟合实例组织。搭档提名直接使用第四行给出的连续预测。
|
|
4
|
+
|
|
5
|
+
| 路径 | 预测时已有的证据 | 需要估计的量 | 对照论文的位置 |
|
|
6
|
+
| --- | --- | --- | --- |
|
|
7
|
+
| 通路顺序 | 两个基因在第三方扰动中的表达指纹,以及相应的遗传表型和测量记录;训练时有有序参考标签 | 比较两个顺序的拟合得分,取半差作方向分差。反转有序输入使分差变号,零分差表示平局。Jonikas 箭头参照该实验使用的通路注释次序。 | 图 2–3,S2、S5–S8 |
|
|
8
|
+
| Fong 双端点归属 | 两次早期培养重复中,查询组合及两个单株的测量;训练组合共享的晚期单株参照 | 以亲本中点为基线,拟合晚期双扰动偏离中点的大小,再判断 MCF7、MDA-MB-231 各更接近哪个亲本。每一重复产生两个归属;两次重复合计四个均正确才获得严格换向命中。 | 图 5,S14 |
|
|
9
|
+
| ATR 药物表型 | 同一亲本的 RNA 与功能测量、输入重复的未用药双扰动、已测其他组合;可使用训练得到的亲本效应 | 预测另一重复中有药双扰动的连续表型。共同交换两个亲本时输出应保持不变。论文分别比较了联合核与来源加性、同步与分别对称化、相同联合核有无共享亲本效应。 | 图 4,S10–S13 |
|
|
10
|
+
| PARPi 药物表型与搭档选择 | 单扰动 RNA、按向导匹配的功能记录、无药双扰动,以及训练中已测的其他组合 | 先预测有药双扰动表型。原生模型结合共享亲本效应、联合核和有符号秩二配对项。已有连续预测可减去已测无药表型,再在各锚基因的候选池中选出预计药物额外作用最强的搭档。 | 图 6,S15–S17 |
|
|
11
|
+
|
|
12
|
+
## 一条交换原则如何产生两种估计
|
|
13
|
+
|
|
14
|
+
假设 A、B 的 RNA 读数分别为 +1 和 −1,功能读数也分别为 +1 和 −1。对齐后,两个亲本各自的 RNA 与功能读数乘积之和为 +2。同步调换两套记录中的 A、B,结果仍为 +2。只调换 RNA 归属,结果变为 −2。如果两套测量各自先丢掉对应关系,这两种输入就会得到相同的表示。ATR 与 PARPi 的同步和分别对称化对照在相同测量上检验了这项区别。
|
|
15
|
+
|
|
16
|
+
方向任务使用有序拟合分数的奇部分 $[F(A,B)-F(B,A)]/2$。无序表型允许两个来源的奇部分相乘,因为两者同步变号后其乘积保持不变。核分解针对归一化前的相似度;保留对应带来的 MSE 收益来自两臂分别归一化和拟合后的留出预测。
|
|
17
|
+
|
|
18
|
+
## 新数据怎样解释结果
|
|
19
|
+
|
|
20
|
+
- **保留测量归属与尺度。** 每个基因的身份、干预角色和该基因的各来源记录一起交换。药物表型须沿用训练采用的变换、单位、RNA 坐标和字段含义。提供自定义面板的已编码输入时,训练和查询应使用同一套编码;具体接收的字段见各适配器文档。
|
|
21
|
+
- **训练与查询分开。** 未用药的焦点双扰动可以是输入。留出焦点的有药双扰动或晚期双扰动只用于评价。同一基因对的不同顺序、向导、重复须按研究的留出单位分组。训练数据决定尺度、正则化和亲本覆盖。Fong 原冻结预测的适用性取决于同样的细胞系、测量角色、尺度和亲本参照。
|
|
22
|
+
- **按目标读取预测。** Fong 的端点标签表示表型接近哪个单株。PARPi 的连续模型在两个亲本都出现在训练组合时可使用完整拟合;出现新亲本时,使用其余系数一并重新估计的去配对项模型。Hsp12 的 36 对、56 对静态子集均属于 144 对母面板。已测双扰动轨迹解码使用全部 144 对;v17 的 `base e5` 可重建这些分析。
|
|
23
|
+
- **提名与验收分两步。** 先按预测增敏量在同一锚点候选池内作选择(论文主设置要求至少十个候选),再使用独立重复实测的药敏 $\rho$ 检验命中。强命中要求 $\rho<0$ 且进入该锚点完整候选池的前十分之一。目标重复的 $\rho$ 不参与候选排序。S17 的秩四短名单参照与原生 PARPi 秩二项各自拟合。开放重排的 31/133 衡量已知真实首名入围时的诊断修复数。
|
|
24
|
+
- **带上适配器和参照名称。** ATR 两个方向的 11.03%/12.93% 对比同输入的非线性来源加性,4.40%/3.08% 对比另一种对称化的联合核。Fong 的 164/326 对比原简单规则的 133/326,双早期重复的逐端点对照亦为 164/326。对新面板应报告其自身的匹配比较结果。
|
|
25
|
+
|
|
26
|
+
## Niraparib 的亲本对应关系
|
|
27
|
+
|
|
28
|
+
`JIPM("parpi-correspondence")` 在 S11 中对应独立拟合的两种乘积核,见图 4b 和表 S71–S72。剔除与 ATR 重叠的组合后,两个批次分别保留 6,309 对和 6,095 对,2022 年两个重复方向的 MSE 降幅为 1.03%、2.31%,2023 年为 2.34%、2.93%。按训练中位数预设的高差异组在完整面板的 2/4 个比较中平均增益更大。
|
|
29
|
+
|
|
30
|
+
## 来源
|
|
31
|
+
|
|
32
|
+
模型定义依据 *When joint interpretation improves prediction from paired perturbation measurements*(JIPM v52.1)的 Online Methods 及 S1。论文图表、数据来源、拆分和各比较臂的复现入口在配套的 v17 代码总包 `paper/paper_index.tsv` 中。原软件与原始研究材料的许可状态见 v17 的 `NOTICE.md`。各来源的论文结果属于相应的固定实验设计。
|