OpenMS
Loading...
Searching...
No Matches
MultiplexFiltering.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Lars Nilse $
6// $Authors: Lars Nilse $
7// --------------------------------------------------------------------------
8
9#pragma once
10
20
21#include <functional>
22#include <map>
23#include <optional>
24#include <string>
25#include <vector>
26#include <algorithm>
27#include <iostream>
28
29
30namespace OpenMS
31{
32 class IsotopeDistribution;
33
53 class OPENMS_DLLAPI MultiplexFiltering :
54 public ProgressLogger
55 {
56public:
69 typedef std::vector<std::vector<int> > White2Original;
70
87 MultiplexFiltering(const MSExperiment& exp_centroided, const std::vector<MultiplexIsotopicPeakPattern>& patterns, int isotopes_per_peptide_min,
88 int isotopes_per_peptide_max, double intensity_cutoff, double rt_band, double mz_tolerance, bool mz_tolerance_unit,
89 double peptide_similarity, double averagine_similarity, double averagine_similarity_scaling, std::string averagine_type="peptide");
94
102
107 {
109 unsigned pattern_idx;
112 unsigned peak_idx;
115 };
116
127
142 std::vector<std::vector<BlacklistOwner>> getBlacklistOwners() const;
143
153 std::vector<BlacklistOwner> getBlacklistOwners(Size spectrum_index) const;
154
159 {
160 unsigned deuterium = 0;
161 double enrichment = 1.0;
162 };
163
185 void setDeuteriumLabels(const std::map<std::string, DeuteriumLabel>& labels);
186
201 static double deuteriumLowerFraction(unsigned deuterium, double enrichment, const IsotopeDistribution& isotopes);
202
217 static double deuteriumAllowance(unsigned deuterium, double enrichment, const IsotopeDistribution& isotopes);
218
219protected:
224 {
225 size_t rt_idx;
226 size_t mz_idx;
227 int value;
228 };
229
234 {
236 int first;
240 int last;
241 };
242
251
264 int checkForSignificantPeak_(double mz, double mz_tolerance, MSExperiment::ConstIterator& it_rt, double intensity_first_peak,
265 double fraction = 0.3) const;
266
271 double deuteriumAllowance_(const MultiplexIsotopicPeakPattern& pattern, size_t peptide, double mz) const;
272
290 bool filterPeakPositions_(double mz, const MSExperiment::ConstIterator& it_rt_begin, const MSExperiment::ConstIterator& it_rt_band_begin, const MSExperiment::ConstIterator& it_rt_band_end, const MultiplexIsotopicPeakPattern& pattern, MultiplexFilteredPeak& peak, std::vector<BlacklistEntry>* blacklist_reads = nullptr) const;
291
303 void blacklistPeak_(const MultiplexFilteredPeak& peak, unsigned pattern_idx, size_t peak_idx);
304
318 void applyBlacklistEntries_(const std::vector<BlacklistEntry>& entries, unsigned pattern_idx, size_t peak_idx);
319
329 void blacklistEntries_(const MultiplexFilteredPeak& peak, unsigned pattern_idx, std::vector<BlacklistEntry>& entries) const;
330
338 typedef std::function<std::optional<MultiplexFilteredPeak>(SignedSize, std::vector<BlacklistEntry>*)> PeakFilter;
339
356 void filterSpectrum_(size_t idx_rt, unsigned pattern_idx, const PeakFilter& filter_peak, MultiplexFilteredMSExperiment& result);
357
370
381
395
400
404 std::vector<std::vector<int> > blacklist_;
405
412 std::vector<std::vector<int>> blacklist_owner_;
413
417 std::vector<BlacklistOwnerRecord> blacklist_owner_records_;
418
422 std::vector<std::pair<unsigned, unsigned>> filtered_peaks_;
423
429 std::vector<std::vector<BlacklistEntry>> blacklist_reads_;
430
434 std::vector<std::vector<BlacklistEntry>> blacklist_writes_;
435
439 std::vector<std::optional<MultiplexFilteredPeak>> passed_;
440
447
452
456 std::vector<MultiplexIsotopicPeakPattern> patterns_;
457
462
467
472
476 double rt_band_;
477
482
487
492
497
502
507 std::string averagine_type_;
508
513 std::vector<std::vector<DeuteriumLabel>> deuterium_;
514
515 };
516
517}
518
Definition IsotopeDistribution.h:40
In-Memory representation of a mass spectrometry run.
Definition MSExperiment.h:49
std::vector< SpectrumType >::const_iterator ConstIterator
Non-mutable iterator.
Definition MSExperiment.h:86
data structure storing all peaks (and optionally their raw data points) of an experiment correspondin...
Definition MultiplexFilteredMSExperiment.h:27
data structure storing a single peak that passed all filters
Definition MultiplexFilteredPeak.h:44
base class for filtering centroided and profile data for peak patterns
Definition MultiplexFiltering.h:55
std::function< std::optional< MultiplexFilteredPeak >(SignedSize, std::vector< BlacklistEntry > *)> PeakFilter
decides on one peak of a 'white' spectrum
Definition MultiplexFiltering.h:338
std::vector< std::vector< BlacklistEntry > > blacklist_writes_
for each peak of the spectrum being filtered that passes, the entries of blacklist_ it sets (see filt...
Definition MultiplexFiltering.h:434
bool filterPeptideCorrelation_(const MultiplexIsotopicPeakPattern &pattern, const MultiplexFilteredPeak &peak) const
check if corresponding satellite peaks of different peptides show a good correlation
std::vector< std::optional< MultiplexFilteredPeak > > passed_
the decision of filterSpectrum_() on each peak of the spectrum (reused, as blacklist_reads_)
Definition MultiplexFiltering.h:439
MSExperiment exp_centroided_white_
"white" centroided experimental data
Definition MultiplexFiltering.h:446
unsigned pattern_idx
index of the pattern, i.e. of its filter result in the list filter() returns
Definition MultiplexFiltering.h:109
double rt_band_
RT range used for filtering.
Definition MultiplexFiltering.h:476
void applyBlacklistEntries_(const std::vector< BlacklistEntry > &entries, unsigned pattern_idx, size_t peak_idx)
write entries to blacklist_, with the filtered peak (pattern_idx, peak_idx) as their owner
double deuteriumAllowance_(const MultiplexIsotopicPeakPattern &pattern, size_t peptide, double mz) const
deuteriumAllowance() for peptide peptide of pattern (monoisotopic m/z mz), with its deuterium labels ...
MSExperiment exp_centroided_
centroided experimental data
Definition MultiplexFiltering.h:399
double peptide_similarity_
peptide similarity
Definition MultiplexFiltering.h:491
double averagine_similarity_
averagine similarity
Definition MultiplexFiltering.h:496
std::vector< std::vector< DeuteriumLabel > > deuterium_
the deuterium labels of each peptide of each mass shift pattern (index: MultiplexIsotopicPeakPattern:...
Definition MultiplexFiltering.h:513
size_t isotopes_per_peptide_max_
maximum number of isotopic peaks per peptide
Definition MultiplexFiltering.h:466
size_t mz_idx
Definition MultiplexFiltering.h:226
static double deuteriumAllowance(unsigned deuterium, double enrichment, const IsotopeDistribution &isotopes)
the part of the peak one isotope below a deuterium-labelled peptide that the check for another envelo...
White2Original exp_centroided_mapping_
mapping of peak indices from a 'white' experiment exp_centroided_white_ to its original experiment ex...
Definition MultiplexFiltering.h:451
void blacklistPeak_(const MultiplexFilteredPeak &peak, unsigned pattern_idx, size_t peak_idx)
blacklist this peak
double averagine_similarity_scaling_
averagine similarity scaling
Definition MultiplexFiltering.h:501
bool filterAveragineModel_(const MultiplexIsotopicPeakPattern &pattern, const MultiplexFilteredPeak &peak) const
check if the satellite peaks conform with the averagine model
std::vector< std::vector< int > > blacklist_owner_
for every peak of blacklist_, who reserved it
Definition MultiplexFiltering.h:412
std::vector< MultiplexIsotopicPeakPattern > patterns_
list of peak patterns
Definition MultiplexFiltering.h:456
void blacklistEntries_(const MultiplexFilteredPeak &peak, unsigned pattern_idx, std::vector< BlacklistEntry > &entries) const
the entries of blacklist_ that blacklistPeak_() sets, with their new values, in the order it sets the...
size_t rt_idx
Definition MultiplexFiltering.h:225
std::vector< std::vector< int > > White2Original
index mapping from a 'white' experiment to its original experiment
Definition MultiplexFiltering.h:69
MSExperiment getBlacklist()
returns the blacklisted, centroided peaks
int first
the first filtered peak that reserved the peak
Definition MultiplexFiltering.h:236
MultiplexFiltering(const MSExperiment &exp_centroided, const std::vector< MultiplexIsotopicPeakPattern > &patterns, int isotopes_per_peptide_min, int isotopes_per_peptide_max, double intensity_cutoff, double rt_band, double mz_tolerance, bool mz_tolerance_unit, double peptide_similarity, double averagine_similarity, double averagine_similarity_scaling, std::string averagine_type="peptide")
constructor
int last
the last filtered peak that reserved the peak, whose value blacklist_ holds
Definition MultiplexFiltering.h:240
double mz_tolerance_
m/z shift tolerance
Definition MultiplexFiltering.h:481
void filterSpectrum_(size_t idx_rt, unsigned pattern_idx, const PeakFilter &filter_peak, MultiplexFilteredMSExperiment &result)
filter all peaks of one 'white' spectrum, add the ones that pass to result and blacklist them
unsigned peak_idx
Definition MultiplexFiltering.h:112
const IsotopeDistribution & averagineDistribution_(double mass) const
averagine isotope distribution (of the type averagine_type_, with isotopes_per_peptide_max_ isotopes)...
bool filterPeakPositions_(double mz, const MSExperiment::ConstIterator &it_rt_begin, const MSExperiment::ConstIterator &it_rt_band_begin, const MSExperiment::ConstIterator &it_rt_band_end, const MultiplexIsotopicPeakPattern &pattern, MultiplexFilteredPeak &peak, std::vector< BlacklistEntry > *blacklist_reads=nullptr) const
check if there are enough peaks in the RT band to form the pattern
std::vector< std::vector< BlacklistOwner > > getBlacklistOwners() const
the owners of the blacklisted peaks, aligned with getBlacklist(): one list per spectrum,...
int checkForSignificantPeak_(double mz, double mz_tolerance, MSExperiment::ConstIterator &it_rt, double intensity_first_peak, double fraction=0.3) const
check for significant peak
size_t isotopes_per_peptide_min_
minimum number of isotopic peaks per peptide
Definition MultiplexFiltering.h:461
std::vector< BlacklistOwner > getBlacklistOwners(Size spectrum_index) const
the owners of the blacklisted peaks of one spectrum, aligned with that spectrum of getBlacklist()
std::vector< std::pair< unsigned, unsigned > > filtered_peaks_
every filtered peak that passed, in the order they passed: index of its pattern and its index in the ...
Definition MultiplexFiltering.h:422
int value
Definition MultiplexFiltering.h:227
std::vector< BlacklistOwnerRecord > blacklist_owner_records_
the first and the last owner of every peak reserved by more than one filtered peak (see blacklist_own...
Definition MultiplexFiltering.h:417
bool mz_tolerance_unit_in_ppm_
unit for m/z shift tolerance (ppm - true, Da - false)
Definition MultiplexFiltering.h:486
MSExperiment & getCentroidedExperiment()
returns the intensity-filtered, centroided spectral data
static double deuteriumLowerFraction(unsigned deuterium, double enrichment, const IsotopeDistribution &isotopes)
the peak one isotope below a deuterium-labelled peptide that its own label isotopologues produce,...
double intensity_cutoff_
intensity cutoff
Definition MultiplexFiltering.h:471
int first_value
the value first left in blacklist_ (read when another filtered peak reserved the peak for the first t...
Definition MultiplexFiltering.h:238
std::vector< std::vector< int > > blacklist_
auxiliary structs for blacklisting
Definition MultiplexFiltering.h:404
void setDeuteriumLabels(const std::map< std::string, DeuteriumLabel > &labels)
take the lower isotopologue of deuterium labels into account where a peak one isotope below a peptide...
void updateWhiteMSExperiment_()
construct an MS experiment from exp_centroided_ containing peaks which have not been previously black...
std::vector< std::vector< BlacklistEntry > > blacklist_reads_
for each peak of the spectrum being filtered, the entries of blacklist_ its decision read (see filter...
Definition MultiplexFiltering.h:429
int mass_trace
mass trace of the pattern the peak was reserved for (peptide * isotopes_per_peptide_max + isotope)
Definition MultiplexFiltering.h:114
std::string averagine_type_
type of averagine to use
Definition MultiplexFiltering.h:507
BlacklistWriter first
the first filtered peak that reserved the peak
Definition MultiplexFiltering.h:123
BlacklistWriter last
the last one, whose mass trace the blacklist holds
Definition MultiplexFiltering.h:125
an entry of blacklist_ (spectrum index and peak index in exp_centroided_) and a value read from or wr...
Definition MultiplexFiltering.h:224
who blacklisted a peak: the first and the last filtered peak that reserved it (the same if only one d...
Definition MultiplexFiltering.h:121
the owners of a peak of blacklist_ that more than one filtered peak reserved (indices in filtered_pea...
Definition MultiplexFiltering.h:234
a filtered peak that blacklisted a peak, and the mass trace of its pattern it reserved the peak for
Definition MultiplexFiltering.h:107
a deuterium label (setDeuteriumLabels()), or the deuterium labels of a peptide
Definition MultiplexFiltering.h:159
data structure for pattern of isotopic peaks
Definition MultiplexIsotopicPeakPattern.h:29
Base class for all classes that want to report their progress.
Definition ProgressLogger.h:28
ptrdiff_t SignedSize
Signed Size type e.g. used as pointer difference.
Definition Types.h:104
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19