| OpenMS 2.5.0

QTClusterFinder.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-2020.
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: Hendrik Weisser $
32 // $Authors: Steffen Sass, Hendrik Weisser $
33 // --------------------------------------------------------------------------
34
35 #pragma once
36
37 #include <OpenMS/ANALYSIS/MAPMATCHING/BaseGroupFinder.h>
38 #include <OpenMS/CONCEPT/ProgressLogger.h>
39 #include <OpenMS/COMPARISON/CLUSTERING/HashGrid.h>
40 #include <OpenMS/DATASTRUCTURES/GridFeature.h>
41 #include <OpenMS/DATASTRUCTURES/QTCluster.h>
42 #include <OpenMS/ANALYSIS/MAPMATCHING/FeatureDistance.h>
43
44 #include <boost/unordered_map.hpp>
45
46 #include <list>
47 #include <vector>
48 #include <set>
49 #include <utility> // for pair<>
50
51 namespace OpenMS
52 {
53
103 class OPENMS_DLLAPI QTClusterFinder :
104 public BaseGroupFinder
105 {
106 private:
107
109 typedef OpenMSBoost::unordered_map<
110 std::pair<OpenMS::GridFeature*, OpenMS::GridFeature*>,
111 double> PairDistances;
112
114 typedef OpenMSBoost::unordered_map<
115 OpenMS::GridFeature*, std::vector<QTCluster*> > ElementMapping;
116
117 typedef HashGrid<OpenMS::GridFeature*> Grid;
118
120 Size num_maps_;
121
123 bool use_IDs_;
124
126 double max_diff_rt_;
127
129 double max_diff_mz_;
130
132 int nr_partitions_;
133
135 FeatureDistance feature_distance_;
136
138 std::set<OpenMS::GridFeature*> already_used_;
139
143 double getDistance_(const OpenMS::GridFeature* left, const
144 OpenMS::GridFeature* right);
145
147 void setParameters_(double max_intensity, double max_mz);
148
150 void makeConsensusFeature_(std::list<QTCluster>& clustering,
151 ConsensusFeature& feature,
152 ElementMapping& element_mapping, Grid&);
153
155 void computeClustering_(Grid& grid, std::list<QTCluster>& clustering);
156
158 template <typename MapType>
159 void run_(const std::vector<MapType>& input_maps, ConsensusMap& result_map);
160
162 template <typename MapType>
163 void run_internal_(const std::vector<MapType>& input_maps,
164 ConsensusMap& result_map, bool do_progress);
165
167 void addClusterElements_(int x, int y, const Grid& grid, QTCluster& cluster,
168 const OpenMS::GridFeature* center_feature);
169
170 protected:
171
172 enum
173 {
174 RT = Peak2D::RT,
175 MZ = Peak2D::MZ
176 };
177
178 public:
179
181 QTClusterFinder();
182
184 ~QTClusterFinder() override;
185
187 static const String getProductName()
188 {
189 return "qt";
190 }
191
199 void run(const std::vector<ConsensusMap>& input_maps,
200 ConsensusMap& result_map) override;
201
209 void run(const std::vector<FeatureMap>& input_maps,
210 ConsensusMap& result_map);
211
213 static BaseGroupFinder* create()
214 {
215 return new QTClusterFinder();
216 }
217 };
218 } // namespace OpenMS
219
OpenMS::QTClusterFinder::PairDistances
OpenMSBoost::unordered_map< std::pair< OpenMS::GridFeature *, OpenMS::GridFeature * >, double > PairDistances
Distances between pairs of grid features.
Definition: QTClusterFinder.h:111
OpenMS::BaseGroupFinder
The base class of all element group finding algorithms.
Definition: BaseGroupFinder.h:61
BaseGroupFinder.h
OpenMS::String
A more convenient string class.
Definition: String.h:58
OpenMS::QTClusterFinder::max_diff_mz_
double max_diff_mz_
Maximum m/z difference.
Definition: QTClusterFinder.h:129
OpenMS::QTClusterFinder::Grid
HashGrid< OpenMS::GridFeature * > Grid
Definition: QTClusterFinder.h:117
HashGrid.h
OpenMS::FeatureDistance
A functor class for the calculation of distances between features or consensus features.
Definition: FeatureDistance.h:89
OpenMS::QTClusterFinder::max_diff_rt_
double max_diff_rt_
Maximum RT difference.
Definition: QTClusterFinder.h:126
OpenMS::Peak2D::RT
Retention time dimension id (0 if used as a const int)
Definition: Peak2D.h:75
OpenMS::GridFeature
Representation of a feature in a hash grid.
Definition: GridFeature.h:52
OpenMS::QTCluster
A representation of a QT cluster used for feature grouping.
Definition: QTCluster.h:111
OpenMS::ConsensusFeature
A consensus feature spanning multiple LC-MS/MS experiments.
Definition: ConsensusFeature.h:69
OpenMS::HashGrid
Container for (2-dimensional coordinate, value) pairs.
Definition: HashGrid.h:62
OpenMS::QTClusterFinder
A variant of QT clustering for the detection of feature groups.
Definition: QTClusterFinder.h:103
GridFeature.h
FeatureDistance.h
OpenMS::QTClusterFinder::getProductName
static const String getProductName()
Returns the name of the product.
Definition: QTClusterFinder.h:187
ProgressLogger.h
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::QTClusterFinder::create
static BaseGroupFinder * create()
Returns an instance of this class.
Definition: QTClusterFinder.h:213
OpenMS::QTClusterFinder::ElementMapping
OpenMSBoost::unordered_map< OpenMS::GridFeature *, std::vector< QTCluster * > > ElementMapping
Map to store which grid features are next to which clusters.
Definition: QTClusterFinder.h:115
OpenMS::Peak2D::MZ
Mass-to-charge dimension id (1 if used as a const int)
Definition: Peak2D.h:76
OpenMS::QTClusterFinder::feature_distance_
FeatureDistance feature_distance_
Feature distance functor.
Definition: QTClusterFinder.h:135
QTCluster.h
OpenMS::QTClusterFinder::nr_partitions_
int nr_partitions_
Maximum m/z difference.
Definition: QTClusterFinder.h:132
OpenMS::QTClusterFinder::already_used_
std::set< OpenMS::GridFeature * > already_used_
Set of features already used.
Definition: QTClusterFinder.h:138
OpenMS::ConsensusMap
A container for consensus elements.
Definition: ConsensusMap.h:79
OpenMS::QTClusterFinder::use_IDs_
bool use_IDs_
Consider peptide identifications for grouping?
Definition: QTClusterFinder.h:123
OpenMS::QTClusterFinder::num_maps_
Size num_maps_
Number of input maps.
Definition: QTClusterFinder.h:120
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127