OpenMS  2.8.0
MRMFeatureFilter.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Douglas McCloskey, Pasquale Domenico Colaianni $
32 // $Authors: Douglas McCloskey, Pasquale Domenico Colaianni $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
39 
41 #include <OpenMS/KERNEL/Feature.h>
43 
46 
47 namespace OpenMS
48 {
49  class AbsoluteQuantitationMethod;
50 
59  class OPENMS_DLLAPI MRMFeatureFilter :
60  public DefaultParamHandler
61  {
62 
63 public:
64 
68 
70  ~MRMFeatureFilter() override;
72 
78  void getDefaultParameters(Param& params) const;
79 
81  void updateMembers_() override;
82 
91  void FilterFeatureMap(FeatureMap& features, const MRMFeatureQC& filter_criteria,
92  const TargetedExperiment& transitions);
93 
106  void FilterFeatureMapPercRSD(FeatureMap& features, const MRMFeatureQC& filter_criteria, const MRMFeatureQC& filter_values);
107 
121  void FilterFeatureMapBackgroundInterference(FeatureMap& features, const MRMFeatureQC& filter_criteria, const MRMFeatureQC& filter_values);
122 
135  void EstimateDefaultMRMFeatureQCValues(const std::vector<FeatureMap>& samples, MRMFeatureQC& filter_template, const TargetedExperiment& transitions, const bool& init_template_values) const;
136 
145  void TransferLLOQAndULOQToCalculatedConcentrationBounds(const std::vector<AbsoluteQuantitationMethod>& quantitation_method, MRMFeatureQC& filter_template);
146 
157  void EstimatePercRSD(const std::vector<FeatureMap>& samples, MRMFeatureQC& filter_template, const TargetedExperiment& transitions) const;
158 
169  void EstimateBackgroundInterferences(const std::vector<FeatureMap>& samples, MRMFeatureQC& filter_template, const TargetedExperiment& transitions) const;
170 
181  double calculateIonRatio(const Feature& component_1, const Feature& component_2, const String& feature_name) const;
182 
191  double calculateRTDifference(Feature& component_1, Feature& component_2) const;
192 
201  double calculateResolution(Feature& component_1, Feature& component_2) const;
202 
215  const Feature& component,
216  const String& meta_value_key,
217  const double& meta_value_l,
218  const double& meta_value_u,
219  bool& key_exists
220  ) const;
221 
232  const Feature& component,
233  const String& meta_value_key,
234  double& meta_value_l,
235  double& meta_value_u,
236  bool& key_exists
237  ) const;
238 
249  const Feature& component,
250  const String& meta_value_key,
251  double& meta_value_l,
252  double& meta_value_u,
253  bool& key_exists
254  ) const;
255 
266  const Feature& component,
267  const String& meta_value_key,
268  double& meta_value_l,
269  double& meta_value_u,
270  bool& key_exists
271  ) const;
272 
281  std::map<String,int> countLabelsAndTransitionTypes(const Feature& component_group,
282  const TargetedExperiment& transitions) const;
283 
291  StringList getUniqueSorted(const StringList& messages) const;
292 
301  void accumulateFilterValues(std::vector<MRMFeatureQC>& filter_values, const std::vector<FeatureMap>& samples, const MRMFeatureQC& filter_template, const TargetedExperiment& transitions) const;
302 
309  void zeroFilterValues(MRMFeatureQC& filter_zeros, const MRMFeatureQC& filter_template) const;
310 
318  void calculateFilterValuesMean(MRMFeatureQC& filter_mean, const std::vector<MRMFeatureQC>& filter_values, const MRMFeatureQC& filter_template) const;
319 
328  void calculateFilterValuesVar(MRMFeatureQC& filter_var, const std::vector<MRMFeatureQC>& filter_values, const MRMFeatureQC& filter_mean, const MRMFeatureQC& filter_template) const;
329 
337  void calculateFilterValuesPercRSD(MRMFeatureQC& filter_rsd, const MRMFeatureQC& filter_mean, const MRMFeatureQC& filter_var) const;
338 
340  template <typename T>
341  bool checkRange(const T& value, const T& value_l, const T& value_u) const;
342 
344  template <typename T>
345  void updateRange(const T& value, T& value_l, T& value_u) const;
346 
348  template <typename T>
349  void setRange(const T& value, T& value_l, T& value_u) const;
350 
352  template <typename T>
353  void initRange(const T& value, T& value_l, T& value_u) const;
354 
355 private:
356  // Members
359  };
360 }
361 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
A container for features.
Definition: FeatureMap.h:106
An LC-MS feature.
Definition: Feature.h:72
The MRMFeatureFilter either flags components and/or transitions that do not pass the QC criteria or f...
Definition: MRMFeatureFilter.h:61
void updateRange(const T &value, T &value_l, T &value_u) const
Updates value_l and value_u according to whether value is greater than value_u or less than value_l.
void setMetaValue(const Feature &component, const String &meta_value_key, double &meta_value_l, double &meta_value_u, bool &key_exists) const
Uses the supplied value to set the metaValue ranges.
void calculateFilterValuesMean(MRMFeatureQC &filter_mean, const std::vector< MRMFeatureQC > &filter_values, const MRMFeatureQC &filter_template) const
Calculate the mean of each MRMFeatureQC parameter from a list of MRMFeatureQC classes.
void FilterFeatureMapPercRSD(FeatureMap &features, const MRMFeatureQC &filter_criteria, const MRMFeatureQC &filter_values)
Flags or filters features and subordinates in a FeatureMap based on a user defined set of filter valu...
std::map< String, int > countLabelsAndTransitionTypes(const Feature &component_group, const TargetedExperiment &transitions) const
Count the number of heavy/light labels and quantifying/detecting/identifying transitions.
void TransferLLOQAndULOQToCalculatedConcentrationBounds(const std::vector< AbsoluteQuantitationMethod > &quantitation_method, MRMFeatureQC &filter_template)
Transfer the lower and upper bound values for the calculated concentrations based off of the Absolute...
String flag_or_filter_
flag or filter (i.e., remove) features that do not pass the QC
Definition: MRMFeatureFilter.h:358
StringList getUniqueSorted(const StringList &messages) const
Sorts the messages and returns a copy without duplicates.
void FilterFeatureMapBackgroundInterference(FeatureMap &features, const MRMFeatureQC &filter_criteria, const MRMFeatureQC &filter_values)
Flags or filters features and subordinates in a FeatureMap based on a user defined set of filter valu...
double calculateRTDifference(Feature &component_1, Feature &component_2) const
Calculates the retention time difference between two features.
void zeroFilterValues(MRMFeatureQC &filter_zeros, const MRMFeatureQC &filter_template) const
Set all members in MRMFeatureQC to zero.
void initRange(const T &value, T &value_l, T &value_u) const
Sets value_l and value_u to value.
void EstimateDefaultMRMFeatureQCValues(const std::vector< FeatureMap > &samples, MRMFeatureQC &filter_template, const TargetedExperiment &transitions, const bool &init_template_values) const
Estimate the lower and upper bound values for the MRMFeatureQC class based on a user supplied templat...
bool checkMetaValue(const Feature &component, const String &meta_value_key, const double &meta_value_l, const double &meta_value_u, bool &key_exists) const
Checks if the metaValue is within the user specified range.
double calculateResolution(Feature &component_1, Feature &component_2) const
Calculates the resolution between two features.
void EstimateBackgroundInterferences(const std::vector< FeatureMap > &samples, MRMFeatureQC &filter_template, const TargetedExperiment &transitions) const
Estimate the background interference level based on the average values from Blank samples....
void FilterFeatureMap(FeatureMap &features, const MRMFeatureQC &filter_criteria, const TargetedExperiment &transitions)
Flags or filters features and subordinates in a FeatureMap.
void updateMembers_() override
Synchronize members with param class.
double calculateIonRatio(const Feature &component_1, const Feature &component_2, const String &feature_name) const
Calculates the ion ratio between two transitions.
void initMetaValue(const Feature &component, const String &meta_value_key, double &meta_value_l, double &meta_value_u, bool &key_exists) const
Uses the supplied value to initialize the metaValue ranges to the same value.
void accumulateFilterValues(std::vector< MRMFeatureQC > &filter_values, const std::vector< FeatureMap > &samples, const MRMFeatureQC &filter_template, const TargetedExperiment &transitions) const
Accumulate feature values from a list of FeatureMaps.
bool checkRange(const T &value, const T &value_l, const T &value_u) const
Checks that the range of value is bracketed by value_l and value_u.
void EstimatePercRSD(const std::vector< FeatureMap > &samples, MRMFeatureQC &filter_template, const TargetedExperiment &transitions) const
Estimate the feature variability as measured by PercentRSD from multiple pooled QC samples or replica...
void setRange(const T &value, T &value_l, T &value_u) const
Sets value_l and value_u to bracket the range 0 to value or value to 0 depending on if value is >0.
~MRMFeatureFilter() override
Destructor.
void getDefaultParameters(Param &params) const
Get the class' default parameters.
void updateMetaValue(const Feature &component, const String &meta_value_key, double &meta_value_l, double &meta_value_u, bool &key_exists) const
Updates the metaValue ranges based on the value given.
void calculateFilterValuesPercRSD(MRMFeatureQC &filter_rsd, const MRMFeatureQC &filter_mean, const MRMFeatureQC &filter_var) const
Calculate the relative standard deviation (PercentRSD) of each MRMFeatureQC parameter from pre-comput...
void calculateFilterValuesVar(MRMFeatureQC &filter_var, const std::vector< MRMFeatureQC > &filter_values, const MRMFeatureQC &filter_mean, const MRMFeatureQC &filter_template) const
Calculate the var of each MRMFeatureQC parameter from a list of MRMFeatureQC classes.
The MRMFeatureQC is a class to handle the parameters and options for MRMFeatureFilter.
Definition: MRMFeatureQC.h:59
Management and storage of parameters / INI files.
Definition: Param.h:70
A more convenient string class.
Definition: String.h:60
A description of a targeted experiment containing precursor and production ions.
Definition: TargetedExperiment.h:65
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47