Jemma Daniel commited on
Commit
ef3002d
·
1 Parent(s): 0430842

Update general model

Browse files
README.md CHANGED
@@ -12,24 +12,25 @@ tags:
12
  - de-novo-peptide-sequencing
13
  ---
14
 
15
- ## Winnow General Probability Calibrator
16
 
17
  [**Winnow**](https://github.com/instadeepai/winnow) recalibrates confidence scores and provides FDR control for *de novo* peptide sequencing (DNS) workflows.
18
- This repository hosts a pretrained, general-purpose calibrator that maps raw [InstaNovo](https://github.com/instadeepai/instanovo) model confidences and complementary features (mass error, retention time, chimericity, beam features, Prosit features) to well-calibrated probabilities.
19
 
20
  - Intended inputs: spectrum input data and corresponding MS/MS PSM results produced by InstaNovo
21
- - Outputs: calibrated per-PSM probabilities in `calibrated_confidence`.
22
 
23
- ### What’s inside
24
- - `calibrator.pkl`: trained classifier
25
- - `scaler.pkl`: feature standardiser
26
- - `irt_predictor.pkl`: Prosit iRT regressor used by RT features
27
 
28
  ---
29
 
30
  ## How to use
31
 
32
  ### Python
 
33
  ```python
34
  from pathlib import Path
35
  from huggingface_hub import snapshot_download
@@ -48,7 +49,7 @@ snapshot_download(
48
  )
49
 
50
  # 2) Load calibrator
51
- calibrator = ProbabilityCalibrator.load(general_model)
52
 
53
  # 3) Load your dataset (InstaNovo-style config)
54
  dataset = InstaNovoDatasetLoader().load(
@@ -68,45 +69,55 @@ dataset.metadata["keep@5%"] = dataset.metadata["calibrated_confidence"] >= cutof
68
  ```
69
 
70
  ### CLI
 
71
  ```bash
72
  # After `pip install winnow`
73
  winnow predict \
74
- --data-source instanovo \
75
- --dataset-config-path config_with_dataset_paths.yaml \
76
- --model-folder general_model_folder \
77
- --method winnow \
78
- --fdr-threshold 0.05 \
79
- --confidence-column calibrated_confidence \
80
- --output-path outputs/winnow_predictions.csv
81
  ```
82
 
83
  ---
84
 
85
  ## Inputs and outputs
 
86
  **Required columns for calibration:**
87
- - Spectrum data (*.parquet)
 
88
  - `spectrum_id` (string): unique spectrum identifier
89
- - `sequence` (string): ground truth peptide sequence from database search (optional)
90
  - `retention_time` (float): retention time (seconds)
91
- - `precursor_mass` (float): mass of the precursor ion (from MS1)
 
92
  - `mz_array` (list[float]): mass-to-charge values of the MS2 spectrum
93
  - `intensity_array` (list[float]): intensity values of the MS2 spectrum
94
- - `precursor_charge` (int): charge of the precursor (from MS1)
95
 
96
- - Beam predictions (*_beams.csv)
97
  - `spectrum_id` (string)
98
- - `sequence` (string): ground truth peptide sequence from database search (optional)
99
- - `preds` (string): top prediction, untokenised sequence
100
- - `preds_tokenised` (string): comma‐separated tokens for the top prediction
101
- - `log_probs` (float): top prediction log probability
102
- - `preds_beam_k` (string): untokenised sequence for beam k (k≥0)
103
- - `log_probs_beam_k` (float)
104
- - `token_log_probs_k` (string/list-encoded): per-token log probabilities for beam k
105
-
106
- **Output columns (added by Winnow's calibrator on `predict`):**
 
 
 
 
 
 
 
107
  - `calibrated_confidence`: calibrated probability
108
- - Optional (if requested): `psm_pep`, `psm_fdr`, `psm_qvalue`
109
- - All input columns are retained in-place
 
110
 
111
  ---
112
 
@@ -120,8 +131,9 @@ winnow predict \
120
  - Immunopeptidomics (PXD006939)
121
  - HeLa degradome (PXD044934)
122
  - Snake venoms (PXD036161)
123
- - All default features were enabled for the training of this model.
124
- - Predictions were obtained using InstaNovo v1.1.1 with knapsack beam search set to 50 beams.
 
125
 
126
  ---
127
 
@@ -180,4 +192,5 @@ If you use the `InstaNovo` model to generate predictions, please also cite: [Ins
180
  ```
181
 
182
  ## Contact
183
- For issues with this pretrained model or usage in Winnow, please open an issue on the Winnow GitHub: https://github.com/instadeepai/winnow
 
 
12
  - de-novo-peptide-sequencing
13
  ---
14
 
15
+ # Winnow General Probability Calibrator
16
 
17
  [**Winnow**](https://github.com/instadeepai/winnow) recalibrates confidence scores and provides FDR control for *de novo* peptide sequencing (DNS) workflows.
18
+ This repository hosts a pretrained, general-purpose calibrator that maps raw [InstaNovo](https://github.com/instadeepai/instanovo) model confidences and complementary features (mass error, retention time, beam features, fragment matching features) to well-calibrated probabilities.
19
 
20
  - Intended inputs: spectrum input data and corresponding MS/MS PSM results produced by InstaNovo
21
+ - Outputs: rescored and calibrated per-PSM probabilities in `calibrated_confidence` with *de novo* FDR control.
22
 
23
+ ## What’s inside
24
+
25
+ - `model.safetensors`: trained classifier
26
+ - `config.json`: classifier hyperparameter settings
27
 
28
  ---
29
 
30
  ## How to use
31
 
32
  ### Python
33
+
34
  ```python
35
  from pathlib import Path
36
  from huggingface_hub import snapshot_download
 
49
  )
50
 
51
  # 2) Load calibrator
52
+ calibrator = ProbabilityCalibrator.load(pretrained_model_name_or_path=general_model)
53
 
54
  # 3) Load your dataset (InstaNovo-style config)
55
  dataset = InstaNovoDatasetLoader().load(
 
69
  ```
70
 
71
  ### CLI
72
+
73
  ```bash
74
  # After `pip install winnow`
75
  winnow predict \
76
+ data_loader=instanovo \
77
+ dataset.spectrum_path_or_directory=my_data.parquet \
78
+ dataset.predictions_path=my_preds.csv \
79
+ calibrator.pretrained_model_name_or_path=config_with_dataset_paths.yaml \
80
+ fdr_control.fdr_threshold=0.05 \
81
+ output_folder=outputs
 
82
  ```
83
 
84
  ---
85
 
86
  ## Inputs and outputs
87
+
88
  **Required columns for calibration:**
89
+
90
+ - Spectrum data (parquet\ipc\mgf)
91
  - `spectrum_id` (string): unique spectrum identifier
92
+ - `experiment_name` (string): MS run identifier
93
  - `retention_time` (float): retention time (seconds)
94
+ - `precursor_charge` (float): charge of the precursor ion (from MS1)
95
+ - `precursor_mz` (float): mass-to-charge of the precursor ion (from MS1)
96
  - `mz_array` (list[float]): mass-to-charge values of the MS2 spectrum
97
  - `intensity_array` (list[float]): intensity values of the MS2 spectrum
 
98
 
99
+ - Beam predictions (csv)
100
  - `spectrum_id` (string)
101
+ - `predictions` (string): top prediction, untokenised sequence
102
+ - `predictions_tokenised` (string): comma‐separated tokens for the top prediction
103
+ - `log_probability` (float): top prediction log probability
104
+ - `token_log_probabilities` (list[float]): per-token log-probabilities for the top prediction
105
+ - `predictions_beam_k` (string): untokenised sequence for beam k (k≥0)
106
+ - `log_probability_beam_k` (float)
107
+ - `token_log_probabilities_k` (string/list-encoded)
108
+
109
+ **Outputs:**
110
+
111
+ - `metadata.csv`: spectrum metadata and computed features. Contains everything *except* the prediction and FDR columns, i.e.:
112
+ - `spectrum_id`, `experiment_name`, `precursor_mz`, `precursor_charge`, `retention_time`, etc. (all pass-through spectrum columns)
113
+ All computed feature columns, including intermediate results (`mass_error_da`, `irt_error`, `ion_matches`, `margin`, etc.)
114
+ - `preds_and_fdr_metrics.csv`: predictions and FDR results. Always contains:
115
+ - `spectrum_id`
116
+ - `prediction`
117
  - `calibrated_confidence`: calibrated probability
118
+ - `psm_fdr`
119
+ - `psm_q_value`
120
+ - Optional: `psm_pep`
121
 
122
  ---
123
 
 
131
  - Immunopeptidomics (PXD006939)
132
  - HeLa degradome (PXD044934)
133
  - Snake venoms (PXD036161)
134
+ - Therapeutic nanobodies (PXD044934)
135
+ - This model uses fragment match features, iRT features, beam features, token score features and the mass error feature.
136
+ - Predictions were obtained using InstaNovo v1.2.0 with beam search set to 5 beams.
137
 
138
  ---
139
 
 
192
  ```
193
 
194
  ## Contact
195
+
196
+ For issues with this pretrained model or usage in Winnow, please open an issue on the Winnow GitHub: https://github.com/instadeepai/winnow
config.json ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "input_dim": 11,
3
+ "hidden_dims": [
4
+ 50,
5
+ 50
6
+ ],
7
+ "dropout": 0.3,
8
+ "learning_rate": 0.0001,
9
+ "weight_decay": 0.001,
10
+ "max_epochs": 1000,
11
+ "batch_size": 1024,
12
+ "n_iter_no_change": 10,
13
+ "tol": 0.0001,
14
+ "seed": 42,
15
+ "val_early_stopping_max_psms": null,
16
+ "val_subsample_seed": null,
17
+ "feature_columns": [
18
+ "ion_matches",
19
+ "ion_match_intensity",
20
+ "irt_error",
21
+ "margin",
22
+ "median_margin",
23
+ "entropy",
24
+ "z-score",
25
+ "min_token_probability",
26
+ "std_token_probability",
27
+ "mass_error_da"
28
+ ],
29
+ "feature_names": [
30
+ "Fragment Match Features",
31
+ "iRT Feature",
32
+ "Beam Features",
33
+ "Token Score Features",
34
+ "Mass Error (Da)"
35
+ ],
36
+ "features": {
37
+ "Fragment Match Features": {
38
+ "_target_": "winnow.calibration.features.fragment_match.FragmentMatchFeatures",
39
+ "mz_tolerance_ppm": 20,
40
+ "mz_tolerance_da": null,
41
+ "learn_from_missing": false,
42
+ "intensity_model_name": "Prosit_2025_intensity_22PTM",
43
+ "max_precursor_charge": 6,
44
+ "max_peptide_length": 30,
45
+ "unsupported_residues": [
46
+ "[UNIMOD:5]",
47
+ "[UNIMOD:385]",
48
+ "(+25.98)"
49
+ ],
50
+ "model_input_constants": null,
51
+ "model_input_columns": {
52
+ "collision_energies": "collision_energy",
53
+ "fragmentation_types": "frag_type"
54
+ },
55
+ "koina_server_url": "localhost:8500",
56
+ "koina_ssl": false,
57
+ "excluded_columns": [
58
+ "complementary_ion_count",
59
+ "max_ion_gap",
60
+ "spectral_angle",
61
+ "xcorr"
62
+ ]
63
+ },
64
+ "iRT Feature": {
65
+ "_target_": "winnow.calibration.features.retention_time.RetentionTimeFeature",
66
+ "train_fraction": 0.1,
67
+ "min_train_points": 5,
68
+ "learn_from_missing": false,
69
+ "seed": 42,
70
+ "irt_model_name": "Prosit_2025_irt_22PTM",
71
+ "max_peptide_length": 30,
72
+ "unsupported_residues": [
73
+ "[UNIMOD:5]",
74
+ "[UNIMOD:385]",
75
+ "(+25.98)"
76
+ ],
77
+ "koina_server_url": "localhost:8500",
78
+ "koina_ssl": false
79
+ },
80
+ "Beam Features": {
81
+ "_target_": "winnow.calibration.features.beam.BeamFeatures",
82
+ "excluded_columns": [
83
+ "edit_distance"
84
+ ]
85
+ },
86
+ "Token Score Features": {
87
+ "_target_": "winnow.calibration.features.token_score.TokenScoreFeatures"
88
+ },
89
+ "Mass Error (Da)": {
90
+ "_target_": "winnow.calibration.features.mass_error.MassErrorDaFeature",
91
+ "residue_masses": {
92
+ "G": 57.021464,
93
+ "A": 71.037114,
94
+ "S": 87.032028,
95
+ "P": 97.052764,
96
+ "V": 99.068414,
97
+ "T": 101.04767,
98
+ "C": 103.009185,
99
+ "L": 113.084064,
100
+ "I": 113.084064,
101
+ "N": 114.042927,
102
+ "D": 115.026943,
103
+ "Q": 128.058578,
104
+ "K": 128.094963,
105
+ "E": 129.042593,
106
+ "M": 131.040485,
107
+ "H": 137.058912,
108
+ "F": 147.068414,
109
+ "R": 156.101111,
110
+ "Y": 163.063329,
111
+ "W": 186.079313,
112
+ "U": 150.953633,
113
+ "O": 237.147727,
114
+ "K[UNIMOD:1]": 170.105528,
115
+ "K[UNIMOD:3]": 354.172561,
116
+ "C[UNIMOD:4]": 160.030649,
117
+ "Q[UNIMOD:7]": 129.042594,
118
+ "R[UNIMOD:7]": 157.085127,
119
+ "N[UNIMOD:7]": 115.026943,
120
+ "S[UNIMOD:21]": 166.998359,
121
+ "T[UNIMOD:21]": 181.014009,
122
+ "Y[UNIMOD:21]": 243.02966,
123
+ "E[UNIMOD:27]": 111.032028,
124
+ "Q[UNIMOD:28]": 111.032029,
125
+ "K[UNIMOD:34]": 142.110613,
126
+ "R[UNIMOD:34]": 170.116761,
127
+ "M[UNIMOD:35]": 147.0354,
128
+ "P[UNIMOD:35]": 113.047679,
129
+ "K[UNIMOD:36]": 156.126263,
130
+ "R[UNIMOD:36]": 184.132411,
131
+ "K[UNIMOD:37]": 170.141913,
132
+ "N[UNIMOD:43]": 317.1223,
133
+ "K[UNIMOD:58]": 184.121178,
134
+ "K[UNIMOD:64]": 228.111007,
135
+ "K[UNIMOD:121]": 242.13789,
136
+ "K[UNIMOD:122]": 156.089878,
137
+ "N[UNIMOD:137]": 1330.46579,
138
+ "N[UNIMOD:148]": 682.254496,
139
+ "N[UNIMOD:159]": 1006.360143,
140
+ "R[UNIMOD:188]": 162.12124,
141
+ "K[UNIMOD:214]": 272.197026,
142
+ "K[UNIMOD:259]": 136.109162,
143
+ "R[UNIMOD:267]": 166.10938,
144
+ "Y[UNIMOD:275]": 192.053493,
145
+ "N[UNIMOD:305]": 1558.576797,
146
+ "N[UNIMOD:307]": 1720.62962,
147
+ "N[UNIMOD:308]": 1882.682444,
148
+ "N[UNIMOD:309]": 1412.518888,
149
+ "N[UNIMOD:310]": 1574.571711,
150
+ "N[UNIMOD:311]": 1736.624535,
151
+ "C[UNIMOD:312]": 222.013284,
152
+ "K[UNIMOD:481]": 132.12007,
153
+ "K[UNIMOD:737]": 357.257895,
154
+ "S[UNIMOD:737]": 316.19496,
155
+ "K[UNIMOD:747]": 214.095357,
156
+ "K[UNIMOD:1289]": 198.136828,
157
+ "K[UNIMOD:1363]": 196.121178,
158
+ "N[UNIMOD:1408]": 2318.815368,
159
+ "N[UNIMOD:1409]": 2027.719952,
160
+ "N[UNIMOD:1410]": 2173.77786,
161
+ "N[UNIMOD:1452]": 1168.412966,
162
+ "N[UNIMOD:1462]": 1476.523699,
163
+ "N[UNIMOD:1465]": 1492.518613,
164
+ "N[UNIMOD:1467]": 1517.550248,
165
+ "N[UNIMOD:1468]": 1533.545162,
166
+ "N[UNIMOD:1477]": 1638.576522,
167
+ "N[UNIMOD:1480]": 1654.571437,
168
+ "N[UNIMOD:1481]": 1663.608157,
169
+ "N[UNIMOD:1484]": 1679.603071,
170
+ "N[UNIMOD:1487]": 1695.597986,
171
+ "N[UNIMOD:1488]": 1703.614305,
172
+ "N[UNIMOD:1496]": 1777.651084,
173
+ "N[UNIMOD:1500]": 1800.629346,
174
+ "N[UNIMOD:1504]": 1816.62426,
175
+ "N[UNIMOD:1506]": 1824.640579,
176
+ "N[UNIMOD:1509]": 1841.655895,
177
+ "N[UNIMOD:1510]": 1849.672213,
178
+ "N[UNIMOD:1511]": 1850.692615,
179
+ "N[UNIMOD:1519]": 1923.708993,
180
+ "N[UNIMOD:1529]": 1970.698488,
181
+ "N[UNIMOD:1531]": 1978.677084,
182
+ "N[UNIMOD:1532]": 1980.730457,
183
+ "N[UNIMOD:1534]": 1986.693402,
184
+ "N[UNIMOD:1537]": 2003.708718,
185
+ "N[UNIMOD:1540]": 2021.757006,
186
+ "N[UNIMOD:1541]": 2028.740353,
187
+ "N[UNIMOD:1547]": 2044.735267,
188
+ "N[UNIMOD:1549]": 2060.730182,
189
+ "N[UNIMOD:1551]": 2068.746501,
190
+ "N[UNIMOD:1555]": 2085.761816,
191
+ "N[UNIMOD:1559]": 2101.756731,
192
+ "N[UNIMOD:1562]": 2110.793451,
193
+ "N[UNIMOD:1722]": 1647.613242,
194
+ "N[UNIMOD:1746]": 1907.714078,
195
+ "N[UNIMOD:1761]": 1152.418052,
196
+ "N[UNIMOD:1763]": 1209.439515,
197
+ "N[UNIMOD:1766]": 1314.470875,
198
+ "N[UNIMOD:1768]": 1355.497424,
199
+ "N[UNIMOD:1769]": 1371.492339,
200
+ "N[UNIMOD:1771]": 1501.555333,
201
+ "N[UNIMOD:1772]": 1615.598261,
202
+ "N[UNIMOD:1773]": 1662.587755,
203
+ "N[UNIMOD:1775]": 1761.656169,
204
+ "N[UNIMOD:1776]": 1818.677633,
205
+ "N[UNIMOD:1777]": 1865.667128,
206
+ "N[UNIMOD:1778]": 1866.687529,
207
+ "N[UNIMOD:1779]": 1898.677358,
208
+ "N[UNIMOD:1780]": 1939.703908,
209
+ "N[UNIMOD:1781]": 1964.735542,
210
+ "N[UNIMOD:1782]": 2011.725037,
211
+ "N[UNIMOD:1783]": 2012.745438,
212
+ "N[UNIMOD:1784]": 2052.751586,
213
+ "N[UNIMOD:1785]": 2069.766902,
214
+ "N[UNIMOD:1840]": 2206.788091,
215
+ "K[UNIMOD:1848]": 242.126657,
216
+ "K[UNIMOD:1849]": 214.131742,
217
+ "N[UNIMOD:1963]": 1962.682169,
218
+ "N[UNIMOD:1964]": 1994.709721,
219
+ "K[UNIMOD:2016]": 432.302109,
220
+ "N[UNIMOD:2028]": 2975.042981,
221
+ "N[UNIMOD:2029]": 2466.888927,
222
+ "[UNIMOD:1]": 42.010565,
223
+ "[UNIMOD:5]": 43.005814,
224
+ "[UNIMOD:214]": 144.102063,
225
+ "[UNIMOD:385]": -17.026549,
226
+ "[UNIMOD:737]": 229.162932,
227
+ "[UNIMOD:2016]": 304.207146,
228
+ "(+25.98)": 25.980265
229
+ },
230
+ "isotope_error_range": [
231
+ 0,
232
+ 1
233
+ ]
234
+ }
235
+ }
236
+ }
irt_predictor.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:6e60e92eb992edeec35a4ad575c692d52b9a62b0eb36e9159d72cf6bc95f1c91
3
- size 11548
 
 
 
 
calibrator.pkl → model.safetensors RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:a6bef25b6d56f887c29fa851670fe42a89c0a388838bec74ec42a2bbf53e0e52
3
- size 85140
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07dc59faaeed64a030044166b216948b54173e57338a0f2a939963f2e0bd4f3a
3
+ size 13540
scaler.pkl DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:75bd5c573b75736ab293025a8a546c2a72d218d3c855655a77132a2d452dd704
3
- size 714