libpappsomspp
Library for mass spectrometry
pappso::MsRunRetentionTime< T > Class Template Reference

#include <msrunretentiontime.h>

Classes

struct  PeptideMs2Point
 

Public Member Functions

 MsRunRetentionTime (MsRunReaderSPtr msrun_reader_sp)
 
 MsRunRetentionTime (const MsRunRetentionTime< T > &other)
 
 ~MsRunRetentionTime ()
 
pappso::MsRunReaderSPtr getMsRunReaderSPtr () const
 
const MsRunIdgetMsRunId () const
 
void setMs2MedianFilter (const FilterMorphoMedian &ms2MedianFilter)
 
void setMs2MeanFilter (const FilterMorphoMean &ms2MeanFilter)
 
void setMs1MeanFilter (const FilterMorphoMean &ms1MeanFilter)
 
const FilterMorphoMediangetMs2MedianFilter () const
 
const FilterMorphoMeangetMs2MeanFilter () const
 
const FilterMorphoMeangetMs1MeanFilter () const
 
Trace getCommonDeltaRt (const std::vector< MsRunRetentionTimeSeamarkPoint< T > > &other_seamarks) const
 
void addPeptideAsSeamark (const T &peptide_id, std::size_t ms2_spectrum_index)
 collects all peptide evidences of a given MSrun seamarks has to be converted to peptide retention time using computePeptideRetentionTimes More...
 
void addPeptideAsSeamark (const T &peptide_id, double retentionTime, double precursorIntensity)
 collects all peptide evidences of a given MSrun seamarks has to be converted to peptide retention time using computePeptideRetentionTimes More...
 
std::size_t getNumberOfCorrectedValues () const
 
Trace align (const MsRunRetentionTime< T > &msrun_retention_time_reference)
 align the current msrunretentiontime object using the given reference More...
 
Trace getCommonSeamarksDeltaRt (const MsRunRetentionTime< T > &msrun_retention_time_reference) const
 get common seamarks between msrunretentiontime objects and their deltart More...
 
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > & getSeamarks () const
 
const std::vector< double > & getAlignedRetentionTimeVector () const
 get aligned retention time vector More...
 
void setAlignedRetentionTimeVector (const std::vector< double > &aligned_times)
 
const std::vector< double > & getMs1RetentionTimeVector () const
 get orginal retention time vector (not aligned) More...
 
bool isAligned () const
 
double translateOriginal2AlignedRetentionTime (double original_retention_time) const
 
double translateAligned2OriginalRetentionTime (double aligned_retention_time) const
 
void computeSeamarks ()
 convert PeptideMs2Point into Peptide seamarks this is required before computing alignment More...
 

Protected Member Functions

double getFrontRetentionTimeReference () const
 
double getBackRetentionTimeReference () const
 
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > getSeamarksReferences () const
 

Private Types

enum class  ComputeRetentionTimeReference { maximum_intensity , weighted_intensity , last }
 

Private Member Functions

void getCommonDeltaRt (Trace &delta_rt, const std::vector< MsRunRetentionTimeSeamarkPoint< T > > &other_seamarks) const
 get a trace of common MS2 retention times (x values) by their deltart (y values) More...
 
void correctNewTimeValues (Trace &ms1_aligned_points, double correction_parameter)
 
void linearRegressionMs2toMs1 (Trace &ms1_aligned_points, const Trace &common_points)
 

Private Attributes

FilterMorphoMedian m_ms2MedianFilter
 
FilterMorphoMean m_ms2MeanFilter
 
FilterMorphoMean m_ms1MeanFilter
 
pappso::MsRunReaderSPtr msp_msrunReader
 
pappso::MsRunIdCstSPtr mcsp_msrunId
 
std::vector< double > m_ms1RetentionTimeVector
 
std::vector< double > m_alignedRetentionTimeVector
 
std::vector< MsRunRetentionTimeSeamarkPoint< T > > m_seamarks
 
std::size_t m_valuesCorrected = 0
 
std::vector< PeptideMs2Pointm_allMs2Points
 
ComputeRetentionTimeReference m_retentionTimeReferenceMethod
 

Detailed Description

template<class T>
class pappso::MsRunRetentionTime< T >

Definition at line 42 of file msrunretentiontime.h.

Member Enumeration Documentation

◆ ComputeRetentionTimeReference

template<class T >
enum class pappso::MsRunRetentionTime::ComputeRetentionTimeReference
strongprivate
Enumerator
maximum_intensity 
weighted_intensity 
last 

Definition at line 52 of file msrunretentiontime.h.

53 {
54 maximum_intensity,
55 weighted_intensity,
56 last
57 };

Constructor & Destructor Documentation

◆ MsRunRetentionTime() [1/2]

template<class T >
MsRunRetentionTime::MsRunRetentionTime ( MsRunReaderSPtr  msrun_reader_sp)

Definition at line 35 of file msrunretentiontime.cpp.

37{
38 msp_msrunReader = msrun_reader_sp;
39 mcsp_msrunId = msp_msrunReader.get()->getMsRunId();
40 m_ms1RetentionTimeVector = msp_msrunReader.get()->getRetentionTimeLine();
41
42
43 std::sort(m_ms1RetentionTimeVector.begin(),
45 [](const double &a, const double &b) { return (a < b); });
46}
pappso::MsRunReaderSPtr msp_msrunReader
std::vector< double > m_ms1RetentionTimeVector
FilterMorphoMedian m_ms2MedianFilter
pappso::MsRunIdCstSPtr mcsp_msrunId

References pappso::a, pappso::b, pappso::MsRunRetentionTime< T >::m_ms1RetentionTimeVector, pappso::MsRunRetentionTime< T >::mcsp_msrunId, and pappso::MsRunRetentionTime< T >::msp_msrunReader.

◆ MsRunRetentionTime() [2/2]

template<class T >
MsRunRetentionTime::MsRunRetentionTime ( const MsRunRetentionTime< T > &  other)

Definition at line 49 of file msrunretentiontime.cpp.

References pappso::MsRunRetentionTime< T >::m_alignedRetentionTimeVector, pappso::MsRunRetentionTime< T >::m_allMs2Points, pappso::MsRunRetentionTime< T >::m_ms1RetentionTimeVector, pappso::MsRunRetentionTime< T >::m_retentionTimeReferenceMethod, pappso::MsRunRetentionTime< T >::m_seamarks, pappso::MsRunRetentionTime< T >::m_valuesCorrected, pappso::MsRunRetentionTime< T >::mcsp_msrunId, and pappso::MsRunRetentionTime< T >::msp_msrunReader.

◆ ~MsRunRetentionTime()

template<class T >
MsRunRetentionTime::~MsRunRetentionTime

Definition at line 68 of file msrunretentiontime.cpp.

69{
70}

Member Function Documentation

◆ addPeptideAsSeamark() [1/2]

template<class T >
void MsRunRetentionTime::addPeptideAsSeamark ( const T &  peptide_id,
double  retentionTime,
double  precursorIntensity 
)

collects all peptide evidences of a given MSrun seamarks has to be converted to peptide retention time using computePeptideRetentionTimes

Parameters
peptide_idunique identifier (whichever type) of a peptide
retentionTimeretention time of this peptide observation
precursorIntensityMS2 precursorIntensity of this peptide

Definition at line 185 of file msrunretentiontime.cpp.

188{
189 PeptideMs2Point ms2point;
190 ms2point.entityHash = peptide_id;
191 ms2point.precursorIntensity = precursorIntensity;
192 ms2point.retentionTime = retentionTime;
193 m_allMs2Points.push_back(ms2point);
194}

References pappso::MsRunRetentionTime< T >::PeptideMs2Point::entityHash, pappso::MsRunRetentionTime< T >::PeptideMs2Point::precursorIntensity, and pappso::MsRunRetentionTime< T >::PeptideMs2Point::retentionTime.

◆ addPeptideAsSeamark() [2/2]

template<class T >
void MsRunRetentionTime::addPeptideAsSeamark ( const T &  peptide_id,
std::size_t  ms2_spectrum_index 
)

collects all peptide evidences of a given MSrun seamarks has to be converted to peptide retention time using computePeptideRetentionTimes

Parameters
peptide_idunique identifier (whichever type) of a peptide
ms2_spectrum_indexassociated MS2 spectrum index ot this peptide

Definition at line 163 of file msrunretentiontime.cpp.

165{
166
167 qDebug();
168 msp_msrunReader.get()->acquireDevice();
169 PeptideMs2Point ms2point;
170 ms2point.entityHash = peptide_id;
171 QualifiedMassSpectrum spectrum =
172 msp_msrunReader.get()->qualifiedMassSpectrum(ms2_spectrum_index, false);
173 ms2point.precursorIntensity = spectrum.getPrecursorIntensity();
174 ms2point.retentionTime = spectrum.getRtInSeconds();
175
176 // addSeamark(m_hash_fn(peptide_str.toStdString()), retentionTime);
177
178 m_allMs2Points.push_back(ms2point);
179
180 qDebug();
181}
Class representing a fully specified mass spectrum.
pappso_double getPrecursorIntensity(bool *ok=nullptr) const
Get the intensity of the precursor ion.
pappso_double getRtInSeconds() const
Get the retention time in seconds.

References pappso::MsRunRetentionTime< T >::PeptideMs2Point::entityHash, pappso::QualifiedMassSpectrum::getPrecursorIntensity(), pappso::QualifiedMassSpectrum::getRtInSeconds(), pappso::MsRunRetentionTime< T >::PeptideMs2Point::precursorIntensity, and pappso::MsRunRetentionTime< T >::PeptideMs2Point::retentionTime.

◆ align()

template<class T >
Trace MsRunRetentionTime::align ( const MsRunRetentionTime< T > &  msrun_retention_time_reference)

align the current msrunretentiontime object using the given reference

Parameters
msrun_retention_time_referencethe reference
Returns
a trace containing aligned MS1 retention times

Definition at line 454 of file msrunretentiontime.cpp.

456{
458 std::vector<MsRunRetentionTimeSeamarkPoint<T>> other_seamarks;
459 if(msrun_retention_time_reference.isAligned())
460 {
461 other_seamarks = msrun_retention_time_reference.getSeamarksReferences();
462 }
463 else
464 {
465 other_seamarks = msrun_retention_time_reference.getSeamarks();
466 }
467 qDebug();
468 if((m_ms1MeanFilter.getHalfWindowSize() * 2 + 1) >=
470 {
472 QObject::tr("ERROR : MS1 alignment of MS run '%1' (%2)' not possible : "
473 "\ntoo few MS1 points (%3)")
474 .arg(msp_msrunReader.get()->getMsRunId().get()->getXmlId())
475 .arg(msp_msrunReader.get()->getMsRunId().get()->getFileName())
476 .arg(m_ms1RetentionTimeVector.size()));
477 }
478
479 qDebug() << m_seamarks[0].entityHash << " " << m_seamarks[0].retentionTime
480 << " " << other_seamarks[0].entityHash
481 << other_seamarks[0].retentionTime << " ";
482 // both seamarks has to be ordered
483 Trace common_points;
484 getCommonDeltaRt(common_points, other_seamarks);
485
486 // writeTrace("lib_ms2_delta_rt.ods", common_points);
487
488 qDebug() << common_points.front().x << " " << common_points.front().y;
489 m_ms2MedianFilter.filter(common_points);
490 // writeTrace("lib_ms2_delta_rt_median.ods", common_points);
491 m_ms2MeanFilter.filter(common_points);
492 // writeTrace("lib_ms2_delta_rt_mean.ods", common_points);
493 // convert common delta rt to real retention times (for convenience)
494 qDebug() << common_points.front().x << " " << common_points.front().y;
495
496
497 // add a first point to ensure coherence:
498 DataPoint first_point;
499 first_point.x = m_ms1RetentionTimeVector.front() - (double)1;
500 if(first_point.x < 0)
501 {
502 first_point.x = 0;
503 }
504 first_point.y =
506 msrun_retention_time_reference.getFrontRetentionTimeReference();
507
508 common_points.push_back(first_point);
509 // add a last point to ensure coherence:
510 DataPoint last_point;
511 last_point.x = m_ms1RetentionTimeVector.back() + 1;
512 last_point.y = m_ms1RetentionTimeVector.back() -
513 msrun_retention_time_reference.getBackRetentionTimeReference();
514 common_points.push_back(last_point);
515 common_points.sortX();
516
517 // now, it is possible for each time range to give a new MS1 time using a
518 // linear regression on MS2 corrected times
520
521 qDebug() << common_points.front().x << " " << common_points.front().y;
522
523 Trace ms1_aligned_points;
524
525 linearRegressionMs2toMs1(ms1_aligned_points, common_points);
526
527 // writeTrace("lib_ms1_map_rt.ods", ms1_aligned_points);
528 qDebug();
529 // smoothing on MS1 points
530 m_ms1MeanFilter.filter(ms1_aligned_points);
531
532 // writeTrace("lib_ms1_map_rt_mean.ods", ms1_aligned_points);
533 // final aligned retentionTime vector
534
535 for(DataPoint &data_point : ms1_aligned_points)
536 {
537 data_point.y = (data_point.x - data_point.y);
538 }
539
540 qDebug();
541 // Here, the correction parameter is the slope of old rt points curve
542 // (divided by 4 to get a finer correction).
543 double correction_parameter =
545 (ms1_aligned_points.size());
546 // set_correction_parameter(correction_parameter / 4);
547 correction_parameter = correction_parameter / (double)4;
548 correctNewTimeValues(ms1_aligned_points, correction_parameter);
549
550 m_alignedRetentionTimeVector = ms1_aligned_points.yValues();
551
552 qDebug();
553 return ms1_aligned_points;
554}
virtual Trace & filter(Trace &data_points) const override
virtual std::size_t getHalfWindowSize() const
void computeSeamarks()
convert PeptideMs2Point into Peptide seamarks this is required before computing alignment
void linearRegressionMs2toMs1(Trace &ms1_aligned_points, const Trace &common_points)
double getFrontRetentionTimeReference() const
void correctNewTimeValues(Trace &ms1_aligned_points, double correction_parameter)
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > & getSeamarks() const
Trace getCommonDeltaRt(const std::vector< MsRunRetentionTimeSeamarkPoint< T > > &other_seamarks) const
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > getSeamarksReferences() const
double getBackRetentionTimeReference() const
A simple container of DataPoint instances.
Definition: trace.h:147
void sortX()
Definition: trace.cpp:936
pappso_double x
Definition: datapoint.h:22
pappso_double y
Definition: datapoint.h:23

References pappso::Trace::filter(), pappso::MsRunRetentionTime< T >::getBackRetentionTimeReference(), pappso::MsRunRetentionTime< T >::getFrontRetentionTimeReference(), pappso::MsRunRetentionTime< T >::getSeamarks(), pappso::MsRunRetentionTime< T >::getSeamarksReferences(), pappso::MsRunRetentionTime< T >::isAligned(), pappso::Trace::sortX(), pappso::DataPoint::x, pappso::DataPoint::y, and pappso::Trace::yValues().

◆ computeSeamarks()

template<class T >
void MsRunRetentionTime::computeSeamarks

convert PeptideMs2Point into Peptide seamarks this is required before computing alignment

Definition at line 199 of file msrunretentiontime.cpp.

200{
201
202 qDebug();
203 if(m_allMs2Points.size() == 0)
204 {
205 // already computed
206 return;
207 }
208 m_seamarks.clear();
211 {
212
213
214 std::sort(m_allMs2Points.begin(),
215 m_allMs2Points.end(),
216 [](const PeptideMs2Point &a, const PeptideMs2Point &b) {
217 if(a.entityHash == b.entityHash)
218 {
219 return (a.precursorIntensity > b.precursorIntensity);
220 }
221 return (a.entityHash < b.entityHash);
222 });
223
224 auto itend =
225 std::unique(m_allMs2Points.begin(),
226 m_allMs2Points.end(),
227 [](const PeptideMs2Point &a, const PeptideMs2Point &b) {
228 return (a.entityHash == b.entityHash);
229 });
230
231 auto it = m_allMs2Points.begin();
232 while(it != itend)
233 {
234 m_seamarks.push_back(
235 {it->entityHash, it->retentionTime, it->precursorIntensity});
236 it++;
237 }
238 }
239 m_allMs2Points.clear();
240
241 std::sort(m_seamarks.begin(),
242 m_seamarks.end(),
245 return (a.entityHash < b.entityHash);
246 });
247 qDebug();
248}

References pappso::a, and pappso::b.

◆ correctNewTimeValues()

template<class T >
void MsRunRetentionTime::correctNewTimeValues ( Trace ms1_aligned_points,
double  correction_parameter 
)
private

Definition at line 612 of file msrunretentiontime.cpp.

614{
615
617 auto new_it(ms1_aligned_points.begin());
618 auto new_nextit(ms1_aligned_points.begin());
619 new_nextit++;
620 for(; new_nextit != ms1_aligned_points.end(); ++new_nextit, ++new_it)
621 {
622 if(new_nextit->y < new_it->y)
623 {
625 new_nextit->y = new_it->y + correction_parameter;
626 }
627 }
628}

◆ getAlignedRetentionTimeVector()

template<class T >
const std::vector< double > & MsRunRetentionTime::getAlignedRetentionTimeVector

get aligned retention time vector

Returns
vector of seconds (as double)

Definition at line 133 of file msrunretentiontime.cpp.

134{
136}

◆ getBackRetentionTimeReference()

template<class T >
double MsRunRetentionTime::getBackRetentionTimeReference
protected

Definition at line 319 of file msrunretentiontime.cpp.

320{
321 if(isAligned())
322 {
323 return m_alignedRetentionTimeVector.back();
324 }
325 return m_ms1RetentionTimeVector.back();
326}

Referenced by pappso::MsRunRetentionTime< T >::align().

◆ getCommonDeltaRt() [1/2]

template<class T >
Trace MsRunRetentionTime::getCommonDeltaRt ( const std::vector< MsRunRetentionTimeSeamarkPoint< T > > &  other_seamarks) const

Definition at line 153 of file msrunretentiontime.cpp.

155{
156 Trace common_points;
157 getCommonDeltaRt(common_points, other_seamarks);
158 return common_points;
159}

◆ getCommonDeltaRt() [2/2]

template<class T >
void MsRunRetentionTime::getCommonDeltaRt ( Trace delta_rt,
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > &  other_seamarks 
) const
private

get a trace of common MS2 retention times (x values) by their deltart (y values)

Parameters
delta_rtthe trace result (common MS2 retention times vs counter part deltart)
other_seamarksseamarks of the counter part (reference)

Definition at line 252 of file msrunretentiontime.cpp.

255{
256
257 qDebug();
258 auto it = other_seamarks.begin();
259
261 {
262 while((it != other_seamarks.end()) &&
263 (it->entityHash < seamark.entityHash))
264 {
265 it++;
266 }
267 if(it == other_seamarks.end())
268 break;
269 if(it->entityHash == seamark.entityHash)
270 {
271 delta_rt.push_back(DataPoint(
272 seamark.retentionTime, seamark.retentionTime - it->retentionTime));
273 }
274 }
275
276 qDebug();
277 if((m_ms2MedianFilter.getHalfWindowSize() * 2 + 1) >= delta_rt.size())
278 {
280 QObject::tr("ERROR : MS2 alignment of MS run '%1' (%2)' not possible : "
281 "\ntoo few MS2 points (%3) in common")
282 .arg(msp_msrunReader.get()->getMsRunId().get()->getXmlId())
283 .arg(msp_msrunReader.get()->getMsRunId().get()->getFileName())
284 .arg(delta_rt.size()));
285 }
286
287 qDebug();
288 if((m_ms2MeanFilter.getHalfWindowSize() * 2 + 1) >= delta_rt.size())
289 {
291 QObject::tr("ERROR : MS2 alignment of MS run '%1' (%2)' not possible : "
292 "\ntoo few MS2 points (%3) in common")
293 .arg(msp_msrunReader.get()->getMsRunId().get()->getXmlId())
294 .arg(msp_msrunReader.get()->getMsRunId().get()->getFileName())
295 .arg(delta_rt.size()));
296 }
297 delta_rt.sortX();
298
299 // there can be multiple entities (peptides) at one retention time
300 // in this case, avoid retention time redundancy by applying unique on trace :
301 delta_rt.unique();
302
303 qDebug();
304}
void unique()
Definition: trace.cpp:952

References pappso::Trace::sortX(), and pappso::Trace::unique().

◆ getCommonSeamarksDeltaRt()

template<class T >
Trace MsRunRetentionTime::getCommonSeamarksDeltaRt ( const MsRunRetentionTime< T > &  msrun_retention_time_reference) const

get common seamarks between msrunretentiontime objects and their deltart

Parameters
msrun_retention_time_referencethe reference
Returns
a trace containing MS2 common points and their deltart

Definition at line 681 of file msrunretentiontime.cpp.

683{
684 // computeSeamarks();
685 std::vector<MsRunRetentionTimeSeamarkPoint<T>> other_seamarks;
686 if(msrun_retention_time_reference.isAligned())
687 {
688 other_seamarks = msrun_retention_time_reference.getSeamarksReferences();
689 }
690 else
691 {
692 other_seamarks = msrun_retention_time_reference.getSeamarks();
693 }
694 qDebug();
695
696 qDebug() << m_seamarks[0].entityHash << " " << m_seamarks[0].retentionTime
697 << " " << other_seamarks[0].entityHash
698 << other_seamarks[0].retentionTime << " ";
699 // both seamarks has to be ordered
700 Trace common_points;
701 getCommonDeltaRt(common_points, other_seamarks);
702 return common_points;
703}

References pappso::MsRunRetentionTime< T >::getSeamarks(), pappso::MsRunRetentionTime< T >::getSeamarksReferences(), and pappso::MsRunRetentionTime< T >::isAligned().

◆ getFrontRetentionTimeReference()

template<class T >
double MsRunRetentionTime::getFrontRetentionTimeReference
protected

Definition at line 309 of file msrunretentiontime.cpp.

310{
311 if(isAligned())
312 {
313 return m_alignedRetentionTimeVector.front();
314 }
315 return m_ms1RetentionTimeVector.front();
316}

Referenced by pappso::MsRunRetentionTime< T >::align().

◆ getMs1MeanFilter()

template<typename T >
const pappso::FilterMorphoMean & pappso::MsRunRetentionTime< T >::getMs1MeanFilter

Definition at line 111 of file msrunretentiontime.cpp.

112{
113 return m_ms1MeanFilter;
114}

◆ getMs1RetentionTimeVector()

template<class T >
const std::vector< double > & MsRunRetentionTime::getMs1RetentionTimeVector

get orginal retention time vector (not aligned)

Returns
vector of seconds (as double)

Definition at line 146 of file msrunretentiontime.cpp.

147{
149}

◆ getMs2MeanFilter()

template<typename T >
const pappso::FilterMorphoMean & pappso::MsRunRetentionTime< T >::getMs2MeanFilter

Definition at line 96 of file msrunretentiontime.cpp.

97{
98 return m_ms2MeanFilter;
99}

◆ getMs2MedianFilter()

template<typename T >
const pappso::FilterMorphoMedian & pappso::MsRunRetentionTime< T >::getMs2MedianFilter

Definition at line 81 of file msrunretentiontime.cpp.

82{
83 return m_ms2MedianFilter;
84}

◆ getMsRunId()

template<class T >
const MsRunId & MsRunRetentionTime::getMsRunId

Definition at line 74 of file msrunretentiontime.cpp.

75{
76 return *(mcsp_msrunId.get());
77}

◆ getMsRunReaderSPtr()

template<class T >
pappso::MsRunReaderSPtr pappso::MsRunRetentionTime< T >::getMsRunReaderSPtr

Definition at line 633 of file msrunretentiontime.cpp.

634{
635 return msp_msrunReader;
636}

◆ getNumberOfCorrectedValues()

template<class T >
std::size_t MsRunRetentionTime::getNumberOfCorrectedValues

Definition at line 140 of file msrunretentiontime.cpp.

141{
142 return m_valuesCorrected;
143}

◆ getSeamarks()

template<class T >
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > & MsRunRetentionTime::getSeamarks

Definition at line 125 of file msrunretentiontime.cpp.

126{
127 qDebug();
128 return m_seamarks;
129}

Referenced by pappso::MsRunRetentionTime< T >::align(), and pappso::MsRunRetentionTime< T >::getCommonSeamarksDeltaRt().

◆ getSeamarksReferences()

template<class T >
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > MsRunRetentionTime::getSeamarksReferences
protected

Definition at line 434 of file msrunretentiontime.cpp.

435{
436 std::vector<MsRunRetentionTimeSeamarkPoint<T>> other_seamarks = m_seamarks;
437 for(auto &seamark : other_seamarks)
438 {
439 seamark.retentionTime =
440 translateOriginal2AlignedRetentionTime(seamark.retentionTime);
441 }
442 return other_seamarks;
443}
double translateOriginal2AlignedRetentionTime(double original_retention_time) const

Referenced by pappso::MsRunRetentionTime< T >::align(), and pappso::MsRunRetentionTime< T >::getCommonSeamarksDeltaRt().

◆ isAligned()

template<class T >
bool MsRunRetentionTime::isAligned

◆ linearRegressionMs2toMs1()

template<class T >
void MsRunRetentionTime::linearRegressionMs2toMs1 ( Trace ms1_aligned_points,
const Trace common_points 
)
private

Definition at line 559 of file msrunretentiontime.cpp.

561{
562
563 // first slope :
564 std::vector<DataPoint>::const_iterator itms2 = common_points.begin();
565 std::vector<DataPoint>::const_iterator itms2next = itms2 + 1;
566 if(itms2next == common_points.end())
567 {
568 // error
570 QObject::tr("ERROR : MS1 alignment of MS run '%1' (%2)' not possible : "
571 "\ntoo few common points (%3)")
572 .arg(msp_msrunReader.get()->getMsRunId().get()->getXmlId())
573 .arg(msp_msrunReader.get()->getMsRunId().get()->getFileName())
574 .arg(common_points.size()));
575 }
576 qDebug() << "() itms2->x=" << itms2->x << " itms2->y=" << itms2->y;
577
578 for(double &original_rt_point : m_ms1RetentionTimeVector)
579 {
580 DataPoint ms1_point;
581 ms1_point.x = original_rt_point;
582
583 while(ms1_point.x > itms2next->x)
584 {
585 itms2++;
586 itms2next++;
587 }
588
589 double ratio = (itms2next->x - itms2->x);
590 if(ratio != 0)
591 {
592 ratio = (ms1_point.x - itms2->x) / ratio;
593 }
594 else
595 {
596 // avoid division by zero
597 ratio = 1;
598 }
599 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "() " <<
600 // ratio;
601
602 ms1_point.y = itms2->y + ((itms2next->y - itms2->y) * ratio);
603
604 // qDebug() << __FILE__ << "@" << __LINE__ << __FUNCTION__ << "() "
605 // << ms1_point.y;
606 ms1_aligned_points.push_back(ms1_point);
607 }
608}

References pappso::DataPoint::x, and pappso::DataPoint::y.

◆ setAlignedRetentionTimeVector()

template<class T >
void pappso::MsRunRetentionTime< T >::setAlignedRetentionTimeVector ( const std::vector< double > &  aligned_times)

Definition at line 640 of file msrunretentiontime.cpp.

642{
643
644 if(aligned_times.size() == m_ms1RetentionTimeVector.size())
645 {
646 m_alignedRetentionTimeVector = aligned_times;
647 }
648 else
649 {
650 if(aligned_times.size() == m_ms1RetentionTimeVector.size() * 2)
651 {
653 for(std::size_t i = 0; i < m_ms1RetentionTimeVector.size(); i++)
654 {
655 if(aligned_times[2 * i] != m_ms1RetentionTimeVector[i])
656 {
658 QObject::tr(
659 "ERROR : aligned_times (size=%1) vector does not have "
660 "required size (size=%2)")
661 .arg(aligned_times.size())
662 .arg(m_ms1RetentionTimeVector.size()));
663 }
664 m_alignedRetentionTimeVector[i] = aligned_times[(2 * i) + 1];
665 }
666 }
667 else
668 {
670 QObject::tr("ERROR : aligned_times (size=%1) vector does not have "
671 "required size (size=%2)")
672 .arg(aligned_times.size())
673 .arg(m_ms1RetentionTimeVector.size()));
674 }
675 }
676}

◆ setMs1MeanFilter()

template<class T >
void MsRunRetentionTime::setMs1MeanFilter ( const FilterMorphoMean ms1MeanFilter)

Definition at line 118 of file msrunretentiontime.cpp.

119{
120 m_ms1MeanFilter = ms1MeanFilter;
121}

◆ setMs2MeanFilter()

template<class T >
void MsRunRetentionTime::setMs2MeanFilter ( const FilterMorphoMean ms2MeanFilter)

Definition at line 104 of file msrunretentiontime.cpp.

105{
106 m_ms2MeanFilter = ms2MeanFilter;
107}

◆ setMs2MedianFilter()

template<class T >
void MsRunRetentionTime::setMs2MedianFilter ( const FilterMorphoMedian ms2MedianFilter)

Definition at line 88 of file msrunretentiontime.cpp.

90{
91 m_ms2MedianFilter = ms2MedianFilter;
92}

◆ translateAligned2OriginalRetentionTime()

template<class T >
double MsRunRetentionTime::translateAligned2OriginalRetentionTime ( double  aligned_retention_time) const

Definition at line 383 of file msrunretentiontime.cpp.

385{
386 if(m_alignedRetentionTimeVector.size() < 3)
387 {
389 QObject::tr("ERROR : too few aligned points to compute aligned "
390 "retention time (%1)")
391 .arg(m_ms1RetentionTimeVector.size()));
392 }
394 {
396 QObject::tr("ERROR : m_alignedRetentionTimeVector.size() %1 != %2 "
397 "m_ms1RetentionTimeVector.size()")
399 .arg(m_ms1RetentionTimeVector.size()));
400 }
401 auto it_plus = std::find_if(m_alignedRetentionTimeVector.begin(),
403 [aligned_retention_time](const double &rt_point) {
404 return aligned_retention_time < rt_point;
405 });
406 double rt1_a, rt2_a, rt1_b, rt2_b;
407 if(it_plus == m_alignedRetentionTimeVector.end())
408 {
409 it_plus--;
410 }
411 if(it_plus == m_alignedRetentionTimeVector.begin())
412 {
413 it_plus++;
414 }
415 auto it_minus = it_plus - 1;
416
417 rt1_a = *it_minus;
418 rt2_a = *it_plus;
419
420 double ratio = (aligned_retention_time - rt1_a) / (rt2_a - rt1_a);
421
422 auto itref = m_ms1RetentionTimeVector.begin() +
423 std::distance(m_alignedRetentionTimeVector.begin(), it_minus);
424
425 rt1_b = *itref;
426 itref++;
427 rt2_b = *itref;
428
429 return (((rt2_b - rt1_b) * ratio) + rt1_b);
430}

◆ translateOriginal2AlignedRetentionTime()

template<class T >
double MsRunRetentionTime::translateOriginal2AlignedRetentionTime ( double  original_retention_time) const

Definition at line 331 of file msrunretentiontime.cpp.

333{
334 if(m_alignedRetentionTimeVector.size() < 3)
335 {
337 QObject::tr("ERROR : too few aligned points to compute aligned "
338 "retention time (%1)")
339 .arg(m_ms1RetentionTimeVector.size()));
340 }
342 {
344 QObject::tr("ERROR : m_alignedRetentionTimeVector.size() %1 != %2 "
345 "m_ms1RetentionTimeVector.size()")
347 .arg(m_ms1RetentionTimeVector.size()));
348 }
349 auto it_plus =
350 std::find_if(m_ms1RetentionTimeVector.begin(),
352 [original_retention_time](const double &rt_point) {
353 return original_retention_time < rt_point;
354 });
355 double rt1_a, rt2_a, rt1_b, rt2_b;
356 if(it_plus == m_ms1RetentionTimeVector.end())
357 {
358 it_plus--;
359 }
360 if(it_plus == m_ms1RetentionTimeVector.begin())
361 {
362 it_plus++;
363 }
364 auto it_minus = it_plus - 1;
365
366 rt1_a = *it_minus;
367 rt2_a = *it_plus;
368
369 double ratio = (original_retention_time - rt1_a) / (rt2_a - rt1_a);
370
371 auto itref = m_alignedRetentionTimeVector.begin() +
372 std::distance(m_ms1RetentionTimeVector.begin(), it_minus);
373
374 rt1_b = *itref;
375 itref++;
376 rt2_b = *itref;
377
378 return (((rt2_b - rt1_b) * ratio) + rt1_b);
379}

Member Data Documentation

◆ m_alignedRetentionTimeVector

template<class T >
std::vector<double> pappso::MsRunRetentionTime< T >::m_alignedRetentionTimeVector
private

◆ m_allMs2Points

template<class T >
std::vector<PeptideMs2Point> pappso::MsRunRetentionTime< T >::m_allMs2Points
private

◆ m_ms1MeanFilter

template<class T >
FilterMorphoMean pappso::MsRunRetentionTime< T >::m_ms1MeanFilter
private

Definition at line 171 of file msrunretentiontime.h.

◆ m_ms1RetentionTimeVector

template<class T >
std::vector<double> pappso::MsRunRetentionTime< T >::m_ms1RetentionTimeVector
private

◆ m_ms2MeanFilter

template<class T >
FilterMorphoMean pappso::MsRunRetentionTime< T >::m_ms2MeanFilter
private

Definition at line 170 of file msrunretentiontime.h.

◆ m_ms2MedianFilter

template<class T >
FilterMorphoMedian pappso::MsRunRetentionTime< T >::m_ms2MedianFilter
private

Definition at line 169 of file msrunretentiontime.h.

◆ m_retentionTimeReferenceMethod

template<class T >
ComputeRetentionTimeReference pappso::MsRunRetentionTime< T >::m_retentionTimeReferenceMethod
private

◆ m_seamarks

template<class T >
std::vector<MsRunRetentionTimeSeamarkPoint<T> > pappso::MsRunRetentionTime< T >::m_seamarks
private

◆ m_valuesCorrected

template<class T >
std::size_t pappso::MsRunRetentionTime< T >::m_valuesCorrected = 0
private

◆ mcsp_msrunId

template<class T >
pappso::MsRunIdCstSPtr pappso::MsRunRetentionTime< T >::mcsp_msrunId
private

◆ msp_msrunReader

template<class T >
pappso::MsRunReaderSPtr pappso::MsRunRetentionTime< T >::msp_msrunReader
private

The documentation for this class was generated from the following files: