86 template <
typename SpectrumT,
typename TransitionT>
92 std::vector<MSChromatogram > picked_chroms;
93 std::vector<MSChromatogram > smoothed_chroms;
104 !transition_group.
getTransition(native_id).isDetectingTransition() )
111 picker_.pickChromatogram(chromatogram, picked_chrom, smoothed_chrom);
113 picked_chroms.push_back(std::move(picked_chrom));
114 smoothed_chroms.push_back(std::move(smoothed_chrom));
122 SpectrumT picked_chrom, smoothed_chrom;
125 picker_.pickChromatogram(chromatogram, picked_chrom, smoothed_chrom);
126 picked_chrom.sortByIntensity();
127 picked_chroms.push_back(picked_chrom);
128 smoothed_chroms.push_back(smoothed_chrom);
136 int chr_idx, peak_idx, cnt = 0;
137 std::vector<MRMFeature> features;
140 chr_idx = -1; peak_idx = -1;
142 if (boundary_selection_method_ ==
"largest")
144 findLargestPeak(picked_chroms, chr_idx, peak_idx);
146 else if (boundary_selection_method_ ==
"widest")
148 findWidestPeakIndices(picked_chroms, chr_idx, peak_idx);
151 if (chr_idx == -1 && peak_idx == -1)
153 OPENMS_LOG_DEBUG <<
"**** No more peaks left. Nr. chroms: " << picked_chroms.size() << std::endl;
158 MRMFeature mrm_feature = createMRMFeature(transition_group, picked_chroms, smoothed_chroms, chr_idx, peak_idx);
159 double total_xic = 0;
164 features.push_back(std::move(mrm_feature));
168 if (stop_after_feature_ > 0 && cnt > stop_after_feature_) {
172 if (intensity > 0 && intensity / total_xic < stop_after_intensity_ratio_)
174 OPENMS_LOG_DEBUG <<
"**** Minimum intensity ratio reached. Nr. chroms: " << picked_chroms.size() << std::endl;
180 for (
Size i = 0; i < features.size(); i++)
184 for (
Size j = 0; j < i; j++)
186 if ((
double)mrm_feature.
getMetaValue(
"leftWidth") >= (
double)features[j].getMetaValue(
"leftWidth") &&
187 (
double)mrm_feature.
getMetaValue(
"rightWidth") <= (
double)features[j].getMetaValue(
"rightWidth") )
199 template <
typename SpectrumT,
typename TransitionT>
201 std::vector<SpectrumT>& picked_chroms,
202 const std::vector<SpectrumT>& smoothed_chroms,
211 double best_left = picked_chroms[chr_idx].getFloatDataArrays()[PeakPickerChromatogram::IDX_LEFTBORDER][peak_idx];
212 double best_right = picked_chroms[chr_idx].getFloatDataArrays()[PeakPickerChromatogram::IDX_RIGHTBORDER][peak_idx];
213 double peak_apex = picked_chroms[chr_idx][peak_idx].getRT();
214 OPENMS_LOG_DEBUG <<
"**** Creating MRMFeature for peak " << peak_idx <<
" in chrom. " << chr_idx <<
" with " <<
215 picked_chroms[chr_idx][peak_idx] <<
" and borders " << best_left <<
" " <<
216 best_right <<
" (" << best_right - best_left <<
")" << std::endl;
218 if (use_consensus_ && recalculate_peaks_)
221 recalculatePeakBorders_(picked_chroms, best_left, best_right, recalculate_peaks_max_z_);
222 if (peak_apex < best_left || peak_apex > best_right)
225 peak_apex = (best_left + best_right) / 2.0;
229 std::vector< double > left_edges;
230 std::vector< double > right_edges;
231 double min_left = best_left;
232 double max_right = best_right;
238 remove_overlapping_features(picked_chroms, best_left, best_right);
242 pickApex(picked_chroms, best_left, best_right, peak_apex,
243 min_left, max_right, left_edges, right_edges);
246 picked_chroms[chr_idx][peak_idx].setIntensity(0.0);
251 if (min_peak_width_ > 0.0 && std::fabs(best_right - best_left) < min_peak_width_)
256 if (compute_peak_quality_)
259 double qual = computeQuality_(transition_group, picked_chroms, chr_idx, best_left, best_right, outlier);
260 if (qual < min_qual_)
274 SpectrumT master_peak_container;
275 const SpectrumT& ref_chromatogram = selectChromHelper_(transition_group, picked_chroms[chr_idx].getNativeID());
276 prepareMasterContainer_(ref_chromatogram, master_peak_container, min_left, max_right);
281 double total_intensity = 0;
double total_peak_apices = 0;
double total_xic = 0;
double total_mi = 0;
282 pickFragmentChromatograms(transition_group, picked_chroms, mrmFeature, smoothed_chroms,
283 best_left, best_right, use_consensus_,
284 total_intensity, total_xic, total_mi, total_peak_apices,
285 master_peak_container, left_edges, right_edges,
290 pickPrecursorChromatograms(transition_group,
291 picked_chroms, mrmFeature, smoothed_chroms,
292 best_left, best_right, use_consensus_,
293 total_intensity, master_peak_container, left_edges, right_edges,
296 mrmFeature.
setRT(peak_apex);
302 if (compute_total_mi_)
306 mrmFeature.
setMetaValue(
"peak_apices_sum", total_peak_apices);
324 template <
typename SpectrumT>
325 void pickApex(std::vector<SpectrumT>& picked_chroms,
326 const double best_left,
const double best_right,
const double peak_apex,
327 double &min_left,
double &max_right,
328 std::vector< double > & left_edges, std::vector< double > & right_edges)
330 for (
Size k = 0; k < picked_chroms.size(); k++)
332 double peak_apex_dist_min = std::numeric_limits<double>::max();
334 for (
Size i = 0; i < picked_chroms[k].size(); i++)
338 picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_LEFTBORDER][i],
339 picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_RIGHTBORDER][i]);
340 if (pa_tmp.
apex_pos > 1e-11 && std::fabs(pa_tmp.
apex_pos - peak_apex) < peak_apex_dist_min)
342 peak_apex_dist_min = std::fabs(pa_tmp.
apex_pos - peak_apex);
348 double l = best_left;
349 double r = best_right;
352 l = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_LEFTBORDER][min_dist];
353 r = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_RIGHTBORDER][min_dist];
354 picked_chroms[k][min_dist].setIntensity(0.0);
357 left_edges.push_back(l);
358 right_edges.push_back(r);
360 if (l < min_left) {min_left = l;}
361 if (r > max_right) {max_right = r;}
365 template <
typename SpectrumT,
typename TransitionT>
367 const std::vector<SpectrumT>& picked_chroms,
369 const std::vector<SpectrumT>& smoothed_chroms,
370 const double best_left,
const double best_right,
371 const bool use_consensus_,
372 double & total_intensity,
375 double & total_peak_apices,
376 const SpectrumT & master_peak_container,
377 const std::vector< double > & left_edges,
378 const std::vector< double > & right_edges,
385 double local_left = best_left;
386 double local_right = best_right;
392 if (!transition_group.
getTransitions()[k].isDetectingTransition())
395 "When using non-consensus peak picker, all transitions need to be detecting transitions.");
397 local_left = left_edges[k];
398 local_right = right_edges[k];
401 const SpectrumT& chromatogram = selectChromHelper_(transition_group, transition_group.
getTransitions()[k].getNativeID());
404 for (
typename SpectrumT::const_iterator it = chromatogram.begin(); it != chromatogram.end(); it++)
406 total_xic += it->getIntensity();
411 double transition_total_xic = 0;
413 for (
typename SpectrumT::const_iterator it = chromatogram.begin(); it != chromatogram.end(); it++)
415 transition_total_xic += it->getIntensity();
419 double transition_total_mi = 0;
420 if (compute_total_mi_)
422 std::vector<unsigned int> chrom_vect_id_ranked, chrom_vect_det_ranked;
423 std::vector<double> chrom_vect_id, chrom_vect_det;
424 for (
typename SpectrumT::const_iterator it = chromatogram.begin(); it != chromatogram.end(); it++)
426 chrom_vect_id.push_back(it->getIntensity());
430 int transition_total_mi_norm = 0;
435 const SpectrumT& chromatogram_det = selectChromHelper_(transition_group, transition_group.
getTransitions()[m].getNativeID());
436 chrom_vect_det.clear();
437 for (
typename SpectrumT::const_iterator it = chromatogram_det.begin(); it != chromatogram_det.end(); it++)
439 chrom_vect_det.push_back(it->getIntensity());
443 transition_total_mi_norm++;
446 if (transition_total_mi_norm > 0) { transition_total_mi /= transition_total_mi_norm; }
451 total_mi += transition_total_mi / transition_total_mi_norm;
455 SpectrumT used_chromatogram;
457 if (peak_integration_ ==
"original")
459 used_chromatogram = resampleChromatogram_(chromatogram, master_peak_container, local_left, local_right);
461 else if (peak_integration_ ==
"smoothed")
463 if (smoothed_chroms.size() <= k)
466 "Tried to calculate peak area and height without any smoothed chromatograms");
468 used_chromatogram = resampleChromatogram_(smoothed_chroms[k], master_peak_container, local_left, local_right);
473 String(
"Peak integration chromatogram ") + peak_integration_ +
" is not a valid method for MRMTransitionGroupPicker");
482 double peak_integral = pa.
area;
483 double peak_apex_int = pa.
height;
493 for (
const auto& p : used_chromatogram)
499 if (background_subtraction_ !=
"none")
501 double background{0};
502 double avg_noise_level{0};
503 if (background_subtraction_ ==
"original")
505 const double intensity_left = chromatogram.PosBegin(local_left)->getIntensity();
506 const double intensity_right = (chromatogram.PosEnd(local_right) - 1)->getIntensity();
507 const UInt n_points = std::distance(chromatogram.PosBegin(local_left), chromatogram.PosEnd(local_right));
508 avg_noise_level = (intensity_right + intensity_left) / 2;
509 background = avg_noise_level * n_points;
511 else if (background_subtraction_ ==
"exact")
514 background = pb.
area;
515 avg_noise_level = pb.
height;
517 peak_integral -= background;
518 peak_apex_int -= avg_noise_level;
519 if (peak_integral < 0) {peak_integral = 0;}
520 if (peak_apex_int < 0) {peak_apex_int = 0;}
523 f.
setMetaValue(
"noise_background_level", avg_noise_level);
526 f.
setRT(picked_chroms[chr_idx][peak_idx].getPos());
532 f.
setMZ(chromatogram.getProduct().getMZ());
533 mrmFeature.
setMZ(chromatogram.getPrecursor().getMZ());
535 if (chromatogram.metaValueExists(
"product_mz"))
537 f.
setMetaValue(
"MZ", chromatogram.getMetaValue(
"product_mz"));
538 f.
setMZ(chromatogram.getMetaValue(
"product_mz"));
541 f.
setMetaValue(
"native_id", chromatogram.getNativeID());
544 if (compute_total_mi_)
549 if (transition_group.
getTransitions()[k].isQuantifyingTransition())
551 total_intensity += peak_integral;
552 total_peak_apices += peak_apex_int;
559 if (compute_peak_shape_metrics_)
578 mrmFeature.
addFeature(f, chromatogram.getNativeID());
582 template <
typename SpectrumT,
typename TransitionT>
584 const std::vector<SpectrumT>& picked_chroms,
586 const std::vector<SpectrumT>& smoothed_chroms,
587 const double best_left,
const double best_right,
588 const bool use_consensus_,
589 double & total_intensity,
590 const SpectrumT & master_peak_container,
591 const std::vector< double > & left_edges,
592 const std::vector< double > & right_edges,
604 double local_left = best_left;
605 double local_right = best_right;
606 if (!use_consensus_ && right_edges.size() > prec_idx && left_edges.size() > prec_idx)
608 local_left = left_edges[prec_idx];
609 local_right = right_edges[prec_idx];
612 SpectrumT used_chromatogram;
614 if (peak_integration_ ==
"original")
616 used_chromatogram = resampleChromatogram_(chromatogram, master_peak_container, local_left, local_right);
619 else if (peak_integration_ ==
"smoothed" && smoothed_chroms.size() <= prec_idx)
622 "Tried to calculate peak area and height without any smoothed chromatograms for precursors");
624 else if (peak_integration_ ==
"smoothed")
626 used_chromatogram = resampleChromatogram_(smoothed_chroms[prec_idx], master_peak_container, local_left, local_right);
631 String(
"Peak integration chromatogram ") + peak_integration_ +
" is not a valid method for MRMTransitionGroupPicker");
640 double peak_integral = pa.
area;
641 double peak_apex_int = pa.
height;
649 for (
const auto& p : used_chromatogram)
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].getPos());
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].getPos() >= best_left && picked_chroms[k][i].getPos() <= 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; }
751 double left = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_LEFTBORDER][i];
752 double right = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_RIGHTBORDER][i];
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].getPos() >= best_left && picked_chroms[k][i].getPos() <= best_right)
913 if (picked_chroms[k][i].getIntensity() > max_int)
915 max_int = picked_chroms[k][i].getIntensity() > max_int;
916 l_tmp = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_LEFTBORDER][i];
917 r_tmp = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_RIGHTBORDER][i];
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].getPos() >= best_left && picked_chroms[k][i].getPos() <= best_right)
993 if (picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_ABUNDANCE][i] > max_int)
995 max_int = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_ABUNDANCE][i];
996 left = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_LEFTBORDER][i];
997 right = picked_chroms[k].getFloatDataArrays()[PeakPickerChromatogram::IDX_RIGHTBORDER][i];
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());
1034 OPENMS_LOG_DEBUG <<
" - Recalculating right peak boundaries " << mean <<
" mean / best "
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());
1051 OPENMS_LOG_DEBUG <<
" - Recalculating left peak boundaries " << mean <<
" mean / best "
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 PeakContainerT>
1083 PeakContainerT& master_peak_container,
1084 double left_boundary,
1085 double right_boundary)
1092 auto begin = ref_chromatogram.begin();
1093 while (begin != ref_chromatogram.end() && begin->getPos() < left_boundary) {begin++; }
1094 if (begin != ref_chromatogram.begin()) { begin--; }
1097 while (end != ref_chromatogram.end() && end->getPos() < right_boundary) {end++; }
1098 if (end != ref_chromatogram.end()) { end++; }
1101 master_peak_container.resize(distance(begin, end));
1102 auto it = master_peak_container.begin();
1103 for (
auto chrom_it = begin; chrom_it != end; chrom_it++, it++)
1105 it->setPos(chrom_it->getPos());
1119 template <
typename PeakContainerT>
1121 const PeakContainerT& master_peak_container,
1122 double left_boundary,
1123 double right_boundary)
1128 auto begin = chromatogram.begin();
1129 while (begin != chromatogram.end() && begin->getPos() < left_boundary) {begin++;}
1130 if (begin != chromatogram.begin()) { begin--; }
1133 while (end != chromatogram.end() && end->getPos() < right_boundary) {end++;}
1134 if (end != chromatogram.end()) { end++; }
1136 auto resampled_peak_container = master_peak_container;
1138 lresampler.
raster(begin, end, resampled_peak_container.begin(), resampled_peak_container.end());
1140 return resampled_peak_container;
#define OPENMS_LOG_DEBUG
Macro for debug information - includes file and line info.
Definition LogStream.h:558
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.
Definition ConvexHull2D.h:49
void setHullPoints(const PointArrayType &points)
accessor for the outer(!) points (no checking is performed if this is actually a convex hull)
Representation of a coordinate in D-dimensional space.
Definition DPosition.h:32
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
A method or algorithm argument contains illegal values.
Definition Exception.h:630
An LC-MS feature.
Definition Feature.h:46
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:33
void raster(PeakContainerT &container)
Applies the resampling algorithm to a container (MSSpectrum or MSChromatogram).
Definition LinearResamplerAlign.h:54
A multi-chromatogram MRM feature.
Definition MRMFeature.h:26
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:55
void findLargestPeak(const std::vector< MSChromatogram > &picked_chroms, int &chr_idx, int &peak_idx)
Find largest peak in a vector of chromatograms.
void prepareMasterContainer_(const PeakContainerT &ref_chromatogram, PeakContainerT &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 boundary_selection_method_
Which method to use for selecting peaks' boundaries.
Definition MRMTransitionGroupPicker.h:1167
const SpectrumT & selectChromHelper_(const MRMTransitionGroup< SpectrumT, TransitionT > &transition_group, const String &native_id)
Select matching precursor or fragment ion chromatogram.
Definition MRMTransitionGroupPicker.h:790
String peak_integration_
Definition MRMTransitionGroupPicker.h:1146
bool compute_total_mi_
Definition MRMTransitionGroupPicker.h:1153
String background_subtraction_
Definition MRMTransitionGroupPicker.h:1147
bool compute_peak_quality_
Definition MRMTransitionGroupPicker.h:1151
bool use_precursors_
Definition MRMTransitionGroupPicker.h:1149
PeakContainerT resampleChromatogram_(const PeakContainerT &chromatogram, const PeakContainerT &master_peak_container, double left_boundary, double right_boundary)
Resample a container at the positions indicated by the master peak container.
Definition MRMTransitionGroupPicker.h:1120
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:325
double min_peak_width_
Definition MRMTransitionGroupPicker.h:1158
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
int stop_after_feature_
Definition MRMTransitionGroupPicker.h:1156
PeakPickerChromatogram picker_
Definition MRMTransitionGroupPicker.h:1169
double recalculate_peaks_max_z_
Definition MRMTransitionGroupPicker.h:1159
PeakIntegrator pi_
Definition MRMTransitionGroupPicker.h:1170
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:1154
double resample_boundary_
Definition MRMTransitionGroupPicker.h:1160
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:200
~MRMTransitionGroupPicker() override
Destructor.
MRMTransitionGroupPicker()
Constructor.
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:1157
void pickTransitionGroup(MRMTransitionGroup< SpectrumT, TransitionT > &transition_group)
Pick a group of chromatograms belonging to the same peptide.
Definition MRMTransitionGroupPicker.h:87
MRMTransitionGroupPicker & operator=(const MRMTransitionGroupPicker &rhs)
Assignment operator is protected for algorithm.
bool use_consensus_
Definition MRMTransitionGroupPicker.h:1150
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:366
bool recalculate_peaks_
Definition MRMTransitionGroupPicker.h:1148
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:583
bool compute_peak_shape_metrics_
Definition MRMTransitionGroupPicker.h:1152
The representation of a group of transitions in a targeted proteomics experiment.
Definition MRMTransitionGroup.h:42
const String & getTransitionGroupID() const
Definition MRMTransitionGroup.h:104
const std::vector< TransitionType > & getTransitions() const
Definition MRMTransitionGroup.h:116
bool hasPrecursorChromatogram(const String &key) const
Definition MRMTransitionGroup.h:242
bool isInternallyConsistent() const
Check whether internal state is consistent, e.g. same number of chromatograms and transitions are pre...
Definition MRMTransitionGroup.h:291
ChromatogramType & getPrecursorChromatogram(const String &key)
Definition MRMTransitionGroup.h:247
bool chromatogramIdsMatch() const
Ensure that chromatogram native ids match their keys in the map.
Definition MRMTransitionGroup.h:300
bool hasTransition(const String &key) const
Definition MRMTransitionGroup.h:144
bool hasChromatogram(const String &key) const
Definition MRMTransitionGroup.h:188
const TransitionType & getTransition(const String &key)
Definition MRMTransitionGroup.h:149
void addFeature(const MRMFeature &feature)
Definition MRMTransitionGroup.h:275
ChromatogramType & getChromatogram(const String &key)
Definition MRMTransitionGroup.h:193
std::vector< ChromatogramType > & getPrecursorChromatograms()
Definition MRMTransitionGroup.h:211
std::vector< ChromatogramType > & getChromatograms()
Definition MRMTransitionGroup.h:160
The representation of a chromatogram.
Definition MSChromatogram.h:30
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:179
void setRT(CoordinateType coordinate)
Mutable access to the RT coordinate (index 0)
Definition Peak2D.h:191
IntensityType getIntensity() const
Definition Peak2D.h:143
void setIntensity(IntensityType intensity)
Sets data point intensity (height)
Definition Peak2D.h:149
Compute the area, background and shape metrics of a peak.
Definition PeakIntegrator.h:87
Int points_across_half_height
Definition PeakIntegrator.h:224
double apex_pos
Definition PeakIntegrator.h:111
ConvexHull2D::PointArrayType hull_points
Definition PeakIntegrator.h:115
double width_at_5
Definition PeakIntegrator.h:146
Int points_across_baseline
Definition PeakIntegrator.h:220
double width_at_50
Definition PeakIntegrator.h:154
double end_position_at_50
Definition PeakIntegrator.h:178
double baseline_delta_2_height
Definition PeakIntegrator.h:216
double height
Definition PeakIntegrator.h:107
double end_position_at_10
Definition PeakIntegrator.h:174
double width_at_10
Definition PeakIntegrator.h:150
double total_width
Definition PeakIntegrator.h:182
double end_position_at_5
Definition PeakIntegrator.h:170
double start_position_at_50
Definition PeakIntegrator.h:166
double tailing_factor
Definition PeakIntegrator.h:196
double slope_of_baseline
Definition PeakIntegrator.h:211
double start_position_at_10
Definition PeakIntegrator.h:162
double asymmetry_factor
Definition PeakIntegrator.h:206
double start_position_at_5
Definition PeakIntegrator.h:158
double area
Definition PeakIntegrator.h:103
Definition PeakIntegrator.h:99
Definition PeakIntegrator.h:124
Definition PeakIntegrator.h:142
The PeakPickerChromatogram finds peaks a single chromatogram.
Definition PeakPickerChromatogram.h:44
A more convenient string class.
Definition String.h:32
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:147
double mean() const
Definition StatsHelpers.h:184
int Int
Signed integer type.
Definition Types.h:72
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
#define OPENMS_PRECONDITION(condition, message)
Precondition macro.
Definition openms/include/OpenMS/CONCEPT/Macros.h:94
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
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)
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)