22#include <unordered_map>
50 std::map<Int, std::map<std::string, std::map<Int, std::map<UInt, double>>>>
abundances;
53 std::map<Int, std::map<std::string, std::map<Int, UInt64>>>
psm_counts;
130 n_samples(0), quant_proteins(0), too_few_peptides(0),
131 quant_peptides(0), total_peptides(0), quant_features(0),
132 total_features(0), blank_features(0), ambig_features(0) {}
202 bool remove_unquantified =
true);
211 std::size_t
operator()(
const std::pair<std::string, UInt>& p)
const noexcept
213 const std::size_t h1 = std::hash<std::string>{}(p.first);
214 const std::size_t h2 = std::hash<UInt>{}(p.second);
216 return h1 ^ (h2 + 0x9e3779b97f4a7c15ULL + (h1 << 6) + (h1 >> 2));
283 const std::string& filename,
285 UInt channel_or_label);
300 const std::map<
Int, std::map<std::string, std::map<
Int, std::map<UInt, double>>>>& peptide_abundances,
301 Int& best_charge)
const;
355 template <
typename T>
356 void orderBest_(
const std::map<T, FractionGroupAbundances>& abundances,
357 std::vector<T>& result)
359 typedef std::pair<Size, double> PairType;
360 std::multimap<PairType, T, std::greater<PairType> > order;
361 for (
const auto& abundance : abundances)
364 for (
const auto& [fraction_group, label_abundances] : abundance.second)
366 (void)fraction_group;
367 for (
const auto& label_abundance : label_abundances)
369 total += label_abundance.second;
372 if (total <= 0.0)
continue;
373 PairType key = std::make_pair(countQuantifiedAssays_(abundance.second), total);
374 order.insert(std::make_pair(key, abundance.first));
377 for (
typename std::multimap<PairType, T, std::greater<PairType> >::
378 iterator ord_it = order.begin(); ord_it != order.end(); ++ord_it)
380 result.push_back(ord_it->second);
420 const std::string& method)
const;
432 const std::vector<std::string>& selected_peptides,
433 const std::string& aggregate_method,
449 const std::vector<std::string>& selected_peptides,
450 const std::string& aggregate_method,
453 const std::map<std::string, std::string>& accession_to_leader,
476 const std::map<std::string, std::string>& accession_to_leader)
const;
508 UInt channel_or_label)
const;
520 UInt channel_or_label)
const;
A container for consensus elements.
Definition ConsensusMap.h:67
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:449
Representation of a Peak2D, RichPeak2D or Feature .
Definition FeatureHandle.h:36
A container for features.
Definition FeatureMap.h:78
Helper class for peptide and protein quantification based on feature data annotated with IDs.
Definition PeptideAndProteinQuant.h:37
void readQuantData(ConsensusMap &consensus, const ExperimentalDesign &ed)
Read quantitative data from a consensus map.
const DesignCell & getDesignCellFromFilenameAndChannel_(const std::string &filename, UInt channel_or_label) const
Map (filename, channel) to its experimental-design cell.
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:72
void readQuantData(FeatureMap &features, const ExperimentalDesign &ed)
Read quantitative data from a feature map.
void buildSampleIDLookup_()
(Re)build design-cell lookups from experimental_design_.
std::unordered_map< std::string, std::vector< const PeptideQuant::value_type * > > UnmodifiedToEntriesIndex
Definition PeptideAndProteinQuant.h:233
void orderBest_(const std::map< T, FractionGroupAbundances > &abundances, std::vector< T > &result)
Order keys according to how many assays they quantify, breaking ties by total abundance.
Definition PeptideAndProteinQuant.h:356
bool getBestCharge_(const std::map< Int, std::map< std::string, std::map< Int, std::map< UInt, double > > > > &peptide_abundances, Int &best_charge) const
Select one charge state globally for a modified peptide.
ExperimentalDesign experimental_design_
Experimental design for filename/channel to sample mapping.
Definition PeptideAndProteinQuant.h:249
std::map< std::string, ProteinData > ProteinQuant
Mapping: protein accession -> protein data.
Definition PeptideAndProteinQuant.h:105
std::map< UInt, std::map< UInt, double > > FractionGroupAbundances
Mapping: experimental-design fraction group -> label/channel -> abundance.
Definition PeptideAndProteinQuant.h:44
void calculateFileAndChannelLevelProteinAbundances_(const std::string &protein_accession, const std::vector< std::string > &selected_peptides, const std::string &aggregate_method, Size top_n, bool include_all, const std::map< std::string, std::string > &accession_to_leader, const UnmodifiedToEntriesIndex &unmod_to_entries)
Calculate detailed protein abundances at channel level using selected peptides.
double aggregateAbundances_(const std::vector< double > &abundances, const std::string &method) const
Aggregate abundances using the specified mathematical method.
std::vector< std::string > selectPeptidesForQuantification_(const std::string &protein_accession, Size top_n, bool fix_peptides)
Select peptides for protein quantification based on filtering criteria.
void quantifyFeature_(const FeatureHandle &feature, size_t fraction, const std::string &filename, const PeptideHit &hit, UInt channel_or_label)
Gather quantitative information from a feature.
const PeptideQuant & getPeptideResults()
Get peptide abundance data.
void performIbaqNormalization_(const ProteinIdentification &proteins)
Perform iBAQ normalization on protein abundances.
static Int selectBestFraction_(const std::map< Int, std::map< UInt, double > > &fraction_abundances)
Select the fraction to keep for one fraction group, see 'fractions:aggregate' 'best'.
std::map< std::string, std::string > mapAccessionToLeader(const OpenMS::ProteinIdentification &proteins) const
void countPeptides_(PeptideIdentificationList &peptides)
Count the number of identifications (best hits only) of each peptide sequence.
void quantifyPeptides(const PeptideIdentificationList &peptides=PeptideIdentificationList())
Compute peptide abundances.
std::map< AASequence, Int > best_charge_by_peptidoform_
Definition PeptideAndProteinQuant.h:243
PeptideQuant pep_quant_
Peptide quantification data.
Definition PeptideAndProteinQuant.h:239
void transferPeptideDataToProteins_(const ProteinIdentification &proteins)
Transfer peptide-level quantitative data to protein-level data structures.
static Size countQuantifiedAssays_(const FractionGroupAbundances &abundances)
Number of assays in which abundances is actually quantified.
void calculateFractionGroupLevelProteinAbundances_(const std::string &protein_accession, const std::vector< std::string > &selected_peptides, const std::string &aggregate_method, Size top_n, bool include_all)
Calculate protein abundances at experimental-design fraction-group/label grain.
~PeptideAndProteinQuant() override
Destructor.
Definition PeptideAndProteinQuant.h:139
std::string getAccession_(const std::set< std::string > &pep_accessions, const std::map< std::string, std::string > &accession_to_leader) const
Get the "canonical" protein accession from the list of protein accessions of a peptide.
Size getSampleIDFromFilenameAndChannel_(const std::string &filename, UInt channel_or_label) const
Map (filename, channel) to a sample using the precomputed design-cell lookup.
void readQuantData(std::vector< ProteinIdentification > &proteins, PeptideIdentificationList &peptides, const ExperimentalDesign &ed)
Read quantitative data from identification results (for quantification via spectral counting).
void updateMembers_() override
Clear all data when parameters are set.
std::set< std::pair< UInt, UInt > > quantification_fraction_group_labels_
Definition PeptideAndProteinQuant.h:260
std::map< UInt, std::map< Int, std::map< UInt, double > > > FractionGroupFractionAbundances
Mapping: fraction group -> fraction -> label/channel -> abundance.
Definition PeptideAndProteinQuant.h:304
const ProteinQuant & getProteinResults()
Get protein abundance data.
std::unordered_map< std::pair< std::string, UInt >, DesignCell, FileLabelHash > design_cell_lookup_
Definition PeptideAndProteinQuant.h:255
void normalizePeptides_()
Normalize peptide abundances across assays by multiplicative scaling to equal medians.
void quantifyProteins(const ProteinIdentification &proteins=ProteinIdentification())
Compute protein abundances.
Statistics stats_
Processing statistics for output in the end.
Definition PeptideAndProteinQuant.h:236
const Statistics & getStatistics()
Get summary statistics.
PeptideHit getAnnotation_(PeptideIdentificationList &peptides)
Get the "canonical" annotation (a single peptide hit) of a feature/consensus feature from the associa...
std::map< UInt64, double > SampleAbundances
Mapping: sample ID -> abundance.
Definition PeptideAndProteinQuant.h:41
ProteinQuant prot_quant_
Protein quantification data.
Definition PeptideAndProteinQuant.h:246
PeptideAndProteinQuant()
Constructor.
void collapseFractions_(const FractionGroupFractionAbundances &fraction_abundances, FractionGroupAbundances &assay_abundances) const
Combine the fractions of every fraction group into assay abundances.
Experimental-design coordinates of one (basename, label) cell.
Definition PeptideAndProteinQuant.h:222
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition PeptideHit.h:52
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Representation of a protein identification run.
Definition ProteinIdentification.h:55
int Int
Signed integer type.
Definition Types.h:72
unsigned int UInt
Unsigned integer type.
Definition Types.h:64
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
Definition PeptideAndProteinQuant.h:210
std::size_t operator()(const std::pair< std::string, UInt > &p) const noexcept
Definition PeptideAndProteinQuant.h:211
Quantitative and associated data for a peptide.
Definition PeptideAndProteinQuant.h:48
std::map< Int, std::map< std::string, std::map< Int, UInt64 > > > psm_counts
mapping: fraction -> filename -> charge -> abundance
Definition PeptideAndProteinQuant.h:53
SampleAbundances total_psm_counts
spectral counting-based abundances
Definition PeptideAndProteinQuant.h:59
FractionGroupAbundances fraction_group_abundances
mapping: fraction group -> label/channel -> abundance
Definition PeptideAndProteinQuant.h:56
std::map< Int, std::map< std::string, std::map< Int, std::map< UInt, double > > > > abundances
mapping: fraction -> filename -> charge -> channel/label -> abundance
Definition PeptideAndProteinQuant.h:50
PeptideData()=default
constructor
std::set< std::string > accessions
protein accessions for this peptide
Definition PeptideAndProteinQuant.h:62
Quantitative and associated data for a protein.
Definition PeptideAndProteinQuant.h:76
ProteinData()=default
constructor
SampleAbundances total_psm_counts
spectral counting-based abundances
Definition PeptideAndProteinQuant.h:92
std::map< std::string, SampleAbundances > peptide_psm_counts
Definition PeptideAndProteinQuant.h:80
std::map< std::string, std::map< UInt, double > > channel_level_abundances
mapping: filename -> channel/label -> abundance
Definition PeptideAndProteinQuant.h:83
std::map< std::string, UInt64 > file_level_psm_counts
mapping: filename -> PSM counts
Definition PeptideAndProteinQuant.h:86
FractionGroupAbundances fraction_group_abundances
mapping: fraction group -> label/channel -> total abundance
Definition PeptideAndProteinQuant.h:89
std::map< std::string, FractionGroupAbundances > peptide_fraction_group_abundances
mapping: peptide (unmodified) -> fraction group -> label/channel -> abundance
Definition PeptideAndProteinQuant.h:78
SampleAbundances total_distinct_peptides
number of distinct peptide sequences
Definition PeptideAndProteinQuant.h:95
Statistics for processing summary.
Definition PeptideAndProteinQuant.h:109
Size quant_proteins
protein statistics
Definition PeptideAndProteinQuant.h:120
Size quant_peptides
peptide statistics
Definition PeptideAndProteinQuant.h:123
Size n_samples
number of SampleSection entries (used by sample-indexed spectral-count metadata)
Definition PeptideAndProteinQuant.h:111
Size n_fractions
number of fractions
Definition PeptideAndProteinQuant.h:114
Statistics()
constructor
Definition PeptideAndProteinQuant.h:129
Size n_ms_files
number of MS files
Definition PeptideAndProteinQuant.h:117
Size ambig_features
Definition PeptideAndProteinQuant.h:126