Skip to content

Commit 0ec6642

Browse files
committed
Fixes bug in PR #123, and update docstrings
1 parent 4917cfe commit 0ec6642

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

optimhc/rescore/mokapot.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ def rescore(
3030
psms : PsmContainer
3131
A PsmContainer object containing PSM data.
3232
model : object, optional
33-
A trained model for rescoring PSMs.
33+
An untrained mokapot-compatible model (e.g. PercolatorModel, XGBoostPercolatorModel).
34+
mokapot.brew trains it internally across cross-validation folds. If None, mokapot
35+
uses its default PercolatorModel.
3436
rescoring_features : List[str], optional
3537
A list of feature names to use for rescoring.
3638
test_fdr : float, optional
37-
The FDR threshold for testing the model. Default is 0.01.
39+
The FDR threshold used to evaluate and report results after training. Default is 0.01.
3840
**kwargs : dict
3941
Additional keyword arguments for mokapot.brew.
4042
@@ -47,19 +49,18 @@ def rescore(
4749
(i.e. PSMs, peptides) when assessed using the learned score. If a list, they will be
4850
in the same order as provided in the psms parameter.
4951
- list of Model objects:
50-
The learned Model objects, one for each fold.
52+
The trained Model objects, one for each cross-validation fold.
5153
5254
Notes
5355
-----
5456
This function:
55-
1. Converts the PsmContainer to a mokapot dataset
56-
2. Runs mokapot.brew with the specified parameters
57-
3. Returns the results and models
57+
1. Converts the PsmContainer to a mokapot LinearPsmDataset
58+
2. Passes the dataset and untrained model to mokapot.brew, which trains across folds
59+
3. Returns the per-fold confidence results and trained models
5860
"""
5961
psms = convert_to_mokapot_dataset(psms, rescoring_features=rescoring_features)
6062
logger.info("Rescoring PSMs with mokapot.")
61-
model_arg = [model] if model is not None else None
62-
results, models = mokapot.brew(psms, model=model_arg, test_fdr=test_fdr, **kwargs)
63+
results, models = mokapot.brew(psms, model=model, test_fdr=test_fdr, **kwargs)
6364
return results, models
6465

6566

0 commit comments

Comments
 (0)