OpenMS
PeptideAndProteinQuant.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Hendrik Weisser $
6 // $Authors: Hendrik Weisser $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
17 
18 
19 namespace OpenMS
20 {
28  class OPENMS_DLLAPI PeptideAndProteinQuant :
29  public DefaultParamHandler
30  {
31 public:
32 
34  typedef std::map<UInt64, double> SampleAbundances;
35 
37  struct PeptideData
38  {
40  std::map<Int, std::map<Int, SampleAbundances>> abundances;
41 
43  std::map<Int, std::map<Int, SampleAbundances>> psm_counts;
44 
47 
50 
52  std::set<String> accessions;
53 
55  Size psm_count = 0;
56 
58  PeptideData() = default;
59  };
60 
62  typedef std::map<AASequence, PeptideData> PeptideQuant;
63 
65  struct ProteinData
66  {
68  std::map<String, SampleAbundances> abundances;
69 
70  std::map<String, SampleAbundances> psm_counts;
71 
74 
77 
80 
82  Size psm_count = 0;
83 
85  ProteinData() = default;
86  };
87 
89  typedef std::map<String, ProteinData> ProteinQuant;
90 
92  struct Statistics
93  {
96 
99 
102 
104  Size quant_proteins, too_few_peptides;
105 
107  Size quant_peptides, total_peptides;
108 
110  Size quant_features, total_features, blank_features, ambig_features;
111 
114  n_samples(0), quant_proteins(0), too_few_peptides(0),
115  quant_peptides(0), total_peptides(0), quant_features(0),
116  total_features(0), blank_features(0), ambig_features(0) {}
117  };
118 
121 
124 
130  void readQuantData(FeatureMap& features, const ExperimentalDesign& ed);
131 
137  void readQuantData(ConsensusMap& consensus, const ExperimentalDesign& ed);
138 
144  void readQuantData(std::vector<ProteinIdentification>& proteins,
145  std::vector<PeptideIdentification>& peptides,
146  const ExperimentalDesign& ed);
147 
157  void quantifyPeptides(const std::vector<PeptideIdentification>& peptides =
158  std::vector<PeptideIdentification>());
159 
160 
166  void quantifyProteins(const ProteinIdentification& proteins =
168 
171 
174 
177 
180  const ProteinQuant& protein_quants,
181  ProteinIdentification& proteins,
182  bool remove_unquantified = true);
183 
184 private:
185 
188 
191 
194 
195 
202  PeptideHit getAnnotation_(std::vector<PeptideIdentification>& peptides);
203 
212  void quantifyFeature_(const FeatureHandle& feature,
213  size_t fraction,
214  size_t sample,
215  const PeptideHit& hit);
216 
224  bool getBest_(
225  const std::map<Int, std::map<Int, SampleAbundances>> & peptide_abundances,
226  std::pair<size_t, size_t> & best);
227 
233  template <typename T>
234  void orderBest_(const std::map<T, SampleAbundances> & abundances,
235  std::vector<T>& result)
236  {
237  typedef std::pair<Size, double> PairType;
238  std::multimap<PairType, T, std::greater<PairType> > order;
239  for (typename std::map<T, SampleAbundances>::const_iterator ab_it =
240  abundances.begin(); ab_it != abundances.end(); ++ab_it)
241  {
242  double total = 0.0;
243  for (SampleAbundances::const_iterator samp_it = ab_it->second.begin();
244  samp_it != ab_it->second.end(); ++samp_it)
245  {
246  total += samp_it->second;
247  }
248  if (total <= 0.0) continue; // not quantified
249  PairType key = std::make_pair(ab_it->second.size(), total);
250  order.insert(std::make_pair(key, ab_it->first));
251  }
252  result.clear();
253  for (typename std::multimap<PairType, T, std::greater<PairType> >::
254  iterator ord_it = order.begin(); ord_it != order.end(); ++ord_it)
255  {
256  result.push_back(ord_it->second);
257  }
258  }
259 
260 
261 
266 
279  String getAccession_(const std::set<String>& pep_accessions,
280  std::map<String, String>& accession_to_leader);
281 
287  void countPeptides_(std::vector<PeptideIdentification>& peptides);
288 
290  void updateMembers_() override;
291 
292  }; // class
293 
294 } // namespace
295 
A container for consensus elements.
Definition: ConsensusMap.h:66
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
Representation of an experimental design in OpenMS. Instances can be loaded with the ExperimentalDesi...
Definition: ExperimentalDesign.h:219
Representation of a Peak2D, RichPeak2D or Feature .
Definition: FeatureHandle.h:34
A container for features.
Definition: FeatureMap.h:80
Helper class for peptide and protein quantification based on feature data annotated with IDs.
Definition: PeptideAndProteinQuant.h:30
void readQuantData(ConsensusMap &consensus, const ExperimentalDesign &ed)
Read quantitative data from a consensus map.
void annotateQuantificationsToProteins(const ProteinQuant &protein_quants, ProteinIdentification &proteins, bool remove_unquantified=true)
Annotate protein quant results as meta data to protein ids.
std::map< AASequence, PeptideData > PeptideQuant
Mapping: peptide sequence (modified) -> peptide data.
Definition: PeptideAndProteinQuant.h:62
void readQuantData(FeatureMap &features, const ExperimentalDesign &ed)
Read quantitative data from a feature map.
void countPeptides_(std::vector< PeptideIdentification > &peptides)
Count the number of identifications (best hits only) of each peptide sequence.
void quantifyPeptides(const std::vector< PeptideIdentification > &peptides=std::vector< PeptideIdentification >())
Compute peptide abundances.
std::map< String, ProteinData > ProteinQuant
Mapping: protein accession -> protein data.
Definition: PeptideAndProteinQuant.h:89
const ProteinQuant & getProteinResults()
Get protein abundance data.
void quantifyFeature_(const FeatureHandle &feature, size_t fraction, size_t sample, const PeptideHit &hit)
Gather quantitative information from a feature.
bool getBest_(const std::map< Int, std::map< Int, SampleAbundances >> &peptide_abundances, std::pair< size_t, size_t > &best)
Determine fraction and charge state of a peptide with the highest number of abundances.
PeptideQuant pep_quant_
Peptide quantification data.
Definition: PeptideAndProteinQuant.h:190
const PeptideQuant & getPeptideResults()
Get peptide abundance data.
~PeptideAndProteinQuant() override
Destructor.
Definition: PeptideAndProteinQuant.h:123
void updateMembers_() override
Clear all data when parameters are set.
void normalizePeptides_()
Normalize peptide abundances across samples by (multiplicative) scaling to equal medians.
String getAccession_(const std::set< String > &pep_accessions, std::map< String, String > &accession_to_leader)
Get the "canonical" protein accession from the list of protein accessions of a peptide.
void quantifyProteins(const ProteinIdentification &proteins=ProteinIdentification())
Compute protein abundances.
Statistics stats_
Processing statistics for output in the end.
Definition: PeptideAndProteinQuant.h:187
PeptideHit getAnnotation_(std::vector< PeptideIdentification > &peptides)
Get the "canonical" annotation (a single peptide hit) of a feature/consensus feature from the associa...
const Statistics & getStatistics()
Get summary statistics.
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:234
std::map< UInt64, double > SampleAbundances
Mapping: sample ID -> abundance.
Definition: PeptideAndProteinQuant.h:34
ProteinQuant prot_quant_
Protein quantification data.
Definition: PeptideAndProteinQuant.h:193
PeptideAndProteinQuant()
Constructor.
void readQuantData(std::vector< ProteinIdentification > &proteins, std::vector< PeptideIdentification > &peptides, const ExperimentalDesign &ed)
Read quantitative data from identification results (for quantification via spectral counting).
Representation of a peptide hit.
Definition: PeptideHit.h:31
Representation of a protein identification run.
Definition: ProteinIdentification.h:50
A more convenient string class.
Definition: String.h:34
int Int
Signed integer type.
Definition: Types.h:72
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
Quantitative and associated data for a peptide.
Definition: PeptideAndProteinQuant.h:38
SampleAbundances total_psm_counts
spectral counting-based abundances
Definition: PeptideAndProteinQuant.h:49
SampleAbundances total_abundances
mapping: sample -> total abundance
Definition: PeptideAndProteinQuant.h:46
std::set< String > accessions
protein accessions for this peptide
Definition: PeptideAndProteinQuant.h:52
std::map< Int, std::map< Int, SampleAbundances > > abundances
mapping: fraction -> charge -> sample -> abundance
Definition: PeptideAndProteinQuant.h:40
std::map< Int, std::map< Int, SampleAbundances > > psm_counts
mapping: fraction -> charge -> sample -> abundance
Definition: PeptideAndProteinQuant.h:43
Quantitative and associated data for a protein.
Definition: PeptideAndProteinQuant.h:66
SampleAbundances total_psm_counts
spectral counting-based abundances
Definition: PeptideAndProteinQuant.h:76
SampleAbundances total_abundances
mapping: sample -> total abundance
Definition: PeptideAndProteinQuant.h:73
std::map< String, SampleAbundances > abundances
mapping: peptide (unmodified) -> sample -> abundance
Definition: PeptideAndProteinQuant.h:68
std::map< String, SampleAbundances > psm_counts
Definition: PeptideAndProteinQuant.h:70
SampleAbundances total_distinct_peptides
number of distinct peptide sequences
Definition: PeptideAndProteinQuant.h:79
Statistics for processing summary.
Definition: PeptideAndProteinQuant.h:93
Size quant_proteins
protein statistics
Definition: PeptideAndProteinQuant.h:104
Size quant_peptides
peptide statistics
Definition: PeptideAndProteinQuant.h:107
Size n_samples
number of samples (or assays in mzTab terms)
Definition: PeptideAndProteinQuant.h:95
Size n_fractions
number of fractions
Definition: PeptideAndProteinQuant.h:98
Statistics()
constructor
Definition: PeptideAndProteinQuant.h:113
Size n_ms_files
number of MS files
Definition: PeptideAndProteinQuant.h:101
Size ambig_features
Definition: PeptideAndProteinQuant.h:110