OpenMS  2.7.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 
40 
42 #include <OpenMS/KERNEL/Feature.h>
44 #include <OpenMS/FORMAT/QcMLFile.h>
45 
49 
50 namespace OpenMS
51 {
52  class AbsoluteQuantitationMethod;
53 
62  class OPENMS_DLLAPI MRMFeatureFilter :
63  public DefaultParamHandler
64  {
65 
66 public:
67 
71 
73  ~MRMFeatureFilter() override;
75 
81  void getDefaultParameters(Param& params) const;
82 
84  void updateMembers_() override;
85 
94  void FilterFeatureMap(FeatureMap& features, const MRMFeatureQC& filter_criteria,
95  const TargetedExperiment& transitions);
96 
109  void FilterFeatureMapPercRSD(FeatureMap& features, const MRMFeatureQC& filter_criteria, const MRMFeatureQC& filter_values);
110 
124  void FilterFeatureMapBackgroundInterference(FeatureMap& features, const MRMFeatureQC& filter_criteria, const MRMFeatureQC& filter_values);
125 
138  void EstimateDefaultMRMFeatureQCValues(const std::vector<FeatureMap>& samples, MRMFeatureQC& filter_template, const TargetedExperiment& transitions, const bool& init_template_values);
139 
148  void TransferLLOQAndULOQToCalculatedConcentrationBounds(const std::vector<AbsoluteQuantitationMethod>& quantitation_method, MRMFeatureQC& filter_template);
149 
160  void EstimatePercRSD(const std::vector<FeatureMap>& samples, MRMFeatureQC& filter_template, const TargetedExperiment& transitions);
161 
172  void EstimateBackgroundInterferences(const std::vector<FeatureMap>& samples, MRMFeatureQC& filter_template, const TargetedExperiment& transitions);
173 
184  double calculateIonRatio(const Feature& component_1, const Feature& component_2, const String& feature_name) const;
185 
194  double calculateRTDifference(Feature& component_1, Feature& component_2) const;
195 
204  double calculateResolution(Feature& component_1, Feature& component_2) const;
205 
218  const Feature& component,
219  const String& meta_value_key,
220  const double& meta_value_l,
221  const double& meta_value_u,
222  bool& key_exists
223  ) const;
224 
235  const Feature& component,
236  const String& meta_value_key,
237  double& meta_value_l,
238  double& meta_value_u,
239  bool& key_exists
240  ) const;
241 
252  const Feature& component,
253  const String& meta_value_key,
254  double& meta_value_l,
255  double& meta_value_u,
256  bool& key_exists
257  ) const;
258 
269  const Feature& component,
270  const String& meta_value_key,
271  double& meta_value_l,
272  double& meta_value_u,
273  bool& key_exists
274  ) const;
275 
284  std::map<String,int> countLabelsAndTransitionTypes(const Feature& component_group,
285  const TargetedExperiment& transitions) const;
286 
294  StringList getUniqueSorted(const StringList& messages) const;
295 
304  void accumulateFilterValues(std::vector<MRMFeatureQC>& filter_values, const std::vector<FeatureMap>& samples, const MRMFeatureQC& filter_template, const TargetedExperiment& transitions) const;
305 
312  void zeroFilterValues(MRMFeatureQC& filter_zeros, const MRMFeatureQC& filter_template) const;
313 
321  void calculateFilterValuesMean(MRMFeatureQC& filter_mean, const std::vector<MRMFeatureQC>& filter_values, const MRMFeatureQC& filter_template) const;
322 
331  void calculateFilterValuesVar(MRMFeatureQC& filter_var, const std::vector<MRMFeatureQC>& filter_values, const MRMFeatureQC& filter_mean, const MRMFeatureQC& filter_template) const;
332 
340  void calculateFilterValuesPercRSD(MRMFeatureQC& filter_rsd, const MRMFeatureQC& filter_mean, const MRMFeatureQC& filter_var) const;
341 
343  template <typename T>
344  bool checkRange(const T& value, const T& value_l, const T& value_u) const;
345 
347  template <typename T>
348  void updateRange(const T& value, T& value_l, T& value_u) const;
349 
351  template <typename T>
352  void setRange(const T& value, T& value_l, T& value_u) const;
353 
355  template <typename T>
356  void initRange(const T& value, T& value_l, T& value_u) const;
357 
358 private:
359  // Members
362  };
363 }
364 
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
A container for features.
Definition: FeatureMap.h:105
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:64
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 EstimatePercRSD(const std::vector< FeatureMap > &samples, MRMFeatureQC &filter_template, const TargetedExperiment &transitions)
Estimate the feature variability as measured by PercentRSD from multiple pooled QC samples or replica...
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:361
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 EstimateBackgroundInterferences(const std::vector< FeatureMap > &samples, MRMFeatureQC &filter_template, const TargetedExperiment &transitions)
Estimate the background interference level based on the average values from Blank samples....
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 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.
void EstimateDefaultMRMFeatureQCValues(const std::vector< FeatureMap > &samples, MRMFeatureQC &filter_template, const TargetedExperiment &transitions, const bool &init_template_values)
Estimate the lower and upper bound values for the MRMFeatureQC class based on a user supplied templat...
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 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:61
Management and storage of parameters / INI files.
Definition: Param.h:70
A more convenient string class.
Definition: String.h:61
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