OpenMS  3.0.0
PeptideAndProteinQuant.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-2022.
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: Hendrik Weisser $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
43 
44 
45 namespace OpenMS
46 {
54  class OPENMS_DLLAPI PeptideAndProteinQuant :
55  public DefaultParamHandler
56  {
57 public:
58 
60  typedef std::map<UInt64, double> SampleAbundances;
61 
63  struct PeptideData
64  {
66  std::map<Int, std::map<Int, SampleAbundances>> abundances;
67 
69  std::map<Int, std::map<Int, SampleAbundances>> psm_counts;
70 
73 
76 
78  std::set<String> accessions;
79 
81  Size psm_count = 0;
82 
84  PeptideData() = default;
85  };
86 
88  typedef std::map<AASequence, PeptideData> PeptideQuant;
89 
91  struct ProteinData
92  {
94  std::map<String, SampleAbundances> abundances;
95 
96  std::map<String, SampleAbundances> psm_counts;
97 
100 
103 
106 
108  Size psm_count = 0;
109 
111  ProteinData() = default;
112  };
113 
115  typedef std::map<String, ProteinData> ProteinQuant;
116 
118  struct Statistics
119  {
122 
125 
128 
130  Size quant_proteins, too_few_peptides;
131 
133  Size quant_peptides, total_peptides;
134 
136  Size quant_features, total_features, blank_features, ambig_features;
137 
140  n_samples(0), quant_proteins(0), too_few_peptides(0),
141  quant_peptides(0), total_peptides(0), quant_features(0),
142  total_features(0), blank_features(0), ambig_features(0) {}
143  };
144 
147 
150 
156  void readQuantData(FeatureMap& features, const ExperimentalDesign& ed);
157 
163  void readQuantData(ConsensusMap& consensus, const ExperimentalDesign& ed);
164 
170  void readQuantData(std::vector<ProteinIdentification>& proteins,
171  std::vector<PeptideIdentification>& peptides,
172  const ExperimentalDesign& ed);
173 
183  void quantifyPeptides(const std::vector<PeptideIdentification>& peptides =
184  std::vector<PeptideIdentification>());
185 
186 
192  void quantifyProteins(const ProteinIdentification& proteins =
194 
196  const Statistics& getStatistics();
197 
199  const PeptideQuant& getPeptideResults();
200 
202  const ProteinQuant& getProteinResults();
203 
205  static void annotateQuantificationsToProteins(
206  const ProteinQuant& protein_quants,
207  ProteinIdentification& proteins,
208  const UInt n_samples,
209  bool remove_unquantified = true);
210 
211 private:
212 
215 
218 
221 
222 
229  PeptideHit getAnnotation_(std::vector<PeptideIdentification>& peptides);
230 
239  void quantifyFeature_(const FeatureHandle& feature,
240  size_t fraction,
241  size_t sample,
242  const PeptideHit& hit);
243 
251  bool getBest_(
252  const std::map<Int, std::map<Int, SampleAbundances>> & peptide_abundances,
253  std::pair<size_t, size_t> & best);
254 
260  template <typename T>
261  void orderBest_(const std::map<T, SampleAbundances> & abundances,
262  std::vector<T>& result)
263  {
264  typedef std::pair<Size, double> PairType;
265  std::multimap<PairType, T, std::greater<PairType> > order;
266  for (typename std::map<T, SampleAbundances>::const_iterator ab_it =
267  abundances.begin(); ab_it != abundances.end(); ++ab_it)
268  {
269  double total = 0.0;
270  for (SampleAbundances::const_iterator samp_it = ab_it->second.begin();
271  samp_it != ab_it->second.end(); ++samp_it)
272  {
273  total += samp_it->second;
274  }
275  if (total <= 0.0) continue; // not quantified
276  PairType key = std::make_pair(ab_it->second.size(), total);
277  order.insert(std::make_pair(key, ab_it->first));
278  }
279  result.clear();
280  for (typename std::multimap<PairType, T, std::greater<PairType> >::
281  iterator ord_it = order.begin(); ord_it != order.end(); ++ord_it)
282  {
283  result.push_back(ord_it->second);
284  }
285  }
286 
287 
288 
292  void normalizePeptides_();
293 
306  String getAccession_(const std::set<String>& pep_accessions,
307  std::map<String, String>& accession_to_leader);
308 
314  void countPeptides_(std::vector<PeptideIdentification>& peptides, const Size& n_fractions);
315 
317  void updateMembers_() override;
318 
319  }; // class
320 
321 } // namespace
322 
DefaultParamHandler.h
OpenMS::ExperimentalDesign
Representation of an experimental design in OpenMS. Instances can be loaded with the ExperimentalDesi...
Definition: ExperimentalDesign.h:242
OpenMS::PeptideAndProteinQuant::Statistics
Statistics for processing summary.
Definition: PeptideAndProteinQuant.h:118
OpenMS::PeptideAndProteinQuant::Statistics::Statistics
Statistics()
constructor
Definition: PeptideAndProteinQuant.h:139
OpenMS::PeptideAndProteinQuant::prot_quant_
ProteinQuant prot_quant_
Protein quantification data.
Definition: PeptideAndProteinQuant.h:220
OpenMS::PeptideAndProteinQuant::PeptideData::total_abundances
SampleAbundances total_abundances
mapping: sample -> total abundance
Definition: PeptideAndProteinQuant.h:72
OpenMS::PeptideAndProteinQuant::pep_quant_
PeptideQuant pep_quant_
Peptide quantification data.
Definition: PeptideAndProteinQuant.h:217
OpenMS::String
A more convenient string class.
Definition: String.h:58
ConsensusMap.h
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::PeptideAndProteinQuant::ProteinData::total_abundances
SampleAbundances total_abundances
mapping: sample -> total abundance
Definition: PeptideAndProteinQuant.h:99
OpenMS::PeptideAndProteinQuant::~PeptideAndProteinQuant
~PeptideAndProteinQuant() override
Destructor.
Definition: PeptideAndProteinQuant.h:149
OpenMS::PeptideAndProteinQuant::PeptideData::accessions
std::set< String > accessions
protein accessions for this peptide
Definition: PeptideAndProteinQuant.h:78
OpenMS::PeptideAndProteinQuant::Statistics::total_features
Size total_features
Definition: PeptideAndProteinQuant.h:136
OpenMS::PeptideAndProteinQuant::Statistics::n_samples
Size n_samples
number of samples (or assays in mzTab terms)
Definition: PeptideAndProteinQuant.h:121
OpenMS::ProteinIdentification
Representation of a protein identification run.
Definition: ProteinIdentification.h:70
OpenMS::PeptideAndProteinQuant::ProteinData::total_psm_counts
SampleAbundances total_psm_counts
spectral counting-based abundances
Definition: PeptideAndProteinQuant.h:102
OpenMS::DefaultParamHandler
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
OpenMS::Int
int Int
Signed integer type.
Definition: Types.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::PeptideAndProteinQuant::Statistics::n_ms_files
Size n_ms_files
number of MS files
Definition: PeptideAndProteinQuant.h:127
OpenMS::PeptideAndProteinQuant::ProteinData::psm_counts
std::map< String, SampleAbundances > psm_counts
Definition: PeptideAndProteinQuant.h:96
OpenMS::PeptideAndProteinQuant::PeptideData::abundances
std::map< Int, std::map< Int, SampleAbundances > > abundances
mapping: fraction -> charge -> sample -> abundance
Definition: PeptideAndProteinQuant.h:66
OpenMS::PeptideAndProteinQuant::ProteinData::total_distinct_peptides
SampleAbundances total_distinct_peptides
number of distinct peptide sequences
Definition: PeptideAndProteinQuant.h:105
OpenMS::PeptideAndProteinQuant::SampleAbundances
std::map< UInt64, double > SampleAbundances
Mapping: sample ID -> abundance.
Definition: PeptideAndProteinQuant.h:60
OpenMS::PeptideAndProteinQuant::ProteinData
Quantitative and associated data for a protein.
Definition: PeptideAndProteinQuant.h:91
FeatureMap.h
ProteinIdentification.h
OpenMS::PeptideAndProteinQuant::orderBest_
void orderBest_(const std::map< T, SampleAbundances > &abundances, std::vector< T > &result)
Order keys (charges/peptides for peptide/protein quantification) according to how many samples they a...
Definition: PeptideAndProteinQuant.h:261
OpenMS::PeptideAndProteinQuant::PeptideData::total_psm_counts
SampleAbundances total_psm_counts
spectral counting-based abundances
Definition: PeptideAndProteinQuant.h:75
OpenMS::ConsensusMap
A container for consensus elements.
Definition: ConsensusMap.h:82
OpenMS::UInt
unsigned int UInt
Unsigned integer type.
Definition: Types.h:94
OpenMS::PeptideAndProteinQuant::Statistics::n_fractions
Size n_fractions
number of fractions
Definition: PeptideAndProteinQuant.h:124
OpenMS::PeptideAndProteinQuant::PeptideData::psm_counts
std::map< Int, std::map< Int, SampleAbundances > > psm_counts
mapping: fraction -> charge -> sample -> abundance
Definition: PeptideAndProteinQuant.h:69
ExperimentalDesign.h
OpenMS::FeatureMap
A container for features.
Definition: FeatureMap.h:98
OpenMS::FeatureHandle
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:57
OpenMS::PeptideAndProteinQuant::Statistics::too_few_peptides
Size too_few_peptides
Definition: PeptideAndProteinQuant.h:130
OpenMS::PeptideAndProteinQuant::stats_
Statistics stats_
Processing statistics for output in the end.
Definition: PeptideAndProteinQuant.h:214
PeptideIdentification.h
OpenMS::PeptideAndProteinQuant::ProteinQuant
std::map< String, ProteinData > ProteinQuant
Mapping: protein accession -> protein data.
Definition: PeptideAndProteinQuant.h:115
OpenMS::PeptideAndProteinQuant::PeptideData
Quantitative and associated data for a peptide.
Definition: PeptideAndProteinQuant.h:63
OpenMS::PeptideAndProteinQuant::Statistics::total_peptides
Size total_peptides
Definition: PeptideAndProteinQuant.h:133
OpenMS::PeptideAndProteinQuant::PeptideQuant
std::map< AASequence, PeptideData > PeptideQuant
Mapping: peptide sequence (modified) -> peptide data.
Definition: PeptideAndProteinQuant.h:88
OpenMS::PeptideHit
Representation of a peptide hit.
Definition: PeptideHit.h:55
OpenMS::PeptideAndProteinQuant
Helper class for peptide and protein quantification based on feature data annotated with IDs.
Definition: PeptideAndProteinQuant.h:54
OpenMS::PeptideAndProteinQuant::ProteinData::abundances
std::map< String, SampleAbundances > abundances
mapping: peptide (unmodified) -> sample -> abundance
Definition: PeptideAndProteinQuant.h:94