PyProphet / pyprophet

PyProphet: Semi-supervised learning and scoring of OpenSWATH results.
http://www.openswath.org
BSD 3-Clause "New" or "Revised" License
29 stars 21 forks source link

Assay RT calculation is not proper #73

Open shubham1637 opened 5 years ago

shubham1637 commented 5 years ago

https://github.com/PyProphet/pyprophet/blob/eb048de3014c676d704250cdd443e81af14e32f0/pyprophet/export.py#L59

To get assay_rt, we should be doing exp_rt - lib2expTrafo(delta_rt). Currently, we are subtracting library_space time from experimental_space time. lib2expTrafo function would convert delta_rt from library_space to experimental_space.

grosenberger commented 5 years ago

Are you sure? I think this is implemented after the following calculation:

https://github.com/OpenMS/OpenMS/blob/b7f3d1bb456f17a7c4ae42b20721bbfdf70e9ce3/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp#L624

shubham1637 commented 5 years ago

Before this, expected_rt is transformed using trafo.

https://github.com/OpenMS/OpenMS/blob/b7f3d1bb456f17a7c4ae42b20721bbfdf70e9ce3/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp#L1101

https://github.com/OpenMS/OpenMS/blob/b7f3d1bb456f17a7c4ae42b20721bbfdf70e9ce3/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp#L539

shubham1637 commented 5 years ago

Sorry, I should have said assay_rt calculation is not correct.

grosenberger commented 5 years ago

I'm unfortunately still not sure if I understand the problem. I think the following is happening:

Since we don't store assay RT in the OSW files, we compute this in PyProphet on the fly. For this, we use the feature RT and subtract the delta RT. All of these calculations are done in RT rather than in iRT space. Is there something going wrong in the computations? Is it correct or different in the TSV output? I thought that assay_rt is identical in the original TSV and PyProphet TSV output.

shubham1637 commented 4 years ago
  • Then the delta RT between the feature RT and assay RT is computed.

delta RT is trafo.apply(feature RT) - assay RT https://github.com/OpenMS/OpenMS/blob/b7f3d1bb456f17a7c4ae42b20721bbfdf70e9ce3/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp#L1101

EXP_RT is taken from FEATURE.EXP_RT in pyProphet, which is in the unit of experimental time, whereas delta RT is computed in the unit of library time. I haven't compared with the output file. I did compare manually in the .osw files in FEATURE and PRECURSOR table.

I am also not sure if we are on the same page for the definition of iRT. I think iRT time would be unit-less, whereas Library and Experimental time would be in the unit of second.

grosenberger commented 4 years ago

I believe delta RT is computed also in experimental time: https://github.com/OpenMS/OpenMS/blob/b7f3d1bb456f17a7c4ae42b20721bbfdf70e9ce3/src/openms/source/ANALYSIS/OPENSWATH/MRMFeatureFinderScoring.cpp#L756

What might be confusing is that expected_rt is first obtained in library space and then transformed to experimental space.

So I think the PyProphet computation is the same as the OpenSWATH, right?

shubham1637 commented 4 years ago

I am not sure about this calculation. In the final output .osw file, for one feature I calculated that FEATURE.DELTA_RT = FEATURE.NORM_RT - PRECURSOR.LIBRARY_RT Therefore, it looks like that FEATURE.DELTA_RT is in the library space.