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{
49 class OPENMS_DLLAPI MultiplexFiltering :
50 public ProgressLogger
51 {
52public:
64 typedef std::vector<std::map<int, int> > White2Original;
65
82 MultiplexFiltering(const MSExperiment& exp_centroided, const std::vector<MultiplexIsotopicPeakPattern>& patterns, int isotopes_per_peptide_min,
83 int isotopes_per_peptide_max, double intensity_cutoff, double rt_band, double mz_tolerance, bool mz_tolerance_unit,
84 double peptide_similarity, double averagine_similarity, double averagine_similarity_scaling, std::string averagine_type="peptide");
89
97
102 {
104 unsigned pattern_idx;
107 unsigned peak_idx;
110 };
111
122
137 std::vector<std::vector<BlacklistOwner>> getBlacklistOwners() const;
138
148 std::vector<BlacklistOwner> getBlacklistOwners(Size spectrum_index) const;
149
150protected:
155 {
156 size_t rt_idx;
157 size_t mz_idx;
158 int value;
159 };
160
165 {
167 int first;
171 int last;
172 };
173
182
193 int checkForSignificantPeak_(double mz, double mz_tolerance, MSExperiment::ConstIterator& it_rt, double intensity_first_peak) const;
194
211 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;
212
224 void blacklistPeak_(const MultiplexFilteredPeak& peak, unsigned pattern_idx, size_t peak_idx);
225
239 void applyBlacklistEntries_(const std::vector<BlacklistEntry>& entries, unsigned pattern_idx, size_t peak_idx);
240
250 void blacklistEntries_(const MultiplexFilteredPeak& peak, unsigned pattern_idx, std::vector<BlacklistEntry>& entries) const;
251
259 typedef std::function<std::optional<MultiplexFilteredPeak>(SignedSize, std::vector<BlacklistEntry>*)> PeakFilter;
260
277 void filterSpectrum_(size_t idx_rt, unsigned pattern_idx, const PeakFilter& filter_peak, MultiplexFilteredMSExperiment& result);
278
291
305
310
314 std::vector<std::vector<int> > blacklist_;
315
322 std::vector<std::vector<int>> blacklist_owner_;
323
327 std::vector<BlacklistOwnerRecord> blacklist_owner_records_;
328
332 std::vector<std::pair<unsigned, unsigned>> filtered_peaks_;
333
339 std::vector<std::vector<BlacklistEntry>> blacklist_reads_;
340
344 std::vector<std::vector<BlacklistEntry>> blacklist_writes_;
345
352
357
361 std::vector<MultiplexIsotopicPeakPattern> patterns_;
362
367
372
377
381 double rt_band_;
382
387
392
397
402
407
412 std::string averagine_type_;
413
414 };
415
416}
417
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:51
std::function< std::optional< MultiplexFilteredPeak >(SignedSize, std::vector< BlacklistEntry > *)> PeakFilter
decides on one peak of a 'white' spectrum
Definition MultiplexFiltering.h:259
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:344
bool filterPeptideCorrelation_(const MultiplexIsotopicPeakPattern &pattern, const MultiplexFilteredPeak &peak) const
check if corresponding satellite peaks of different peptides show a good correlation
MSExperiment exp_centroided_white_
"white" centroided experimental data
Definition MultiplexFiltering.h:351
unsigned pattern_idx
index of the pattern, i.e. of its filter result in the list filter() returns
Definition MultiplexFiltering.h:104
double rt_band_
RT range used for filtering.
Definition MultiplexFiltering.h:381
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:309
double peptide_similarity_
peptide similarity
Definition MultiplexFiltering.h:396
double averagine_similarity_
averagine similarity
Definition MultiplexFiltering.h:401
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:371
size_t mz_idx
Definition MultiplexFiltering.h:157
White2Original exp_centroided_mapping_
mapping of peak indices from a 'white' experiment exp_centroided_white_ to its original experiment ex...
Definition MultiplexFiltering.h:356
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:406
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:322
std::vector< MultiplexIsotopicPeakPattern > patterns_
list of peak patterns
Definition MultiplexFiltering.h:361
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:156
MSExperiment getBlacklist()
returns the blacklisted, centroided peaks
int first
the first filtered peak that reserved the peak
Definition MultiplexFiltering.h:167
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:171
std::vector< std::map< int, int > > White2Original
index mapping from a 'white' experiment to its original experiment
Definition MultiplexFiltering.h:64
double mz_tolerance_
m/z shift tolerance
Definition MultiplexFiltering.h:386
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:107
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:366
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:332
int value
Definition MultiplexFiltering.h:158
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:327
bool mz_tolerance_unit_in_ppm_
unit for m/z shift tolerance (ppm - true, Da - false)
Definition MultiplexFiltering.h:391
MSExperiment & getCentroidedExperiment()
returns the intensity-filtered, centroided spectral data
double intensity_cutoff_
intensity cutoff
Definition MultiplexFiltering.h:376
int first_value
the value first left in blacklist_ (read when another filtered peak reserved the peak for the first t...
Definition MultiplexFiltering.h:169
std::vector< std::vector< int > > blacklist_
auxiliary structs for blacklisting
Definition MultiplexFiltering.h:314
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:339
int mass_trace
mass trace of the pattern the peak was reserved for (peptide * isotopes_per_peptide_max + isotope)
Definition MultiplexFiltering.h:109
std::string averagine_type_
type of averagine to use
Definition MultiplexFiltering.h:412
BlacklistWriter first
the first filtered peak that reserved the peak
Definition MultiplexFiltering.h:118
BlacklistWriter last
the last one, whose mass trace the blacklist holds
Definition MultiplexFiltering.h:120
an entry of blacklist_ (spectrum index and peak index in exp_centroided_) and a value read from or wr...
Definition MultiplexFiltering.h:155
who blacklisted a peak: the first and the last filtered peak that reserved it (the same if only one d...
Definition MultiplexFiltering.h:116
the owners of a peak of blacklist_ that more than one filtered peak reserved (indices in filtered_pea...
Definition MultiplexFiltering.h:165
a filtered peak that blacklisted a peak, and the mass trace of its pattern it reserved the peak for
Definition MultiplexFiltering.h:102
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