![]() |
OpenMS
|
Helper class for peptide and protein quantification based on feature data annotated with IDs. More...
#include <OpenMS/ANALYSIS/QUANTITATION/PeptideAndProteinQuant.h>
Classes | |
| struct | DesignCell |
| Experimental-design coordinates of one (basename, label) cell. More... | |
| struct | FileLabelHash |
| struct | PeptideData |
| Quantitative and associated data for a peptide. More... | |
| struct | ProteinData |
| Quantitative and associated data for a protein. More... | |
| struct | Statistics |
| Statistics for processing summary. More... | |
Public Types | |
| typedef std::map< UInt64, double > | SampleAbundances |
| Mapping: sample ID -> abundance. | |
| typedef std::map< UInt, std::map< UInt, double > > | FractionGroupAbundances |
| Mapping: experimental-design fraction group -> label/channel -> abundance. | |
| typedef std::map< AASequence, PeptideData > | PeptideQuant |
| Mapping: peptide sequence (modified) -> peptide data. | |
| typedef std::map< std::string, ProteinData > | ProteinQuant |
| Mapping: protein accession -> protein data. | |
Public Member Functions | |
| PeptideAndProteinQuant () | |
| Constructor. | |
| ~PeptideAndProteinQuant () override | |
| Destructor. | |
| void | readQuantData (FeatureMap &features, const ExperimentalDesign &ed) |
| Read quantitative data from a feature map. | |
| void | readQuantData (ConsensusMap &consensus, const ExperimentalDesign &ed) |
| Read quantitative data from a consensus map. | |
| void | readQuantData (std::vector< ProteinIdentification > &proteins, PeptideIdentificationList &peptides, const ExperimentalDesign &ed) |
| Read quantitative data from identification results (for quantification via spectral counting). | |
| void | quantifyPeptides (const PeptideIdentificationList &peptides=PeptideIdentificationList()) |
| Compute peptide abundances. | |
| void | quantifyProteins (const ProteinIdentification &proteins=ProteinIdentification()) |
| Compute protein abundances. | |
| std::map< std::string, std::string > | mapAccessionToLeader (const OpenMS::ProteinIdentification &proteins) const |
| const Statistics & | getStatistics () |
| Get summary statistics. | |
| const PeptideQuant & | getPeptideResults () |
| Get peptide abundance data. | |
| const ProteinQuant & | getProteinResults () |
| Get protein abundance data. | |
| void | annotateQuantificationsToProteins (const ProteinQuant &protein_quants, ProteinIdentification &proteins, bool remove_unquantified=true) |
| Annotate protein quant results as meta data to protein ids. | |
Public Member Functions inherited from DefaultParamHandler | |
| DefaultParamHandler (const std::string &name) | |
| Constructor with name that is displayed in error messages. | |
| DefaultParamHandler (const DefaultParamHandler &rhs) | |
| Copy constructor. | |
| virtual | ~DefaultParamHandler () |
| Destructor. | |
| DefaultParamHandler & | operator= (const DefaultParamHandler &rhs) |
| Assignment operator. | |
| virtual bool | operator== (const DefaultParamHandler &rhs) const |
| Equality operator. | |
| void | setParameters (const Param ¶m) |
| Sets the parameters. | |
| const Param & | getParameters () const |
| Non-mutable access to the parameters. | |
| const Param & | getDefaults () const |
| Non-mutable access to the default parameters. | |
| const std::string & | getName () const |
| Non-mutable access to the name. | |
| void | setName (const std::string &name) |
| Mutable access to the name. | |
| const std::vector< std::string > & | getSubsections () const |
| Non-mutable access to the registered subsections. | |
Private Types | |
| typedef std::unordered_map< std::string, std::vector< const PeptideQuant::value_type * > > | UnmodifiedToEntriesIndex |
| typedef std::map< UInt, std::map< Int, std::map< UInt, double > > > | FractionGroupFractionAbundances |
| Mapping: fraction group -> fraction -> label/channel -> abundance. | |
Private Member Functions | |
| PeptideHit | getAnnotation_ (PeptideIdentificationList &peptides) |
| Get the "canonical" annotation (a single peptide hit) of a feature/consensus feature from the associated list of peptide identifications. | |
| 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. | |
| 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. | |
| void | collapseFractions_ (const FractionGroupFractionAbundances &fraction_abundances, FractionGroupAbundances &assay_abundances) const |
| Combine the fractions of every fraction group into assay abundances. | |
| template<typename T > | |
| 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. | |
| void | normalizePeptides_ () |
| Normalize peptide abundances across assays by multiplicative scaling to equal medians. | |
| void | transferPeptideDataToProteins_ (const ProteinIdentification &proteins) |
| Transfer peptide-level quantitative data to protein-level data structures. | |
| 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. | |
| double | aggregateAbundances_ (const std::vector< double > &abundances, const std::string &method) const |
| Aggregate abundances using the specified mathematical method. | |
| 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. | |
| 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. | |
| void | performIbaqNormalization_ (const ProteinIdentification &proteins) |
| Perform iBAQ normalization on protein abundances. | |
| 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. | |
| void | countPeptides_ (PeptideIdentificationList &peptides) |
| Count the number of identifications (best hits only) of each peptide sequence. | |
| void | buildSampleIDLookup_ () |
(Re)build design-cell lookups from experimental_design_. | |
| const DesignCell & | getDesignCellFromFilenameAndChannel_ (const std::string &filename, UInt channel_or_label) const |
| Map (filename, channel) to its experimental-design cell. | |
| Size | getSampleIDFromFilenameAndChannel_ (const std::string &filename, UInt channel_or_label) const |
| Map (filename, channel) to a sample using the precomputed design-cell lookup. | |
| void | updateMembers_ () override |
| Clear all data when parameters are set. | |
Static Private Member Functions | |
| 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'. | |
| static Size | countQuantifiedAssays_ (const FractionGroupAbundances &abundances) |
Number of assays in which abundances is actually quantified. | |
Private Attributes | |
| Statistics | stats_ |
| Processing statistics for output in the end. | |
| PeptideQuant | pep_quant_ |
| Peptide quantification data. | |
| std::map< AASequence, Int > | best_charge_by_peptidoform_ |
| ProteinQuant | prot_quant_ |
| Protein quantification data. | |
| ExperimentalDesign | experimental_design_ |
| Experimental design for filename/channel to sample mapping. | |
| std::unordered_map< std::pair< std::string, UInt >, DesignCell, FileLabelHash > | design_cell_lookup_ |
| std::set< std::pair< UInt, UInt > > | quantification_fraction_group_labels_ |
Additional Inherited Members | |
Static Public Member Functions inherited from DefaultParamHandler | |
| static void | writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const std::string &key_prefix="") |
| Writes all parameters to meta values. | |
Protected Member Functions inherited from DefaultParamHandler | |
| void | defaultsToParam_ () |
| Updates the parameters after the defaults have been set in the constructor. | |
Protected Attributes inherited from DefaultParamHandler | |
| Param | param_ |
| Container for current parameters. | |
| Param | defaults_ |
| Container for default parameters. This member should be filled in the constructor of derived classes! | |
| std::vector< std::string > | subsections_ |
| Container for registered subsections. This member should be filled in the constructor of derived classes! | |
| std::string | error_name_ |
| Name that is displayed in error messages during the parameter checking. | |
| bool | check_defaults_ |
| If this member is set to false no checking if parameters in done;. | |
| bool | warn_empty_defaults_ |
| If this member is set to false no warning is emitted when defaults are empty;. | |
Helper class for peptide and protein quantification based on feature data annotated with IDs.
This class is used by ProteinQuantifier. See there for further documentation.
Parameters of this class are:| Name | Type | Default | Restrictions | Description |
|---|---|---|---|---|
| method | string | top | top, iBAQ | - top - quantify based on three most abundant peptides (number can be changed in 'top'). - iBAQ (intensity based absolute quantification), calculate the sum of all peptide peak intensities divided by the number of theoretically observable tryptic peptides (https://rdcu.be/cND1J). Warning: only consensusXML or featureXML input is allowed! |
| best_charge | string | false | true, false | Distinguish between fraction and charge states in detailed peptide output. For protein quantification, select one charge per modified peptide globally: maximize the number of (fraction group, label) assays with a positive abundance, then break ties by total abundance; retain that charge's values in every assay. By default, protein abundances are summed over all charge states. How the retained values of several fractions are combined is governed by 'fractions:aggregate', not by this flag. |
| top:N | int | 3 | min: 0 | Calculate protein abundance from this number of proteotypic peptides (most abundant first; '0' for all) |
| top:aggregate | string | median | median, mean, weighted_mean, sum | Aggregation method used to compute protein abundances from peptide abundances |
| top:include_all | string | false | true, false | Include results for proteins with fewer proteotypic peptides than indicated by 'N' (no effect if 'N' is 0 or 1) |
| fractions:aggregate | string | sum | sum, best | How the fractions of one fraction group are combined into that group's (fraction group, label) assay values. - sum - add up every fraction, i.e. treat them as the parts of one separated sample that they are. - best - keep a single fraction per peptide and fraction group and discard the others. The fraction is chosen ONCE per peptide, ranked by the number of labels in which it has a positive abundance and then by the total of those abundances (an exact tie keeps the lowest fraction number), and ALL of its labels are then taken from it. The choice is deliberately not made per label: taking one channel from one fraction and another channel from a different fraction would mix physical aliquots and destroy the reporter-ion ratios that isobaric quantification consists of. Only the assay values are affected. Per-(file, channel) quantities are per fraction by definition and always report every file. |
| consensus:normalize | string | false | true, false | Scale peptide abundances so that the median of each (fraction group, label) assay matches the overall median. Abundances of zero count as 'not detected' and are left out of the medians; an assay without any positive abundance takes no part in the normalization. |
| consensus:fix_peptides | string | false | true, false | Use the same peptides for protein quantification across all (fraction group, label) assays. With 'N 0',all peptides that occur in every assay are considered. Otherwise ('N'), the N peptides that occur in the most assays (independently of each other) are selected, breaking ties by total abundance (there is no guarantee that the best co-ocurring peptides are chosen!). A peptide counts as occurring in an assay only where its abundance is positive: an abundance stored as zero means 'not detected' (e.g. an isobaric reporter below 'min_reporter_intensity'), not a measurement of absence. |
| struct OpenMS::PeptideAndProteinQuant::DesignCell |
| typedef std::map<UInt, std::map<UInt, double> > FractionGroupAbundances |
Mapping: experimental-design fraction group -> label/channel -> abundance.
|
private |
Mapping: fraction group -> fraction -> label/channel -> abundance.
| typedef std::map<AASequence, PeptideData> PeptideQuant |
Mapping: peptide sequence (modified) -> peptide data.
| typedef std::map<std::string, ProteinData> ProteinQuant |
Mapping: protein accession -> protein data.
| typedef std::map<UInt64, double> SampleAbundances |
Mapping: sample ID -> abundance.
|
private |
Index: unmodified peptide sequence -> all pep_quant_ entries (modified peptidoforms) sharing that unmodified sequence. Built once per quantifyProteins() call so that channel-level aggregation does not rescan pep_quant_ (calling AASequence::toUnmodifiedString() on every entry) for every (protein, peptide) pair. Only looked up by key (never range-iterated); the per-bucket vector preserves pep_quant_ (AASequence-sorted) order, so an unordered map keeps output identical.
Constructor.
|
inlineoverride |
Destructor.
|
private |
Aggregate abundances using the specified mathematical method.
| [in] | abundances | Vector of abundance values to aggregate |
| [in] | method | Aggregation method ("median", "mean", "weighted_mean", "sum") |
| void annotateQuantificationsToProteins | ( | const ProteinQuant & | protein_quants, |
| ProteinIdentification & | proteins, | ||
| bool | remove_unquantified = true |
||
| ) |
Annotate protein quant results as meta data to protein ids.
|
private |
(Re)build design-cell lookups from experimental_design_.
Maps each (basename without extension, channel/label) of the MS file section to its sample and fraction group. Conflicting duplicate cells and fraction-group labels that resolve to different samples are rejected. Called whenever the experimental design is (re)set.
| Exception::MissingInformation | if a cell refers outside the sample section, duplicate cells conflict, one run belongs to several fraction groups, or one fraction-group label resolves to several samples |
|
private |
Calculate detailed protein abundances at channel level using selected peptides.
| [in] | protein_accession | The protein accession |
| [in] | selected_peptides | Vector of peptide sequences to use for quantification |
| [in] | aggregate_method | Method to aggregate peptide abundances |
| [in] | top_n | Maximum number of peptides to use per file/channel cell |
| [in] | include_all | Whether to include proteins with insufficient peptides |
| [in] | accession_to_leader | Map for resolving protein group leaders |
| [in] | unmod_to_entries | Precomputed index from unmodified peptide sequence to the pep_quant_ entries sharing it (avoids rescanning pep_quant_) |
|
private |
Calculate protein abundances at experimental-design fraction-group/label grain.
| [in] | protein_accession | The protein accession |
| [in] | selected_peptides | Vector of peptide sequences to use for quantification |
| [in] | aggregate_method | Method to aggregate peptide abundances |
| [in] | top_n | Maximum number of peptides to use per quantification unit |
| [in] | include_all | Whether to include proteins with insufficient peptides |
|
private |
Combine the fractions of every fraction group into assay abundances.
Applies 'fractions:aggregate': 'sum' adds all fractions up, 'best' keeps the single fraction chosen by selectBestFraction_() and discards the others. Either way every label observed in any fraction of a group becomes a cell of that group's assays, so that the two settings produce the same set of keys and a label seen only in a discarded fraction reports "not detected" rather than disappearing.
| [in] | fraction_abundances | Mapping fraction group -> fraction -> label -> abundance |
| [out] | assay_abundances | Mapping fraction group -> label -> abundance |
|
private |
Count the number of identifications (best hits only) of each peptide sequence.
The peptide hits in peptides are sorted by score in the process.
|
staticprivate |
Number of assays in which abundances is actually quantified.
Counts the entries with a positive abundance, not the entries. A zero is not a measurement of "no protein": IsobaricChannelExtractor stores a reporter it could not find - or one below 'min_reporter_intensity' - as 0.0, and quantifyFeature_ records that handle like any other, so the assay key exists with value 0. Counting those keys would report a peptide with signal in 2 of 10 TMT channels as quantified in all 10.
This is the rule normalizePeptides_() already applies to its medians and getBestCharge_() to its charge prevalence; it belongs to every count of "in how many assays".
|
private |
Get the "canonical" protein accession from the list of protein accessions of a peptide.
| [in] | pep_accessions | Protein accessions of a peptide |
| [in] | accession_to_leader | Captures information about indistinguishable proteins (maps accession to accession of group leader) |
If there is no information about indistinguishable proteins (from protXML) available, a canonical accession exists only for proteotypic peptides - it's the single accession for the respective peptide.
Otherwise, a peptide has a canonical accession if it maps only to proteins of one indistinguishable group. In this case, the canonical accession is that of the group leader.
If there is no canonical accession, the empty string is returned.
|
private |
Get the "canonical" annotation (a single peptide hit) of a feature/consensus feature from the associated list of peptide identifications.
Only the best-scoring peptide hit of each ID in peptides is taken into account. The hits of each ID must already be sorted! If there's more than one ID and the best hits are not identical by sequence, or if there's no peptide ID, an empty peptide hit (for "ambiguous/no annotation") is returned. Protein accessions from identical peptide hits are accumulated.
|
private |
Select one charge state globally for a modified peptide.
Positive observations are collapsed to (fraction group, label) assays through the experimental design. The charge quantified in the most distinct assays wins; ties are resolved by its summed abundance across all assays. If both criteria tie, the lower charge wins deterministically.
| [in] | peptide_abundances | Mapping fraction -> filename -> charge -> channel -> abundance |
| [out] | best_charge | Selected charge state |
|
private |
Map (filename, channel) to its experimental-design cell.
| [in] | filename | The base filename (without path/extension) |
| [in] | channel_or_label | The channel/label identifier |
| Exception::MissingInformation | if the (filename, channel) pair is not in the experimental design |
| const PeptideQuant & getPeptideResults | ( | ) |
Get peptide abundance data.
| const ProteinQuant & getProteinResults | ( | ) |
Get protein abundance data.
|
private |
Map (filename, channel) to a sample using the precomputed design-cell lookup.
| [in] | filename | The base filename without path or extension |
| [in] | channel_or_label | The channel or label identifier |
| Exception::MissingInformation | if the (filename, channel) pair is not in the experimental design |
| const Statistics & getStatistics | ( | ) |
Get summary statistics.
| std::map< std::string, std::string > mapAccessionToLeader | ( | const OpenMS::ProteinIdentification & | proteins | ) | const |
|
private |
Normalize peptide abundances across assays by multiplicative scaling to equal medians.
|
inlineprivate |
Order keys according to how many assays they quantify, breaking ties by total abundance.
The keys of abundances are stored ordered in result, best first.
|
private |
Perform iBAQ normalization on protein abundances.
| [in] | proteins | Protein identification information containing sequences |
|
private |
Gather quantitative information from a feature.
Store quantitative information from feature in member pep_quant_, based on the peptide annotation in hit. fraction, use 0 for first fraction (or if no fractionation was performed) filename, the base filename (without path/extension) from which the feature originates channel_or_label, the channel/label identifier (e.g., TMT channel, typically 1 for LFQ) Channel identifiers originate from consensus map headers/experimental designs and are therefore non-negative. If hit is empty ("ambiguous/no annotation"), nothing is stored.
| void quantifyPeptides | ( | const PeptideIdentificationList & | peptides = PeptideIdentificationList() | ) |
Compute peptide abundances.
Based on quantitative data for individual charge states (in member pep_quant_), overall abundances for peptides are computed (and stored again in pep_quant_).
Quantitative data must first be read via readQuantData().
Optional (peptide-level) protein inference information (e.g. from Fido or ProteinProphet) can be supplied via peptides. In that case, peptide-to-protein associations - the basis for protein-level quantification - will also be read from peptides!
| void quantifyProteins | ( | const ProteinIdentification & | proteins = ProteinIdentification() | ) |
Compute protein abundances.
Peptide abundances must be computed first with quantifyPeptides(). Optional protein inference information (e.g. BasicProteinInference or Epifany) can be supplied via proteins.
| [in] | proteins | Optional protein inference information |
| void readQuantData | ( | ConsensusMap & | consensus, |
| const ExperimentalDesign & | ed | ||
| ) |
Read quantitative data from a consensus map.
Parameters should be set before using this method, as setting parameters will clear all results.
| void readQuantData | ( | FeatureMap & | features, |
| const ExperimentalDesign & | ed | ||
| ) |
Read quantitative data from a feature map.
Parameters should be set before using this method, as setting parameters will clear all results.
| void readQuantData | ( | std::vector< ProteinIdentification > & | proteins, |
| PeptideIdentificationList & | peptides, | ||
| const ExperimentalDesign & | ed | ||
| ) |
Read quantitative data from identification results (for quantification via spectral counting).
Parameters should be set before using this method, as setting parameters will clear all results.
|
staticprivate |
Select the fraction to keep for one fraction group, see 'fractions:aggregate' 'best'.
Ranked by the number of labels with a positive abundance, then by the total of those abundances. An exact tie keeps the lowest fraction number. The choice is made for the fraction group as a whole and never per label: taking one channel from one fraction and another channel from a different fraction would mix physical aliquots and destroy the reporter-ion ratios that isobaric quantification consists of.
| [in] | fraction_abundances | Mapping fraction -> label -> abundance of one fraction group |
| Exception::InvalidValue | if fraction_abundances is empty |
|
private |
Select peptides for protein quantification based on filtering criteria.
| [in] | protein_accession | The protein accession to select peptides for |
| [in] | top_n | Maximum number of peptides to select (0 = no limit) |
| [in] | fix_peptides | Whether to use consistent peptides across assays |
|
private |
Transfer peptide-level quantitative data to protein-level data structures.
This method populates prot_quant_ with peptide abundance and PSM count data.
| [in] | proteins | Protein identification information |
|
overrideprivatevirtual |
Clear all data when parameters are set.
Reimplemented from DefaultParamHandler.
|
private |
Charge selected per modified peptide when best_charge is enabled. Kept separately so detailed peptide output can retain all observed charge states.
|
private |
Precomputed lookup (basename without extension, channel/label) -> design coordinates, built once from experimental_design_ to avoid linear scans of the MS file section for every peptide/channel during aggregation. Pure lookup (never iterated), so an unordered map is used for O(1) access without affecting output.
|
private |
Experimental design for filename/channel to sample mapping.
|
private |
Peptide quantification data.
|
private |
Protein quantification data.
Fraction-group/label cells represented by the current quantification input. For a ConsensusMap this is the intersection of its column headers with the design, so design files that were not part of the map do not create invented zero-valued QPX quantities.
|
private |
Processing statistics for output in the end.