deeplc

DeepLC: Retention time prediction for peptides carrying any modification.

deeplc.calibrate(psm_list_reference, model=None, calibration=None, predict_kwargs=None)

Return a Calibration instance fitted to the reference dataset.

Parameters:
  • psm_list_reference (PSMList) – List of PSMs to use as reference for calibration.

  • model (Module | PathLike | str | None) – Trained model or path to model file.

  • calibration (Calibration | None) – Calibration instance to use. If None, SplineTransformerCalibration is used.

  • predict_kwargs (dict | None) – Additional keyword arguments to pass to the prediction function.

Returns:

Fitted calibration instance.

Return type:

Calibration

deeplc.predict(psm_list, model=None, predict_kwargs=None, return_matrix=False)

Predict retention times for a list of PSMs using a trained model.

Parameters:
  • psm_list (PSMList | list[PSM | Peptidoform | str]) – List of PSMs to predict retention times for.

  • model (Module | PathLike | str | None) – Trained model or path to model file. If None, the default DeepLC model is used.

  • predict_kwargs (dict | None) – Additional keyword arguments to pass to the prediction function.

  • return_matrix (bool) – If True, return the full prediction matrix of shape (n, n_heads) when using a multitask model. If False (default), return a 1D array of shape (n,) using head 0 when model output is 2D.

Returns:

Retention time predictions. Shape (n,) unless return_matrix=True and model produces multitask output, in which case shape is (n, n_heads).

Return type:

np.ndarray

deeplc.predict_and_calibrate(psm_list, psm_list_reference=None, model=None, calibration=None, predict_kwargs=None)

Predict retention times and calibrate to a reference.

Parameters:
  • psm_list (PSMList | list[PSM | Peptidoform | str]) – List of PSMs to predict retention times for.

  • psm_list_reference (PSMList | list[PSM | Peptidoform | str] | None) – List of PSMs to use as reference for calibration. If None, the best PSMs are automatically selected from psm_list (auto-calibration). This requires that the input PSM list contains observed retention times, score and decoy status to select the best PSMs for auto-calibration.

  • model (Module | PathLike | str | None) – Trained model or path to model file.

  • calibration (Calibration | None) – Calibration instance to use. If None, SplineTransformerCalibration is used.

  • predict_kwargs (dict | None) – Additional keyword arguments to pass to the prediction function.

Returns:

Calibrated retention time predictions.

Return type:

np.ndarray

deeplc.finetune_and_predict(psm_list, psm_list_reference=None, model=None, train_kwargs=None, predict_kwargs=None)

Fine-tune the model to a reference and predict new retention times.

Parameters:
  • psm_list (PSMList | list[PSM | Peptidoform | str]) – List of PSMs to predict retention times for.

  • psm_list_reference (PSMList | list[PSM | Peptidoform | str] | None) – List of PSMs to use as reference for calibration. If None, the best PSMs are automatically selected from psm_list (auto-calibration). This requires that the input PSM list contains observed retention times, score and decoy status to select the best PSMs for auto-calibration.

  • model (Module | PathLike | str | None) – Trained model or path to model file.

  • train_kwargs (dict | None) – Additional keyword arguments to pass to the training function.

  • predict_kwargs (dict | None) – Additional keyword arguments to pass to the prediction function.

Returns:

Calibrated retention time predictions after fine-tuning.

Return type:

np.ndarray

deeplc.finetune(psm_list_reference, psm_list_validation=None, validation_split=0.1, model=None, train_kwargs=None)

Fine-tune an existing model.

Parameters:
  • psm_list_reference (PSMList) – List of PSMs to use as reference for fine-tuning.

  • psm_list_validation (PSMList | None) – List of PSMs to use for validation during fine-tuning. If None, a split from psm_list is used.

  • validation_split (float) – Fraction of psm_list_reference to use for validation when psm_list_validation is None.

  • model (Module | PathLike | str | None) – Trained model or path to model file.

  • train_kwargs (dict | None) – Additional keyword arguments to pass to the training function.

Returns:

Fine-tuned model.

Return type:

torch.nn.Module

deeplc.save_model(model, path)

Save a model’s state dict to a file.

Use load_model() (via predict()) to reload the saved checkpoint.

Parameters:
  • model (Module) – Trained model instance to save.

  • path (PathLike | str) – Destination file path.

Return type:

None

deeplc.train(psm_list_reference, psm_list_validation=None, validation_split=0.1, train_kwargs=None)

Train a new model from scratch.

Parameters:
  • psm_list_reference (PSMList) – List of PSMs to use as reference for fine-tuning.

  • psm_list_validation (PSMList | None) – List of PSMs to use for validation. If None, a split from psm_list is used.

  • validation_split (float) – If psm_list_validation is None, this fraction of psm_list will be used for validation.

  • train_kwargs (dict | None) – Additional keyword arguments to pass to the training function.

Returns:

Trained model.

Return type:

torch.nn.Module