oktoberfest.pr.Predictor.ce_calibration

Predictor.ce_calibration(library, ce_range, group_by_charge, xl=False, **kwargs)

Calculate best collision energy for peptide property predictions.

The function propagates the provided library object to test NCEs in the given ce range, performs intensity prediction for the 1000 highest scoring target PSMs at each NCE and computes the spectral angle between predicted and observed intensities before returning the alignment library.

Parameters:
  • library (Spectra) – spectral library to perform CE calibration on

  • ce_range (tuple[int, int]) – the min and max CE to be tested during calibration

  • group_by_charge (bool) – if true, select the top 1000 spectra independently for each precursor charge

  • xl (bool) – crosslinked or linear peptide

  • kwargs – Additional parameters that are forwarded to Koina

Return type:

Spectra

Returns:

a spectra object containing the spectral angle for each tested CE

Example:

>>> from oktoberfest.data.spectra import FragmentType, Spectra
>>> from oktoberfest import predict as pr
>>> import pandas as pd
>>> import numpy as np
>>> # Required columns: RAW_FILE, MODIFIED_SEQUENCE, COLLISION_ENERGY, PRECURSOR_CHARGE, REVERSE and SCORE
>>> meta_df = pd.DataFrame({"RAW_FILE": ["File1","File1"],
>>>                         "MODIFIED_SEQUENCE": ["AAAC[UNIMOD:4]RFVQ","RM[UNIMOD:35]PC[UNIMOD:4]HKPYL"],
>>>                         "COLLISION_ENERGY": [30,35],
>>>                         "PRECURSOR_CHARGE": [1,2],
>>>                         "FRAGMENTATION": ["HCD","HCD"],
>>>                         "REVERSE": [False,False],
>>>                         "SCORE": [0,0]})
>>> var = Spectra._gen_vars_df()
>>> library = Spectra(obs=meta_df, var=var)
>>> raw_intensities = np.random.rand(2,174)
>>> annotation = np.array([var.index,var.index])
>>> library.add_intensities(raw_intensities, annotation, FragmentType.RAW)
>>> library.strings_to_categoricals()
>>> intensity_predictor = pr.Predictor.from_koina(
>>>                         model_name="Prosit_2020_intensity_HCD",
>>>                         server_url="koina.wilhelmlab.org:443",
>>>                         ssl=True)
>>> alignment_library = intensity_predictor.ce_calibration(library=library, ce_range=(15,30), group_by_charge=False)
>>> print(alignment_library)