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 <optional>
23#include <vector>
24#include <algorithm>
25#include <iostream>
26
27
28namespace OpenMS
29{
30 class IsotopeDistribution;
31
51 class OPENMS_DLLAPI MultiplexFiltering :
52 public ProgressLogger
53 {
54public:
67 typedef std::vector<std::vector<int> > White2Original;
68
85 MultiplexFiltering(const MSExperiment& exp_centroided, const std::vector<MultiplexIsotopicPeakPattern>& patterns, int isotopes_per_peptide_min,
86 int isotopes_per_peptide_max, double intensity_cutoff, double rt_band, double mz_tolerance, bool mz_tolerance_unit,
87 double peptide_similarity, double averagine_similarity, double averagine_similarity_scaling, std::string averagine_type="peptide");
92
100
105 {
107 unsigned pattern_idx;
110 unsigned peak_idx;
113 };
114
125
140 std::vector<std::vector<BlacklistOwner>> getBlacklistOwners() const;
141
151 std::vector<BlacklistOwner> getBlacklistOwners(Size spectrum_index) const;
152
153protected:
158 {
159 size_t rt_idx;
160 size_t mz_idx;
161 int value;
162 };
163
168 {
170 int first;
174 int last;
175 };
176
185
197 int checkForSignificantPeak_(double mz, double mz_tolerance, MSExperiment::ConstIterator& it_rt, double intensity_first_peak) const;
198
216 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;
217
229 void blacklistPeak_(const MultiplexFilteredPeak& peak, unsigned pattern_idx, size_t peak_idx);
230
244 void applyBlacklistEntries_(const std::vector<BlacklistEntry>& entries, unsigned pattern_idx, size_t peak_idx);
245
255 void blacklistEntries_(const MultiplexFilteredPeak& peak, unsigned pattern_idx, std::vector<BlacklistEntry>& entries) const;
256
264 typedef std::function<std::optional<MultiplexFilteredPeak>(SignedSize, std::vector<BlacklistEntry>*)> PeakFilter;
265
282 void filterSpectrum_(size_t idx_rt, unsigned pattern_idx, const PeakFilter& filter_peak, MultiplexFilteredMSExperiment& result);
283
296
307
321
326
330 std::vector<std::vector<int> > blacklist_;
331
338 std::vector<std::vector<int>> blacklist_owner_;
339
343 std::vector<BlacklistOwnerRecord> blacklist_owner_records_;
344
348 std::vector<std::pair<unsigned, unsigned>> filtered_peaks_;
349
355 std::vector<std::vector<BlacklistEntry>> blacklist_reads_;
356
360 std::vector<std::vector<BlacklistEntry>> blacklist_writes_;
361
365 std::vector<std::optional<MultiplexFilteredPeak>> passed_;
366
373
378
382 std::vector<MultiplexIsotopicPeakPattern> patterns_;
383
388
393
398
402 double rt_band_;
403
408
413
418
423
428
433 std::string averagine_type_;
434
435 };
436
437}
438
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:53
std::function< std::optional< MultiplexFilteredPeak >(SignedSize, std::vector< BlacklistEntry > *)> PeakFilter
decides on one peak of a 'white' spectrum
Definition MultiplexFiltering.h:264
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:360
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:365
MSExperiment exp_centroided_white_
"white" centroided experimental data
Definition MultiplexFiltering.h:372
unsigned pattern_idx
index of the pattern, i.e. of its filter result in the list filter() returns
Definition MultiplexFiltering.h:107
double rt_band_
RT range used for filtering.
Definition MultiplexFiltering.h:402
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
MSExperiment exp_centroided_
centroided experimental data
Definition MultiplexFiltering.h:325
double peptide_similarity_
peptide similarity
Definition MultiplexFiltering.h:417
double averagine_similarity_
averagine similarity
Definition MultiplexFiltering.h:422
int checkForSignificantPeak_(double mz, double mz_tolerance, MSExperiment::ConstIterator &it_rt, double intensity_first_peak) const
check for significant peak
size_t isotopes_per_peptide_max_
maximum number of isotopic peaks per peptide
Definition MultiplexFiltering.h:392
size_t mz_idx
Definition MultiplexFiltering.h:160
White2Original exp_centroided_mapping_
mapping of peak indices from a 'white' experiment exp_centroided_white_ to its original experiment ex...
Definition MultiplexFiltering.h:377
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:427
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:338
std::vector< MultiplexIsotopicPeakPattern > patterns_
list of peak patterns
Definition MultiplexFiltering.h:382
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:159
std::vector< std::vector< int > > White2Original
index mapping from a 'white' experiment to its original experiment
Definition MultiplexFiltering.h:67
MSExperiment getBlacklist()
returns the blacklisted, centroided peaks
int first
the first filtered peak that reserved the peak
Definition MultiplexFiltering.h:170
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:174
double mz_tolerance_
m/z shift tolerance
Definition MultiplexFiltering.h:407
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:110
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,...
size_t isotopes_per_peptide_min_
minimum number of isotopic peaks per peptide
Definition MultiplexFiltering.h:387
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:348
int value
Definition MultiplexFiltering.h:161
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:343
bool mz_tolerance_unit_in_ppm_
unit for m/z shift tolerance (ppm - true, Da - false)
Definition MultiplexFiltering.h:412
MSExperiment & getCentroidedExperiment()
returns the intensity-filtered, centroided spectral data
double intensity_cutoff_
intensity cutoff
Definition MultiplexFiltering.h:397
int first_value
the value first left in blacklist_ (read when another filtered peak reserved the peak for the first t...
Definition MultiplexFiltering.h:172
std::vector< std::vector< int > > blacklist_
auxiliary structs for blacklisting
Definition MultiplexFiltering.h:330
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:355
int mass_trace
mass trace of the pattern the peak was reserved for (peptide * isotopes_per_peptide_max + isotope)
Definition MultiplexFiltering.h:112
std::string averagine_type_
type of averagine to use
Definition MultiplexFiltering.h:433
BlacklistWriter first
the first filtered peak that reserved the peak
Definition MultiplexFiltering.h:121
BlacklistWriter last
the last one, whose mass trace the blacklist holds
Definition MultiplexFiltering.h:123
an entry of blacklist_ (spectrum index and peak index in exp_centroided_) and a value read from or wr...
Definition MultiplexFiltering.h:158
who blacklisted a peak: the first and the last filtered peak that reserved it (the same if only one d...
Definition MultiplexFiltering.h:119
the owners of a peak of blacklist_ that more than one filtered peak reserved (indices in filtered_pea...
Definition MultiplexFiltering.h:168
a filtered peak that blacklisted a peak, and the mass trace of its pattern it reserved the peak for
Definition MultiplexFiltering.h:105
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