112 template <
typename SpectrumT,
typename TransitionT>
118 std::vector<MSChromatogram > picked_chroms;
119 std::vector<MSChromatogram > smoothed_chroms;
130 !transition_group.
getTransition(native_id).isDetectingTransition() )
137 picker_.pickChromatogram(chromatogram, picked_chrom, smoothed_chrom);
139 picked_chroms.push_back(std::move(picked_chrom));
140 smoothed_chroms.push_back(std::move(smoothed_chrom));
148 SpectrumT picked_chrom, smoothed_chrom;
151 picker_.pickChromatogram(chromatogram, picked_chrom, smoothed_chrom);
152 picked_chrom.sortByIntensity();
153 picked_chroms.push_back(picked_chrom);
154 smoothed_chroms.push_back(smoothed_chrom);
162 int chr_idx, peak_idx, cnt = 0;
163 std::vector<MRMFeature> features;
166 chr_idx = -1; peak_idx = -1;
168 if (boundary_selection_method_ ==
"largest")
170 findLargestPeak(picked_chroms, chr_idx, peak_idx);
172 else if (boundary_selection_method_ ==
"widest")
174 findWidestPeakIndices(picked_chroms, chr_idx, peak_idx);
177 if (chr_idx == -1 && peak_idx == -1)
179 OPENMS_LOG_DEBUG <<
"**** No more peaks left. Nr. chroms: " << picked_chroms.size() << std::endl;
184 MRMFeature mrm_feature = createMRMFeature(transition_group, picked_chroms, smoothed_chroms, chr_idx, peak_idx);
185 double total_xic = 0;
190 features.push_back(std::move(mrm_feature));
194 if (stop_after_feature_ > 0 && cnt > stop_after_feature_) {
198 if (intensity > 0 && intensity / total_xic < stop_after_intensity_ratio_)
200 OPENMS_LOG_DEBUG <<
"**** Minimum intensity ratio reached. Nr. chroms: " << picked_chroms.size() << std::endl;
206 for (
Size i = 0; i < features.size(); i++)
210 for (
Size j = 0; j < i; j++)
212 if ((
double)mrm_feature.
getMetaValue(
"leftWidth") >= (
double)features[j].getMetaValue(
"leftWidth") &&
213 (
double)mrm_feature.
getMetaValue(
"rightWidth") <= (
double)features[j].getMetaValue(
"rightWidth") )
225 template <
typename SpectrumT,
typename TransitionT>
227 std::vector<SpectrumT>& picked_chroms,
228 const std::vector<SpectrumT>& smoothed_chroms,
239 double peak_apex = picked_chroms[chr_idx][peak_idx].getRT();
240 OPENMS_LOG_DEBUG <<
"**** Creating MRMFeature for peak " << peak_idx <<
" in chrom. " << chr_idx <<
" with " <<
241 picked_chroms[chr_idx][peak_idx] <<
" and borders " << best_left <<
" " <<
242 best_right <<
" (" << best_right - best_left <<
")" << std::endl;
244 if (use_consensus_ && recalculate_peaks_)
247 recalculatePeakBorders_(picked_chroms, best_left, best_right, recalculate_peaks_max_z_);
248 if (peak_apex < best_left || peak_apex > best_right)
251 peak_apex = (best_left + best_right) / 2.0;
255 std::vector< double > left_edges;
256 std::vector< double > right_edges;
257 double min_left = best_left;
258 double max_right = best_right;
264 remove_overlapping_features(picked_chroms, best_left, best_right);
268 pickApex(picked_chroms, best_left, best_right, peak_apex,
269 min_left, max_right, left_edges, right_edges);
272 picked_chroms[chr_idx][peak_idx].setIntensity(0.0);
277 if (min_peak_width_ > 0.0 && std::fabs(best_right - best_left) < min_peak_width_)
282 if (compute_peak_quality_)
285 double qual = computeQuality_(transition_group, picked_chroms, chr_idx, best_left, best_right, outlier);
286 if (qual < min_qual_)
300 SpectrumT master_peak_container;
301 const SpectrumT& ref_chromatogram = selectChromHelper_(transition_group, picked_chroms[chr_idx].getNativeID());
302 prepareMasterContainer_(ref_chromatogram, master_peak_container, min_left, max_right);
307 double total_intensity = 0;
double total_peak_apices = 0;
double total_xic = 0;
double total_mi = 0;
308 pickFragmentChromatograms(transition_group, picked_chroms, mrmFeature, smoothed_chroms,
309 best_left, best_right, use_consensus_,
310 total_intensity, total_xic, total_mi, total_peak_apices,
311 master_peak_container, left_edges, right_edges,
316 pickPrecursorChromatograms(transition_group,
317 picked_chroms, mrmFeature, smoothed_chroms,
318 best_left, best_right, use_consensus_,
319 total_intensity, master_peak_container, left_edges, right_edges,
322 mrmFeature.
setRT(peak_apex);
328 if (compute_total_mi_)
332 mrmFeature.
setMetaValue(
"peak_apices_sum", total_peak_apices);
350 template <
typename SpectrumT>
351 void pickApex(std::vector<SpectrumT>& picked_chroms,
352 const double best_left,
const double best_right,
const double peak_apex,
353 double &min_left,
double &max_right,
354 std::vector< double > & left_edges, std::vector< double > & right_edges)
356 for (
Size k = 0;
k < picked_chroms.size();
k++)
358 double peak_apex_dist_min = std::numeric_limits<double>::max();
360 for (
Size i = 0; i < picked_chroms[
k].size(); i++)
366 if (pa_tmp.
apex_pos > 1e-11 && std::fabs(pa_tmp.
apex_pos - peak_apex) < peak_apex_dist_min)
368 peak_apex_dist_min = std::fabs(pa_tmp.
apex_pos - peak_apex);
374 double l = best_left;
375 double r = best_right;
380 picked_chroms[
k][min_dist].setIntensity(0.0);
383 left_edges.push_back(l);
384 right_edges.push_back(r);
386 if (l < min_left) {min_left = l;}
387 if (r > max_right) {max_right = r;}
391 template <
typename SpectrumT,
typename TransitionT>
393 const std::vector<SpectrumT>& picked_chroms,
395 const std::vector<SpectrumT>& smoothed_chroms,
396 const double best_left,
const double best_right,
397 const bool use_consensus_,
398 double & total_intensity,
401 double & total_peak_apices,
402 const SpectrumT & master_peak_container,
403 const std::vector< double > & left_edges,
404 const std::vector< double > & right_edges,
411 double local_left = best_left;
412 double local_right = best_right;
421 "When using non-consensus peak picker, all transitions need to be detecting transitions.");
423 local_left = left_edges[
k];
424 local_right = right_edges[
k];
427 const SpectrumT& chromatogram = selectChromHelper_(transition_group, transition_group.
getTransitions()[
k].getNativeID());
430 for (
typename SpectrumT::const_iterator it = chromatogram.begin(); it != chromatogram.end(); it++)
432 total_xic += it->getIntensity();
437 double transition_total_xic = 0;
439 for (
typename SpectrumT::const_iterator it = chromatogram.begin(); it != chromatogram.end(); it++)
441 transition_total_xic += it->getIntensity();
445 double transition_total_mi = 0;
446 if (compute_total_mi_)
448 std::vector<unsigned int> chrom_vect_id_ranked, chrom_vect_det_ranked;
449 std::vector<double> chrom_vect_id, chrom_vect_det;
450 for (
typename SpectrumT::const_iterator it = chromatogram.begin(); it != chromatogram.end(); it++)
452 chrom_vect_id.push_back(it->getIntensity());
456 int transition_total_mi_norm = 0;
461 const SpectrumT& chromatogram_det = selectChromHelper_(transition_group, transition_group.
getTransitions()[m].getNativeID());
462 chrom_vect_det.clear();
463 for (
typename SpectrumT::const_iterator it = chromatogram_det.begin(); it != chromatogram_det.end(); it++)
465 chrom_vect_det.push_back(it->getIntensity());
469 transition_total_mi_norm++;
472 if (transition_total_mi_norm > 0) { transition_total_mi /= transition_total_mi_norm; }
477 total_mi += transition_total_mi / transition_total_mi_norm;
481 SpectrumT used_chromatogram;
483 if (peak_integration_ ==
"original")
485 used_chromatogram = resampleChromatogram_(chromatogram, master_peak_container, local_left, local_right);
487 else if (peak_integration_ ==
"smoothed")
489 if (smoothed_chroms.size() <=
k)
492 "Tried to calculate peak area and height without any smoothed chromatograms");
494 used_chromatogram = resampleChromatogram_(smoothed_chroms[
k], master_peak_container, local_left, local_right);
499 String(
"Peak integration chromatogram ") + peak_integration_ +
" is not a valid method for MRMTransitionGroupPicker");
508 double peak_integral = pa.
area;
509 double peak_apex_int = pa.
height;
511 if (background_subtraction_ !=
"none")
513 double background{0};
514 double avg_noise_level{0};
515 if (background_subtraction_ ==
"original")
517 const double intensity_left = chromatogram.PosBegin(local_left)->getIntensity();
518 const double intensity_right = (chromatogram.PosEnd(local_right) - 1)->getIntensity();
519 const UInt n_points = std::distance(chromatogram.PosBegin(local_left), chromatogram.PosEnd(local_right));
520 avg_noise_level = (intensity_right + intensity_left) / 2;
521 background = avg_noise_level * n_points;
523 else if (background_subtraction_ ==
"exact")
526 background = pb.
area;
527 avg_noise_level = pb.
height;
529 peak_integral -= background;
530 peak_apex_int -= avg_noise_level;
531 if (peak_integral < 0) {peak_integral = 0;}
532 if (peak_apex_int < 0) {peak_apex_int = 0;}
535 f.
setMetaValue(
"noise_background_level", avg_noise_level);
538 f.
setRT(picked_chroms[chr_idx][peak_idx].getMZ());
544 f.
setMZ(chromatogram.getProduct().getMZ());
545 mrmFeature.
setMZ(chromatogram.getPrecursor().getMZ());
547 if (chromatogram.metaValueExists(
"product_mz"))
549 f.
setMetaValue(
"MZ", chromatogram.getMetaValue(
"product_mz"));
550 f.
setMZ(chromatogram.getMetaValue(
"product_mz"));
553 f.
setMetaValue(
"native_id", chromatogram.getNativeID());
556 if (compute_total_mi_)
563 total_intensity += peak_integral;
564 total_peak_apices += peak_apex_int;
571 if (compute_peak_shape_metrics_)
590 mrmFeature.
addFeature(f, chromatogram.getNativeID());
594 template <
typename SpectrumT,
typename TransitionT>
596 const std::vector<SpectrumT>& picked_chroms,
598 const std::vector<SpectrumT>& smoothed_chroms,
599 const double best_left,
const double best_right,
600 const bool use_consensus_,
601 double & total_intensity,
602 const SpectrumT & master_peak_container,
603 const std::vector< double > & left_edges,
604 const std::vector< double > & right_edges,
616 double local_left = best_left;
617 double local_right = best_right;
618 if (!use_consensus_ && right_edges.size() > prec_idx && left_edges.size() > prec_idx)
620 local_left = left_edges[prec_idx];
621 local_right = right_edges[prec_idx];
624 SpectrumT used_chromatogram;
626 if (peak_integration_ ==
"original")
628 used_chromatogram = resampleChromatogram_(chromatogram, master_peak_container, local_left, local_right);
631 else if (peak_integration_ ==
"smoothed" && smoothed_chroms.size() <= prec_idx)
634 "Tried to calculate peak area and height without any smoothed chromatograms for precursors");
636 else if (peak_integration_ ==
"smoothed")
638 used_chromatogram = resampleChromatogram_(smoothed_chroms[prec_idx], master_peak_container, local_left, local_right);
643 String(
"Peak integration chromatogram ") + peak_integration_ +
" is not a valid method for MRMTransitionGroupPicker");
652 double peak_integral = pa.
area;
653 double peak_apex_int = pa.
height;
655 if (background_subtraction_ !=
"none")
657 double background{0};
658 double avg_noise_level{0};
659 if ((peak_integration_ ==
"smoothed") && smoothed_chroms.size() <= prec_idx)
662 "Tried to calculate background estimation without any smoothed chromatograms");
664 else if (background_subtraction_ ==
"original")
666 const double intensity_left = chromatogram.PosBegin(local_left)->getIntensity();
667 const double intensity_right = (chromatogram.PosEnd(local_right) - 1)->getIntensity();
668 const UInt n_points = std::distance(chromatogram.PosBegin(local_left), chromatogram.PosEnd(local_right));
669 avg_noise_level = (intensity_right + intensity_left) / 2;
670 background = avg_noise_level * n_points;
672 else if (background_subtraction_ ==
"exact")
675 background = pb.
area;
676 avg_noise_level = pb.
height;
678 peak_integral -= background;
679 peak_apex_int -= avg_noise_level;
680 if (peak_integral < 0) {peak_integral = 0;}
681 if (peak_apex_int < 0) {peak_apex_int = 0;}
684 f.
setMetaValue(
"noise_background_level", avg_noise_level);
687 f.
setMZ(chromatogram.getPrecursor().getMZ());
688 if (
k == 0) {mrmFeature.
setMZ(chromatogram.getPrecursor().getMZ());}
690 if (chromatogram.metaValueExists(
"precursor_mz"))
692 f.
setMZ(chromatogram.getMetaValue(
"precursor_mz"));
693 if (
k == 0) {mrmFeature.
setMZ(chromatogram.getMetaValue(
"precursor_mz"));}
696 f.
setRT(picked_chroms[chr_idx][peak_idx].getMZ());
701 f.
setMetaValue(
"native_id", chromatogram.getNativeID());
706 total_intensity += peak_integral;
726 template <
typename SpectrumT>
730 Size count_inside = 0;
731 for (
Size k = 0;
k < picked_chroms.size();
k++)
733 for (
Size i = 0; i < picked_chroms[
k].size(); i++)
735 if (picked_chroms[
k][i].getMZ() >= best_left && picked_chroms[
k][i].getMZ() <= best_right)
737 picked_chroms[
k][i].setIntensity(0.0);
743 Size count_overlap = 0;
745 for (
Size k = 0;
k < picked_chroms.size();
k++)
747 for (
Size i = 0; i < picked_chroms[
k].size(); i++)
749 if (picked_chroms[
k][i].getIntensity() <= 1e-11) {
continue; }
753 if ((left > best_left && left < best_right)
754 || (right > best_left && right < best_right))
756 picked_chroms[
k][i].setIntensity(0.0);
761 OPENMS_LOG_DEBUG <<
" ** Removed " << count_inside <<
" peaks enclosed in and " <<
762 count_overlap <<
" peaks overlapping with added feature." << std::endl;
766 void findLargestPeak(
const std::vector<MSChromatogram >& picked_chroms,
int& chr_idx,
int& peak_idx);
789 template <
typename SpectrumT,
typename TransitionT>
802 throw Exception::IllegalArgument(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Did not find chromatogram for id '" + native_id +
"'.");
822 template <
typename SpectrumT,
typename TransitionT>
824 const std::vector<SpectrumT>& picked_chroms,
826 const double best_left,
827 const double best_right,
833 double resample_boundary = resample_boundary_;
834 SpectrumT master_peak_container;
835 const SpectrumT& ref_chromatogram = selectChromHelper_(transition_group, picked_chroms[chr_idx].getNativeID());
836 prepareMasterContainer_(ref_chromatogram, master_peak_container, best_left - resample_boundary, best_right + resample_boundary);
837 std::vector<std::vector<double> > all_ints;
838 for (
Size k = 0;
k < picked_chroms.size();
k++)
840 const SpectrumT& chromatogram = selectChromHelper_(transition_group, picked_chroms[
k].getNativeID());
841 const SpectrumT used_chromatogram = resampleChromatogram_(chromatogram,
842 master_peak_container, best_left - resample_boundary, best_right + resample_boundary);
844 std::vector<double> int_here;
845 for (
const auto& peak : used_chromatogram) int_here.push_back(peak.getIntensity());
847 double tic = std::accumulate(int_here.begin(), int_here.end(), 0.0);
848 if (tic > 1e-11) all_ints.push_back(int_here);
852 std::vector<double> mean_shapes;
853 std::vector<double> mean_coel;
854 for (
Size k = 0;
k < all_ints.size();
k++)
856 std::vector<double> shapes;
857 std::vector<double> coel;
858 for (
Size i = 0; i < all_ints.size(); i++)
860 if (i ==
k) {
continue;}
862 all_ints[
k], all_ints[i], boost::numeric_cast<int>(all_ints[i].size()), 1);
868 shapes.push_back(res_shape);
869 coel.push_back(res_coelution);
875 msc = std::for_each(shapes.begin(), shapes.end(), msc);
876 double shapes_mean = msc.
mean();
877 msc = std::for_each(coel.begin(), coel.end(), msc);
878 double coel_mean = msc.
mean();
882 mean_shapes.push_back(shapes_mean);
883 mean_coel.push_back(coel_mean);
889 int min_index_shape = std::distance(mean_shapes.begin(), std::min_element(mean_shapes.begin(), mean_shapes.end()));
890 int max_index_coel = std::distance(mean_coel.begin(), std::max_element(mean_coel.begin(), mean_coel.end()));
893 int missing_peaks = 0;
894 int multiple_peaks = 0;
897 std::vector<double> left_borders;
898 std::vector<double> right_borders;
899 for (
Size k = 0;
k < picked_chroms.size();
k++)
908 for (
Size i = 0; i < picked_chroms[
k].size(); i++)
910 if (picked_chroms[
k][i].getMZ() >= best_left && picked_chroms[
k][i].getMZ() <= best_right)
913 if (picked_chroms[
k][i].getIntensity() > max_int)
915 max_int = picked_chroms[
k][i].getIntensity() > max_int;
922 if (l_tmp > 1e-11) left_borders.push_back(l_tmp);
923 if (r_tmp > 1e-11) right_borders.push_back(r_tmp);
925 if (pfound == 0) missing_peaks++;
926 if (pfound > 1) multiple_peaks++;
931 OPENMS_LOG_DEBUG <<
" Overall found missing : " << missing_peaks <<
" and multiple : " << multiple_peaks << std::endl;
937 if (min_index_shape == max_index_coel)
939 OPENMS_LOG_DEBUG <<
" Element " << min_index_shape <<
" is a candidate for removal ... " << std::endl;
940 outlier =
String(picked_chroms[min_index_shape].getNativeID());
952 double shape_score = std::accumulate(mean_shapes.begin(), mean_shapes.end(), 0.0) / mean_shapes.size();
953 double coel_score = std::accumulate(mean_coel.begin(), mean_coel.end(), 0.0) / mean_coel.size();
954 coel_score = (coel_score - 1.0) / 2.0;
956 double score = shape_score - coel_score - 1.0 * missing_peaks / picked_chroms.size();
958 OPENMS_LOG_DEBUG <<
" Computed score " << score <<
" (from " << shape_score <<
959 " - " << coel_score <<
" - " << 1.0 * missing_peaks / picked_chroms.size() <<
")" << std::endl;
973 template <
typename SpectrumT>
974 void recalculatePeakBorders_(
const std::vector<SpectrumT>& picked_chroms,
double& best_left,
double& best_right,
double max_z)
982 std::vector<double> left_borders;
983 std::vector<double> right_borders;
984 for (
Size k = 0;
k < picked_chroms.size();
k++)
989 for (
Size i = 0; i < picked_chroms[
k].size(); i++)
991 if (picked_chroms[
k][i].getMZ() >= best_left && picked_chroms[
k][i].getMZ() <= best_right)
1003 left_borders.push_back(left);
1004 right_borders.push_back(right);
1005 OPENMS_LOG_DEBUG <<
" * peak " <<
k <<
" left boundary " << left_borders.back() <<
" with inty " << max_int << std::endl;
1006 OPENMS_LOG_DEBUG <<
" * peak " <<
k <<
" right boundary " << right_borders.back() <<
" with inty " << max_int << std::endl;
1011 if (right_borders.empty())
1029 mean = std::accumulate(right_borders.begin(), right_borders.end(), 0.0) / (double) right_borders.size();
1030 stdev = std::sqrt(std::inner_product(right_borders.begin(), right_borders.end(), right_borders.begin(), 0.0)
1031 / right_borders.size() -
mean *
mean);
1032 std::sort(right_borders.begin(), right_borders.end());
1035 << best_right <<
" std " << stdev <<
" : " << std::fabs(best_right -
mean) / stdev
1036 <<
" coefficient of variation" << std::endl;
1039 if (std::fabs(best_right -
mean) / stdev > max_z)
1041 best_right = right_borders[right_borders.size() / 2];
1042 OPENMS_LOG_DEBUG <<
" - CV too large: correcting right boundary to " << best_right << std::endl;
1046 mean = std::accumulate(left_borders.begin(), left_borders.end(), 0.0) / (double) left_borders.size();
1047 stdev = std::sqrt(std::inner_product(left_borders.begin(), left_borders.end(), left_borders.begin(), 0.0)
1048 / left_borders.size() -
mean *
mean);
1049 std::sort(left_borders.begin(), left_borders.end());
1052 << best_left <<
" std " << stdev <<
" : " << std::fabs(best_left -
mean) / stdev
1053 <<
" coefficient of variation" << std::endl;
1056 if (std::fabs(best_left -
mean) / stdev > max_z)
1058 best_left = left_borders[left_borders.size() / 2];
1059 OPENMS_LOG_DEBUG <<
" - CV too large: correcting left boundary to " << best_left << std::endl;
1081 template <
typename SpectrumT>
1083 SpectrumT& master_peak_container,
double left_boundary,
double right_boundary)
1090 typename SpectrumT::const_iterator begin = ref_chromatogram.begin();
1091 while (begin != ref_chromatogram.end() && begin->getMZ() < left_boundary) {begin++; }
1092 if (begin != ref_chromatogram.begin()) {begin--; }
1094 typename SpectrumT::const_iterator end = begin;
1095 while (end != ref_chromatogram.end() && end->getMZ() < right_boundary) {end++; }
1096 if (end != ref_chromatogram.end()) {end++; }
1099 master_peak_container.resize(distance(begin, end));
1100 typename SpectrumT::iterator it = master_peak_container.begin();
1101 for (
typename SpectrumT::const_iterator chrom_it = begin; chrom_it != end; chrom_it++, it++)
1103 it->setMZ(chrom_it->getMZ());
1117 template <
typename SpectrumT>
1119 const SpectrumT& master_peak_container,
double left_boundary,
double right_boundary)
1124 typename SpectrumT::const_iterator begin = chromatogram.begin();
1125 while (begin != chromatogram.end() && begin->getMZ() < left_boundary) {begin++;}
1126 if (begin != chromatogram.begin()) {begin--;}
1128 typename SpectrumT::const_iterator end = begin;
1129 while (end != chromatogram.end() && end->getMZ() < right_boundary) {end++;}
1130 if (end != chromatogram.end()) {end++;}
1132 SpectrumT resampled_peak_container = master_peak_container;
1134 lresampler.
raster(begin, end, resampled_peak_container.begin(), resampled_peak_container.end());
1136 return resampled_peak_container;
#define OPENMS_LOG_DEBUG
Macro for general debugging information.
Definition: LogStream.h:480
const String & getNativeID() const
returns the native identifier for the spectrum, used by the acquisition software.
void setNativeID(const String &native_id)
sets the native identifier for the spectrum, used by the acquisition software.
A 2-dimensional hull representation in [counter]clockwise direction - depending on axis labelling.
Definition: ConvexHull2D.h:73
void setHullPoints(const PointArrayType &points)
accessor for the outer(!) points (no checking is performed if this is actually a convex hull)
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
A method or algorithm argument contains illegal values.
Definition: Exception.h:650
An LC-MS feature.
Definition: Feature.h:72
const std::vector< ConvexHull2D > & getConvexHulls() const
Non-mutable access to the convex hulls.
void setQuality(Size index, QualityType q)
Set the quality in dimension c.
void setOverallQuality(QualityType q)
Set the overall quality.
Linear Resampling of raw data with alignment.
Definition: LinearResamplerAlign.h:59
void raster(SpecT &container)
Applies the resampling algorithm to a container (MSSpectrum or MSChromatogram).
Definition: LinearResamplerAlign.h:80
A multi-chromatogram MRM feature.
Definition: MRMFeature.h:52
void addFeature(const Feature &feature, const String &key)
Adds an feature from a single chromatogram into the feature.
void addPrecursorFeature(const Feature &feature, const String &key)
Adds a precursor feature from a single chromatogram into the feature.
The MRMTransitionGroupPicker finds peaks in chromatograms that belong to the same precursors.
Definition: MRMTransitionGroupPicker.h:81
void findLargestPeak(const std::vector< MSChromatogram > &picked_chroms, int &chr_idx, int &peak_idx)
Find largest peak in a vector of chromatograms.
String boundary_selection_method_
Which method to use for selecting peaks' boundaries.
Definition: MRMTransitionGroupPicker.h:1163
String peak_integration_
Definition: MRMTransitionGroupPicker.h:1142
bool compute_total_mi_
Definition: MRMTransitionGroupPicker.h:1149
PeakPickerMRM picker_
Definition: MRMTransitionGroupPicker.h:1165
const SpectrumT & selectChromHelper_(const MRMTransitionGroup< SpectrumT, TransitionT > &transition_group, const String &native_id)
Select matching precursor or fragment ion chromatogram.
Definition: MRMTransitionGroupPicker.h:790
void prepareMasterContainer_(const SpectrumT &ref_chromatogram, SpectrumT &master_peak_container, double left_boundary, double right_boundary)
Create an empty master peak container that has the correct mz / RT values set.
Definition: MRMTransitionGroupPicker.h:1082
String background_subtraction_
Definition: MRMTransitionGroupPicker.h:1143
bool compute_peak_quality_
Definition: MRMTransitionGroupPicker.h:1147
bool use_precursors_
Definition: MRMTransitionGroupPicker.h:1145
void pickApex(std::vector< SpectrumT > &picked_chroms, const double best_left, const double best_right, const double peak_apex, double &min_left, double &max_right, std::vector< double > &left_edges, std::vector< double > &right_edges)
Apex-based peak picking.
Definition: MRMTransitionGroupPicker.h:351
double min_peak_width_
Definition: MRMTransitionGroupPicker.h:1154
void remove_overlapping_features(std::vector< SpectrumT > &picked_chroms, double best_left, double best_right)
Remove overlapping features.
Definition: MRMTransitionGroupPicker.h:727
void recalculatePeakBorders_(const std::vector< SpectrumT > &picked_chroms, double &best_left, double &best_right, double max_z)
Recalculate the borders of the peak.
Definition: MRMTransitionGroupPicker.h:974
MRMTransitionGroupPicker & operator=(const MRMTransitionGroupPicker &rhs)
Assignment operator is protected for algorithm.
int stop_after_feature_
Definition: MRMTransitionGroupPicker.h:1152
SpectrumT resampleChromatogram_(const SpectrumT &chromatogram, const SpectrumT &master_peak_container, double left_boundary, double right_boundary)
Resample a container at the positions indicated by the master peak container.
Definition: MRMTransitionGroupPicker.h:1118
double recalculate_peaks_max_z_
Definition: MRMTransitionGroupPicker.h:1155
PeakIntegrator pi_
Definition: MRMTransitionGroupPicker.h:1166
void findWidestPeakIndices(const std::vector< MSChromatogram > &picked_chroms, Int &chrom_idx, Int &point_idx) const
Given a vector of chromatograms, find the indices of the chromatogram containing the widest peak and ...
double min_qual_
Definition: MRMTransitionGroupPicker.h:1150
double resample_boundary_
Definition: MRMTransitionGroupPicker.h:1156
MRMFeature createMRMFeature(const MRMTransitionGroup< SpectrumT, TransitionT > &transition_group, std::vector< SpectrumT > &picked_chroms, const std::vector< SpectrumT > &smoothed_chroms, const int chr_idx, const int peak_idx)
Create feature from a vector of chromatograms and a specified peak.
Definition: MRMTransitionGroupPicker.h:226
~MRMTransitionGroupPicker() override
Destructor.
void updateMembers_() override
Synchronize members with param class.
double computeQuality_(const MRMTransitionGroup< SpectrumT, TransitionT > &transition_group, const std::vector< SpectrumT > &picked_chroms, const int chr_idx, const double best_left, const double best_right, String &outlier)
Compute transition group quality (higher score is better)
Definition: MRMTransitionGroupPicker.h:823
double stop_after_intensity_ratio_
Definition: MRMTransitionGroupPicker.h:1153
void pickTransitionGroup(MRMTransitionGroup< SpectrumT, TransitionT > &transition_group)
Pick a group of chromatograms belonging to the same peptide.
Definition: MRMTransitionGroupPicker.h:113
bool use_consensus_
Definition: MRMTransitionGroupPicker.h:1146
void pickFragmentChromatograms(const MRMTransitionGroup< SpectrumT, TransitionT > &transition_group, const std::vector< SpectrumT > &picked_chroms, MRMFeature &mrmFeature, const std::vector< SpectrumT > &smoothed_chroms, const double best_left, const double best_right, const bool use_consensus_, double &total_intensity, double &total_xic, double &total_mi, double &total_peak_apices, const SpectrumT &master_peak_container, const std::vector< double > &left_edges, const std::vector< double > &right_edges, const int chr_idx, const int peak_idx)
Definition: MRMTransitionGroupPicker.h:392
bool recalculate_peaks_
Definition: MRMTransitionGroupPicker.h:1144
void pickPrecursorChromatograms(const MRMTransitionGroup< SpectrumT, TransitionT > &transition_group, const std::vector< SpectrumT > &picked_chroms, MRMFeature &mrmFeature, const std::vector< SpectrumT > &smoothed_chroms, const double best_left, const double best_right, const bool use_consensus_, double &total_intensity, const SpectrumT &master_peak_container, const std::vector< double > &left_edges, const std::vector< double > &right_edges, const int chr_idx, const int peak_idx)
Definition: MRMTransitionGroupPicker.h:595
bool compute_peak_shape_metrics_
Definition: MRMTransitionGroupPicker.h:1148
std::vector< ChromatogramType > & getPrecursorChromatograms()
Definition: MRMTransitionGroup.h:237
ChromatogramType & getChromatogram(const String &key)
Definition: MRMTransitionGroup.h:219
bool hasPrecursorChromatogram(const String &key) const
Definition: MRMTransitionGroup.h:267
const String & getTransitionGroupID() const
Definition: MRMTransitionGroup.h:130
bool isInternallyConsistent() const
Check whether internal state is consistent, e.g. same number of chromatograms and transitions are pre...
Definition: MRMTransitionGroup.h:316
bool chromatogramIdsMatch() const
Ensure that chromatogram native ids match their keys in the map.
Definition: MRMTransitionGroup.h:325
bool hasTransition(const String &key) const
Definition: MRMTransitionGroup.h:170
const TransitionType & getTransition(const String &key)
Definition: MRMTransitionGroup.h:175
bool hasChromatogram(const String &key) const
Definition: MRMTransitionGroup.h:214
void addFeature(const MRMFeature &feature)
Definition: MRMTransitionGroup.h:300
const std::vector< TransitionType > & getTransitions() const
Definition: MRMTransitionGroup.h:142
ChromatogramType & getPrecursorChromatogram(const String &key)
Definition: MRMTransitionGroup.h:272
std::vector< ChromatogramType > & getChromatograms()
Definition: MRMTransitionGroup.h:186
The representation of a chromatogram.
Definition: MSChromatogram.h:57
void sortByIntensity(bool reverse=false)
Lexicographically sorts the peaks by their intensity.
void setMZ(CoordinateType coordinate)
Mutable access to the m/z coordinate (index 1)
Definition: Peak2D.h:204
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition: Peak2D.h:216
IntensityType getIntensity() const
Definition: Peak2D.h:168
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition: Peak2D.h:174
Compute the area, background and shape metrics of a peak.
Definition: PeakIntegrator.h:74
Int points_across_half_height
Definition: PeakIntegrator.h:211
double apex_pos
Definition: PeakIntegrator.h:98
ConvexHull2D::PointArrayType hull_points
Definition: PeakIntegrator.h:102
double width_at_5
Definition: PeakIntegrator.h:133
Int points_across_baseline
Definition: PeakIntegrator.h:207
double width_at_50
Definition: PeakIntegrator.h:141
double end_position_at_50
Definition: PeakIntegrator.h:165
double baseline_delta_2_height
Definition: PeakIntegrator.h:203
double height
Definition: PeakIntegrator.h:94
double end_position_at_10
Definition: PeakIntegrator.h:161
double width_at_10
Definition: PeakIntegrator.h:137
double total_width
Definition: PeakIntegrator.h:169
double end_position_at_5
Definition: PeakIntegrator.h:157
double start_position_at_50
Definition: PeakIntegrator.h:153
double tailing_factor
Definition: PeakIntegrator.h:183
double slope_of_baseline
Definition: PeakIntegrator.h:198
double start_position_at_10
Definition: PeakIntegrator.h:149
double asymmetry_factor
Definition: PeakIntegrator.h:193
double start_position_at_5
Definition: PeakIntegrator.h:145
double area
Definition: PeakIntegrator.h:90
Definition: PeakIntegrator.h:86
Definition: PeakIntegrator.h:111
Definition: PeakIntegrator.h:129
The PeakPickerMRM finds peaks a single chromatogram.
Definition: PeakPickerMRM.h:70
@ IDX_LEFTBORDER
Definition: PeakPickerMRM.h:83
@ IDX_RIGHTBORDER
Definition: PeakPickerMRM.h:83
@ IDX_ABUNDANCE
Definition: PeakPickerMRM.h:83
A more convenient string class.
Definition: String.h:60
Size ensureUniqueId()
Assigns a valid unique id, but only if the present one is invalid. Returns 1 if the unique id was cha...
functor to compute the mean and stddev of sequence using the std::foreach algorithm
Definition: StatsHelpers.h:160
double mean() const
Definition: StatsHelpers.h:197
int Int
Signed integer type.
Definition: Types.h:102
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition: openms/include/OpenMS/CONCEPT/Macros.h:120
static double mean(IteratorType begin, IteratorType end)
Calculates the mean of a range of values.
Definition: StatisticFunctions.h:120
const double k
Definition: Constants.h:158
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:48
OPENSWATHALGO_DLLAPI double rankedMutualInformation(std::vector< unsigned int > &ranked_data1, std::vector< unsigned int > &ranked_data2, const unsigned int max_rank1, const unsigned int max_rank2)
OPENSWATHALGO_DLLAPI XCorrArrayType::const_iterator xcorrArrayGetMaxPeak(const XCorrArrayType &array)
Find best peak in an cross-correlation (highest apex)
OPENSWATHALGO_DLLAPI XCorrArrayType normalizedCrossCorrelation(std::vector< double > &data1, std::vector< double > &data2, const int maxdelay, const int lag)
OPENSWATHALGO_DLLAPI unsigned int computeAndAppendRank(const std::vector< double > &v, std::vector< unsigned int > &ranks)