libpappsomspp
Library for mass spectrometry
Loading...
Searching...
No Matches
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
 
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
 
std::size_t getNumberOfCorrectedValues () const
 
Trace align (const MsRunRetentionTime< T > &msrun_retention_time_reference)
 align the current msrunretentiontime object using the given reference
 
Trace getCommonSeamarksDeltaRt (const MsRunRetentionTime< T > &msrun_retention_time_reference) const
 get common seamarks between msrunretentiontime objects and their deltart
 
const std::vector< MsRunRetentionTimeSeamarkPoint< T > > & getSeamarks () const
 
const std::vector< double > & getAlignedRetentionTimeVector () const
 get aligned retention time vector
 
void setAlignedRetentionTimeVector (const std::vector< double > &aligned_times)
 
const std::vector< double > & getMs1RetentionTimeVector () const
 get orginal retention time vector (not aligned)
 
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
 

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)
 
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

Constructor & Destructor Documentation

◆ MsRunRetentionTime() [1/2]

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

Definition at line 37 of file msrunretentiontime.cpp.

39{
40 msp_msrunReader = msrun_reader_sp;
43
44
45 std::sort(m_ms1RetentionTimeVector.begin(),
47 [](const double &a, const double &b) { return (a < b); });
48}
virtual std::vector< double > getRetentionTimeLine()
retention timeline get retention times along the MSrun in seconds
const MsRunIdCstSPtr & getMsRunId() const
pappso::MsRunReaderSPtr msp_msrunReader
std::vector< double > m_ms1RetentionTimeVector
FilterMorphoMedian m_ms2MedianFilter
pappso::MsRunIdCstSPtr mcsp_msrunId

References pappso::a, pappso::b, pappso::MsRunRetentionTime< T >::getMsRunId(), 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 51 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 70 of file msrunretentiontime.cpp.

71{
72}

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 187 of file msrunretentiontime.cpp.

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

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 165 of file msrunretentiontime.cpp.

167{
168
169 qDebug();
171 PeptideMs2Point ms2point;
172 ms2point.entityHash = peptide_id;
173 QualifiedMassSpectrum spectrum =
174 msp_msrunReader.get()->qualifiedMassSpectrum(ms2_spectrum_index, false);
175 ms2point.precursorIntensity = spectrum.getPrecursorIntensity();
176 ms2point.retentionTime = spectrum.getRtInSeconds();
177
178 // addSeamark(m_hash_fn(peptide_str.toStdString()), retentionTime);
179
180 m_allMs2Points.push_back(ms2point);
181
182 qDebug();
183}
virtual bool acquireDevice()=0
acquire data back end device
virtual QualifiedMassSpectrum qualifiedMassSpectrum(std::size_t spectrum_index, bool want_binary_data=true) const =0
get a QualifiedMassSpectrum class given its scan number
Class representing a fully specified mass spectrum.
pappso_double getPrecursorIntensity(bool *ok=nullptr) const
get precursor intensity
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 456 of file msrunretentiontime.cpp.

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

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 201 of file msrunretentiontime.cpp.

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

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

◆ correctNewTimeValues()

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

Definition at line 614 of file msrunretentiontime.cpp.

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

◆ getAlignedRetentionTimeVector()

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

get aligned retention time vector

Returns
vector of seconds (as double)

Definition at line 135 of file msrunretentiontime.cpp.

136{
138}

◆ getBackRetentionTimeReference()

template<class T >
double MsRunRetentionTime::getBackRetentionTimeReference ( ) const
protected

Definition at line 321 of file msrunretentiontime.cpp.

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

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 155 of file msrunretentiontime.cpp.

157{
158 Trace common_points;
159 getCommonDeltaRt(common_points, other_seamarks);
160 return common_points;
161}

◆ 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 254 of file msrunretentiontime.cpp.

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

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 683 of file msrunretentiontime.cpp.

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

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

◆ getFrontRetentionTimeReference()

template<class T >
double MsRunRetentionTime::getFrontRetentionTimeReference ( ) const
protected

Definition at line 311 of file msrunretentiontime.cpp.

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

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

◆ getMs1MeanFilter()

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

Definition at line 113 of file msrunretentiontime.cpp.

114{
115 return m_ms1MeanFilter;
116}

◆ getMs1RetentionTimeVector()

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

get orginal retention time vector (not aligned)

Returns
vector of seconds (as double)

Definition at line 148 of file msrunretentiontime.cpp.

149{
151}

◆ getMs2MeanFilter()

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

Definition at line 98 of file msrunretentiontime.cpp.

99{
100 return m_ms2MeanFilter;
101}

◆ getMs2MedianFilter()

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

Definition at line 83 of file msrunretentiontime.cpp.

84{
85 return m_ms2MedianFilter;
86}

◆ getMsRunId()

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

Definition at line 76 of file msrunretentiontime.cpp.

77{
78 return *(mcsp_msrunId.get());
79}

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

◆ getMsRunReaderSPtr()

template<class T >
pappso::MsRunReaderSPtr pappso::MsRunRetentionTime< T >::getMsRunReaderSPtr ( ) const

Definition at line 635 of file msrunretentiontime.cpp.

636{
637 return msp_msrunReader;
638}

◆ getNumberOfCorrectedValues()

template<class T >
std::size_t MsRunRetentionTime::getNumberOfCorrectedValues ( ) const

Definition at line 142 of file msrunretentiontime.cpp.

143{
144 return m_valuesCorrected;
145}

◆ getSeamarks()

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

Definition at line 127 of file msrunretentiontime.cpp.

128{
129 qDebug();
130 return m_seamarks;
131}

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

◆ getSeamarksReferences()

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

Definition at line 436 of file msrunretentiontime.cpp.

437{
438 std::vector<MsRunRetentionTimeSeamarkPoint<T>> other_seamarks = m_seamarks;
439 for(auto &seamark : other_seamarks)
440 {
441 seamark.retentionTime =
442 translateOriginal2AlignedRetentionTime(seamark.retentionTime);
443 }
444 return other_seamarks;
445}
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 ( ) const

◆ linearRegressionMs2toMs1()

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

Definition at line 561 of file msrunretentiontime.cpp.

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

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 642 of file msrunretentiontime.cpp.

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

◆ setMs1MeanFilter()

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

Definition at line 120 of file msrunretentiontime.cpp.

121{
122 m_ms1MeanFilter = ms1MeanFilter;
123}

◆ setMs2MeanFilter()

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

Definition at line 106 of file msrunretentiontime.cpp.

107{
108 m_ms2MeanFilter = ms2MeanFilter;
109}

◆ setMs2MedianFilter()

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

Definition at line 90 of file msrunretentiontime.cpp.

92{
93 m_ms2MedianFilter = ms2MedianFilter;
94}

◆ translateAligned2OriginalRetentionTime()

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

Definition at line 385 of file msrunretentiontime.cpp.

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

◆ translateOriginal2AlignedRetentionTime()

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

Definition at line 333 of file msrunretentiontime.cpp.

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

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

◆ msp_msrunReader


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