Peptide and protein quantitation using custom peptide ratios and protein-peptide mappings. More...
#include <ms_customquantitation.hpp>
Public Member Functions | |
ms_customquantitation (const ms_ms2quantitation ©From) | |
Given an ms_ms2quantitation object, copy the peptide-protein mappings, quantitation method and peptide ratios from it. | |
ms_customquantitation (const ms_peptidesummary &initFrom) | |
Given a results file, initialise peptide-protein mappings and the quantitation method from it. | |
ms_customquantitation (const ms_peptidesummary &initFrom, const ms_quant_method &qm) | |
Given a results file, initialise peptide-protein mappings from it, and prepare for data insertion using the given quantitation method. | |
ms_customquantitation (const ms_quant_method &qm) | |
Default constructor: given a quantitation method with protein ratio settings, prepare for data insertion. | |
virtual | ~ms_customquantitation () |
Destructor. | |
void | addHeaderField (const std::string &name, const std::string &value) |
Adds an item of project or search header information. | |
void | addPeptideQuantKey (const std::string &accession, int dbIdx, const ms_peptide_quant_key &key) |
Associate a protein accession with a peptide quant key. | |
void | addPeptideQuantKeys (const std::string &accession, int dbIdx, const ms_peptide_quant_key_vector &keys) |
Associate a protein accession with particular peptide quant keys. | |
void | addPeptideQuantKeys (const std::string &accession, int dbIdx, const std::vector< ms_peptide_quant_key > &keys) |
Associate a protein accession with particular peptide quant keys. | |
void | addPeptideRatio (const ms_peptide_quant_ratio &ratio) |
Add a new peptide ratio. | |
void | addRawFileField (const unsigned int id, const std::string &name, const std::string &value) |
Adds an item of raw file header information. | |
void | appendErrors (const ms_errors &src) |
Copies all errors from another instance and appends them at the end of own list. | |
void | clearAllErrors () |
Remove all errors from the current list of errors. | |
void | clearHeaderFields () |
Clears any header information from the result. | |
void | clearPeptideQuantKeys (const std::string &accession, int dbIdx) |
Clear all peptide quant key associations for a given protein. | |
void | clearPeptideRatios () |
Remove all peptide ratios. | |
void | clearRawFileFields () |
Clears any raw file header information from the result. | |
void | copyFrom (const ms_errors *right) |
Use this member to make a copy of another instance. | |
virtual int | countDistinctPeptides (const ms_peptide_quant_key_vector &activeKeys) const |
Get the number of distinct peptides in the list of active candidates. | |
virtual int | countDistinctPeptides (const std::vector< ms_peptide_quant_key > &activeKeys) const |
Get the number of distinct peptides in the list of active candidates. | |
const ms_errs * | getErrorHandler () const |
Retrive the error object using this function to get access to all errors and error parameters. | |
int | getLastError () const |
Return the error description of the last error that occurred. | |
std::string | getLastErrorString () const |
Return the error description of the last error that occurred. | |
ms_peptide_quant_key_vector | getPeptideQuantKeys (const std::string &accession, int dbIdx) const |
Look up peptide quant keys associated with a given protein, if any. | |
virtual ms_peptide_quant_ratio | getPeptideRatio (const ms_peptide_quant_key &key, const std::string &ratioName) const |
Given peptide quant key and ratio name, return the corresponding peptide ratio data. | |
double | getPeptideRatioNormalisationBase (const std::string &ratioName) const |
Get the peptide ratio normalisation base of the given ratio name. | |
const ms_progress_info & | getProgressInfo () |
Get information about the progress of a currently running long operation (e.g. loading from a file). | |
virtual ms_protein_quant_ratio | getProteinRatio (const std::string &accession, int dbIdx, const std::string &ratioName) const |
Given the protein accession, database ID and ratio name, return the protein ratio data. | |
virtual ms_protein_quant_ratio | getProteinRatio (const std::string &accession, int dbIdx, const std::string &ratioName, const ms_peptide_quant_key_vector &includeKeys, const ms_peptide_quant_key_vector &excludeKeys) const |
Given the protein accession, database ID and ratio name, return the protein ratio data, overriding the default inclusion and exclusion of the specified peptide quant keys. | |
const ms_quant_method & | getQuantitationMethod () const |
Return the current quantitation method. | |
double | getUnnormalisedAveragePeptideRatio (const std::string &ratioName, const std::string &averageType) const |
Calculate the unnormalised average peptide ratio. | |
double | getUnnormalisedAveragePeptideRatio (const std::string &ratioName, const std::string &averageType, const ms_peptide_quant_key_vector &keys) const |
Calculate the unnormalised average of selected peptide quant keys. | |
double | getUnnormalisedAveragePeptideRatio (const std::string &ratioName, const std::string &averageType, const std::string &accession, int dbIdx) const |
Calculate the unnormalised average of peptide quant keys of a protein accession. | |
virtual bool | hasPeptideRatio (const ms_peptide_quant_key &key, const std::string &ratioName) const |
Existence check: return true if a peptide ratio with the associated peptide quant key and ratio name exists. | |
virtual bool | isPeptideRatioExcluded (const ms_peptide_quant_key &key, const std::string &ratioName) const |
Boolean flag: is the given peptide ratio globally excluded from protein ratio calculation? | |
bool | isValid () const |
Call this function to determine if there have been any errors. | |
void | removePeptideQuantKey (const std::string &accession, int dbIdx, const ms_peptide_quant_key &key) |
Deassociate a peptide quant key from the given protein. | |
void | removePeptideRatio (const ms_peptide_quant_key &key, const std::string &ratioName) |
Remove a particular peptide ratio. | |
void | removePeptideRatioNormalisationBase (const std::string &ratioName) |
Reset the peptide ratio normalisation base of the given ratio name. | |
void | removePeptideRatioNormalisationBases () |
Reset all peptide ratio normalisation bases. | |
void | setMinNumPeptides (int value) |
Set the minimum number of peptides needed for protein ratio calculation. | |
virtual void | setPeptideRatioExcluded (const ms_peptide_quant_key &key, const std::string &ratioName) |
Globally exclude a particular peptide ratio from protein ratio calculation. | |
virtual void | setPeptideRatioIncluded (const ms_peptide_quant_key &key, const std::string &ratioName) |
Globally include a particular peptide ratio in protein ratio calculation. | |
void | setPeptideRatioNormalisationBase (const std::string &ratioName, double b) |
Set the peptide ratio normalisation base of the given ratio name. | |
virtual void | setProteinRatioType (const char *value) |
Set the protein ratio type. | |
virtual void | setQuantOutliers (const ms_quant_outliers *) |
Set new peptide ratio outlier settings. | |
Protected Member Functions | |
ms_protein_quant_ratio | calculateGeometricMeanRatio (const std::string &accession, int dbIdx, const std::string &ratioName, const std::vector< double > &sample, const std::vector< double > &logSample, const std::vector< ms_peptide_quant_key > &activeKeys, const std::map< ms_peptide_quant_key, int > &inactiveKeys, double normalityPvalue) const |
Given a sample of peptide ratios, calculate the geometric mean and standard deviation. | |
ms_protein_quant_ratio | calculateMedianRatio (const std::string &accession, int dbIdx, const std::string &ratioName, const std::vector< double > &sample, const std::vector< double > &logSample, const std::vector< ms_peptide_quant_key > &activeKeys, const std::map< ms_peptide_quant_key, int > &inactiveKeys, double normalityPvalue) const |
Given a sample of peptide ratios, calculate the median and standard deviation from the median. | |
ms_protein_quant_ratio | calculateWeightedGeometricMeanRatio (const std::string &accession, int dbIdx, const std::string &ratioName, const std::vector< double > &sample, const std::vector< double > &logSample, const std::vector< double > &weights, const std::vector< ms_peptide_quant_key > &activeKeys, const std::map< ms_peptide_quant_key, int > &inactiveKeys, double normalityPvalue) const |
Given a sample of peptide ratios, calculate the weighted geometric mean and standard deviation. | |
int | getMinNumPeptides () const |
Get the minimum number of peptides needed for protein ratio calculation. | |
void | getProteinRatioSample (const std::string &accession, int dbIdx, const std::string &ratioName, const std::vector< ms_peptide_quant_key > &includeKeys, const std::vector< ms_peptide_quant_key > &excludeKeys, std::vector< double > &sample, std::vector< double > &logSample, std::vector< double > &weights, std::vector< ms_peptide_quant_key > &activeKeys, std::map< ms_peptide_quant_key, int > &inactiveKeys, double &normalityPvalue) const |
Find the peptide quant keys associated with the protein, collect their unique peptide ratios, remove outliers (if desired) and return the values as the sample of peptide ratios. | |
virtual void | getSortedFinitePeptideRatioValues (const std::string &ratioName, const std::set< ms_peptide_quant_key > &keys, const std::set< ms_peptide_quant_key > &includeKeys, const std::set< ms_peptide_quant_key > &excludeKEys, std::vector< double > &values, std::vector< double > &weights, std::vector< ms_peptide_quant_key > &activeKeys, std::map< ms_peptide_quant_key, int > &inactiveKeys) const |
Given a list of q,p values and ratio name, find the non-infinite peptide ratio values and return them in numerically increasing order. | |
bool | initialiseBaseSettings (const ms_quant_method &qmBase, const ms_quant_method &qmConfig) |
Initialise quantitation method settings from the two method objects. | |
Protected Attributes | |
protein_to_peptide_quant_key_t | proteinKeys_ |
Protein-to-peptide mapping. | |
Peptide and protein quantitation using custom peptide ratios and protein-peptide mappings.
ms_customquantitation provides full read and write access to peptide ratios and protein-peptide mappings.
Protein ratios are calculated using the same algorithm as in ms_ms2quantitation. There are three types of ratio: median
, average
and weighted
. Median is the median of all peptide ratios associated with the protein hit, and average is the geometric mean (equivalently, the arithmetic mean of log-transformed peptide ratios). Weighted is the weighted geometric mean. The weighting factor of each peptide ratio must be specified when the peptide ratio is added to the class, and it can not depend on which protein the peptide ratio is associated with.
Note that the weighted ratio type is not the same as in ms_ms2quantitation, where the weights are derived automatically from the input query. In ms_customquantitation, any peptide ratio can have any user-specified weighting factor.
Choosing the right constructor reduces the amount of work you need to do. There are three general use cases:
(In the third case, the quantitation method need not correspond to any method defined in a Mascot Server installation.)
The three use cases are listed in order of increasing amount of work you need to do before getProteinRatio() returns useful values. There are two main steps: adding peptide ratios (addPeptideRatio()) and creating protein-peptide mappings (addPeptideQuantKeys()). Both steps are done for you in use case 1, only the second step is done for you in use case 2, and neither is done in use case 3.
The protein-related methods take two arguments to identify the protein: accession and database index. If your protein accessions come from a Mascot results file, use the database index returned by ms_protein::getDB() as database index.
If your data comes from somewhere else (e.g. an mzIdentML file), you can use any suitable integer for database index, as long as you are consistent with your choice. For example, if you know that all of your accessions are unique, you can simply use 0 as the database index.
ms_customquantitation supports normalisation, but it is less automatic than in ms_ms2quantitation. Normalisation settings in the quantitation method are ignored. Instead, you can set the normalisation factor of each ratio name with setPeptideRatioNormalisationBase(), with which peptide ratios associated with that ratio name are divided before returned by getPeptideRatio() or used in protein ratio calculation. To this end, you can use getUnnormalisedAveragePeptideRatio() to compute the mean or median of a given set of peptide ratios, peptide ratios associated with a protein hit, or all peptide ratios currently stored in the object.
|
explicit |
Default constructor: given a quantitation method with protein ratio settings, prepare for data insertion.
The quantitation method does not need to contain protocol settings, component definitions or peptide quality settings. (This is different from ms_ms2quantitation.) Only the following settings will be used by this class:
If none of these settings are defined, sensible defaults are used: ratio type "median", minimum number of peptides 1, no normalisation or outlier detection.
Note that all normalisation settings are ignored, although the configuration is copied in the current quantitation method object. See setPeptideRatioNormalisationBase().
After the object has been created, you need to add peptide ratios and protein-peptide mappings before protein ratios can be calculated. See addPeptideRatio() and addPeptideQuantKey().
Using the Average protocol: If quantitation protocol is Average, neither outlier removal nor normalisation are supported. If either one is configured in the quantitation method object, the constructor will terminate with an error. Use isValid() after creating the object to check for an error condition.
qm | Full or partial quantitation method describing how protein ratios are to be calculated. |
|
explicit |
Given a results file, initialise peptide-protein mappings and the quantitation method from it.
This is done in two steps. First, the following quantitation method settings are loaded from the results file, if available:
If none of these settings are available in the results file, sensible defaults are used: ratio type "median", minimum number of peptides 1, no normalisation or outlier detection.
Note that all normalisation settings are ignored, although the configuration is copied in the current quantitation method object. See setPeptideRatioNormalisationBase().
In the second step, the constructor iterates through all protein hits and creates a mapping from protein accessions to its peptide matches (peptide quant keys). After this, you need to add peptide ratios using addPeptideRatio(). Protein ratios can then be accessed with getProteinRatio().
Using the Average protocol: If quantitation protocol is Average, neither outlier removal nor normalisation are supported. If either one is configured in the embedded quantitation method object, the constructor will terminate with an error. Use isValid() after creating the object to check for an error condition.
initFrom | Mascot results to initialise from. Before creating the ms_peptidesummary object from the ms_mascotresfilebase object, call ms_mascotresfilebase::setXMLschemaFilePath() to set the locations of the XML schema to validate the embedded quantitation XML file against. |
ms_customquantitation | ( | const ms_peptidesummary & | initFrom, |
const ms_quant_method & | qm | ||
) |
Given a results file, initialise peptide-protein mappings from it, and prepare for data insertion using the given quantitation method.
The quantitation method does not need to contain protocol settings, component definitions or peptide quality settings. (This is different from ms_ms2quantitation.) Only the following settings will be used by this class:
If none of these settings are defined, sensible defaults are used: ratio type "median", minimum number of peptides 1, no normalisation or outlier detection.
Note that all normalisation settings are ignored. See setPeptideRatioNormalisationBase().
Note also that the protocol or component definitions of qm need not match those embedded in the results file, unlike in ms_ms2quantitation.
After initialising quantitation method settings, the constructor iterates through all protein hits and creates a mapping from protein accessions to its peptide matches (peptide quant keys). The peptide quant key for each peptide match is its q,p value; that is, the peptide quant keys are constructed with ms_peptide_quant_key(int q, int p).
You will need to add peptide ratios using addPeptideRatio(). Protein ratios can then be accessed with getProteinRatio().
Using the Average protocol: If quantitation protocol is Average, neither outlier removal nor normalisation are supported. If either one is configured in the quantitation method object, the constructor will terminate with an error. Use isValid() after creating the object to check for an error condition.
initFrom | Mascot results file to initialise peptide-protein mappings from. |
qm | Full or partial quantitation method describing how protein ratios are to be calculated. |
|
explicit |
Given an ms_ms2quantitation object, copy the peptide-protein mappings, quantitation method and peptide ratios from it.
The full quantitation method will be copied, although only the following values will be used by this class:
If none of these settings are defined, sensible defaults are used: ratio type "median", minimum number of peptides 1, no normalisation or outlier detection.
Two things are copied over from copyFrom: protein-peptide mappings for all toplevel protein accessions, and peptide ratios for all peptide quant keys associated with a protein hit. This means peptide ratios in the unassigned list will not be copied over. Copying is followed by setting peptide ratio normalisation to the correct values. You can access and change the values with getPeptideRatioNormalisationBase() and setPeptideRatioNormalisationBase() afterwards.
The peptide ratio and protein-peptide mapping peptide quant keys are constructed using ms_peptide_quant_key(int q, int p), and protein ratios are identified by the same accessions and database indices as in the source object.
The protein ratio type has one difference. Both classes implement median and average in the same way, but the weighted ratio type differs. If copyFrom contains Reporter data and specifies a weighted protein ratio, then protein ratio type is reset to median and the weights are not copied over. You can alter peptide ratio weighting factors later by overwriting the existing one with addPeptideRatio().
If copyFrom is not valid (ms_ms2quantitation::isValid() returns false), then no data importing will take place, and it is as if you called the parameterless constructor ms_customquantitation().
copyFrom | Fully initialised ms_ms2quantitation object to copy data from. |
void addPeptideQuantKey | ( | const std::string & | accession, |
int | dbIdx, | ||
const ms_peptide_quant_key & | key | ||
) |
Associate a protein accession with a peptide quant key.
A protein-peptide mapping is required for protein ratio calculation purposes. That is, each protein accession whose ratio you need must have at least one peptide quant key associated with it, and the peptide quant key must have a peptide ratio defined.
If key is already associated with this protein, no changes are made.
accession | Protein accession. |
dbIdx | Protein database index. |
key | Peptide quant key. |
void addPeptideQuantKeys | ( | const std::string & | accession, |
int | dbIdx, | ||
const ms_peptide_quant_key_vector & | keys | ||
) |
Associate a protein accession with particular peptide quant keys.
A protein-peptide mapping is required for protein ratio calculation purposes. That is, each protein accession whose ratio you need must have at least one peptide quant key associated with it, and the peptide quant key must have a peptide ratio defined.
Values in keys already associated with the protein are skipped.
accession | Protein accession. |
dbIdx | Protein database index. |
keys | Peptide quant keys. |
void addPeptideQuantKeys | ( | const std::string & | accession, |
int | dbIdx, | ||
const std::vector< ms_peptide_quant_key > & | keys | ||
) |
Associate a protein accession with particular peptide quant keys.
A protein-peptide mapping is required for protein ratio calculation purposes. That is, each protein accession whose ratio you need must have at least one peptide quant key associated with it, and the peptide quant key must have a peptide ratio defined.
Values in keys already associated with the protein are skipped.
accession | Protein accession. |
dbIdx | Protein database index. |
keys | Peptide quant keys. |
void addPeptideRatio | ( | const ms_peptide_quant_ratio & | ratio | ) |
Add a new peptide ratio.
If an existing peptide ratio exists with the same query, rank and ratio name as ratio.getQuery()
, ratio.getRank()
and ratio.getRatioName()
, it will be replaced with the new data.
If ratio represents an undefined ("missing") value, the peptide ratio will be removed, as if you had called removePeptideRatio() instead.
ratio | Peptide ratio to add. |
|
inherited |
Copies all errors from another instance and appends them at the end of own list.
src | The object to copy the errors across from. See Maintaining object references: two rules of thumb. |
|
protectedinherited |
Given a sample of peptide ratios, calculate the geometric mean and standard deviation.
accession | Protein accession. This is returned verbatim in the returned object and not used otherwise. |
dbIdx | Protein database index. This is returned verbatim in the returned object and not used otherwise. |
ratioName | Ratio name. This is returned verbatim in the returned object and not used otherwise. |
sample | Sample of peptide ratios in increasing numerical order. Sample size must be at least 1. |
logSample | Log transform of sample. |
normalityPvalue | The p-value that logSample looks normally distributed. |
activeKeys | Peptide quant keys for which sample values are present. |
inactiveKeys | Peptide quant keys ignored due to being skipped, excluded or detected as outliers. |
|
protectedinherited |
Given a sample of peptide ratios, calculate the median and standard deviation from the median.
See ms_quant_stats::sortedMedian for details of how this is calculated.
accession | Protein accession. This is returned verbatim in the returned object and not used otherwise. |
dbIdx | Protein database index. This is returned verbatim in the returned object and not used otherwise. |
ratioName | Ratio name. This is returned verbatim in the returned object and not used otherwise. |
sample | Sample of peptide ratios in increasing numerical order. Sample size must be at least 1. |
logSample | Log transform of sample. |
normalityPvalue | The p-value that logSample looks normally distributed. |
activeKeys | Peptide quant keys for which sample values are present. |
inactiveKeys | Peptide quant keys ignored due to being skipped, excluded or detected as outliers. |
|
protectedinherited |
Given a sample of peptide ratios, calculate the weighted geometric mean and standard deviation.
accession | Protein accession. This is returned verbatim in the returned object and not used otherwise. |
dbIdx | Protein database index. This is returned verbatim in the returned object and not used otherwise. |
ratioName | Ratio name. This is returned verbatim in the returned object and not used otherwise. |
sample | Sample of peptide ratios in increasing numerical order. Sample size must be at least 1. |
logSample | Log transform of sample. |
weights | Weighting factors corresponding to the order of sample (and logSample). |
normalityPvalue | The p-value that logSample looks normally distributed. |
activeKeys | Peptide quant keys for which sample values are present. |
inactiveKeys | Peptide quant keys ignored due to being skipped, excluded or detected as outliers. |
|
inherited |
Remove all errors from the current list of errors.
The list of 'errors' can include fatal errors, warning messages, information messages and different levels of debugging messages.
All messages are accumulated into a list in this object, until clearAllErrors() is called.
See Error Handling.
void clearPeptideQuantKeys | ( | const std::string & | accession, |
int | dbIdx | ||
) |
Clear all peptide quant key associations for a given protein.
After this, getProteinRatio() will return a ratio with state isMissing() when given accession, dbIdx and any ratio name.
accession | Protein accession. |
dbIdx | Protein database index. |
void clearPeptideRatios | ( | ) |
Remove all peptide ratios.
This method also removes all q,p aliases of peptide ratios. However, the peptide-protein mapping will not be changed.
|
inherited |
Use this member to make a copy of another instance.
right | is the source to initialise from |
|
virtualinherited |
Get the number of distinct peptides in the list of active candidates.
The base class ms_quantitation does not have enough infomation about the peptides associated with each ms_peptide_quant_key to determine if they are truly distinct. By default, the number of distinct peptides is the number of elements in activeKeys.
In ms_ms1quantitation and ms_ms2quantitation, peptides are treated as distinctly different only if they have a difference in their peptide string.
This function just calls countDistinctPeptides() relevant to the implementing class (ms_ms1quantitation or ms_ms2quantitation).
activeKeys | Peptide quant keys that are included in the quantitation of a protein. |
Reimplemented in ms_ms1quantitation, and ms_ms2quantitation.
|
virtualinherited |
Get the number of distinct peptides in the list of active candidates.
The base class ms_quantitation does not have enough infomation about the peptides associated with each ms_peptide_quant_key to determine if they are truly distinct. By default, the number of distinct peptides is the number of elements in activeKeys.
In ms_ms1quantitation and ms_ms2quantitation, peptides are treated as distinctly different only if they have a difference in their peptide string.
activeKeys | Peptide quant keys that are included in the quantitation of a protein. |
Reimplemented in ms_ms1quantitation, ms_ms1quantitation, ms_ms2quantitation, and ms_ms2quantitation.
|
inherited |
Retrive the error object using this function to get access to all errors and error parameters.
See Error Handling.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
|
inherited |
Return the error description of the last error that occurred.
All errors are accumulated into a list in this object, until clearAllErrors() is called. This function returns the last error that occurred.
See Error Handling.
|
protectedinherited |
Get the minimum number of peptides needed for protein ratio calculation.
|
inherited |
Look up peptide quant keys associated with a given protein, if any.
In ms_ms2quantitation, the list of peptide quant keys associated with the given protein is immutable, as the keys are derived from q,p values in the Mascot results file. The list does not contain all q,p values, but only those that 1) have component intensities and 2) pass the quality thresholds. Unless the data quality is extremely good, this list will always have fewer elements than the actual peptide matches assigned to the protein hit.
In ms_customquantitation, the peptide-to-protein mapping can be altered with ms_customquantitation::addPeptideQuantKey() and ms_customquantitation::removePeptideQuantKey().
accession | The protein accession. |
dbIdx | The protein database index. |
|
virtual |
Given peptide quant key and ratio name, return the corresponding peptide ratio data.
Often, most peptide matches in a Mascot results file have no ratio data. For example, the peptide match could be non-significant or not quantitable (quality check fails); or with Reporter or Multiplex protocol, the MS/MS spectrum may not contain all component intensities required for ratio calculation.
If hasPeptideRatio(const ms_peptide_quant_key&, std::string) const returns false for the given peptide quant key and ratio name, then the peptide ratio object returned by this method represents an undefined ("missing") value.
Using the Average protocol in ms_customquantitation: If quantitation protocol is Average, peptide ratios are interpreted as raw intensity values. It is usually meaningless to define more than one ratio name in this case.
key | The peptide quant key of the peptide ratio. |
ratioName | The name of the ratio. |
Implements ms_quantitation.
|
inherited |
Get the peptide ratio normalisation base of the given ratio name.
Using the Average protocol in ms_customquantitation: If quantitation protocol is Average, peptide ratio normalisation has no meaning. It is strongly recommended to not set normalisation constants.
ratioName | Peptide ratio name. |
|
inherited |
Get information about the progress of a currently running long operation (e.g. loading from a file).
|
virtual |
Given the protein accession, database ID and ratio name, return the protein ratio data.
Protein ratios are calculated on demand from the current protein-peptide mapping using the current quantitation method and taking peptide exclusion into account. You can exclude peptides from protein ratio calculation by using setPeptideRatioExcluded(). The current outlier detection method may also change which peptide ratios are used for any given protein.
For ms_ms2quantitation, the protein-peptide mapping is immutable. There are three types of protein ratio, which can be changed with setProteinRatioType(): median
, average
and weighted
. Median is the median of all peptide ratios associated with the protein hit, and average is the geometric mean (equivalently, the arithmetic mean of log-transformed peptide ratios). Weighted is a weighted mean of peptide ratios, where the weights are channel intensities. The weighted ratio type is only available for Reporter data.
For ms_customquantitation, you can change the protein-peptide mapping by associating different peptide quant keys with the protein accession; see ms_customquantitation::addPeptideQuantKey() for details. There are three types of protein ratio: median
, average
and weighted
. Median and average are the same as in ms_ms2quantitation, except in the Average protocol (see below). Weighted is the weighted geometric mean, where the weighting factor of each peptide ratio must be specified when the peptide ratio is added to the class. This is not the same weighting as in ms_ms2quantitation.
ms1, ms2 and custom protein ratios are calculated using:
It is possible for the protein ratio to be undefined ("missing") even when it has associated peptide ratios, if there are not enough peptide ratios (setMinNumPeptides()), if all of them are marked excluded, or if too many of them are infinite.
If quantitation protocol is Reporter, Multiplex, Replicate or Precursor, the returned protein ratio object contains two p-values: the normality test value and the null hypothesis value.
The log-transformed peptide ratios are assumed normally distributed, and this hypothesis is tested using the Shapiro-Wilk W test. The normality p-value is -1 when the test could not be run (e.g. too few peptide ratios) and otherwise a positive number between 0 and 1. In the latter case, a value of less than 0.05 (or similar threshold) is usually taken as evidence that the log-transformed peptide ratios are not normally distributed, or equivalently that the peptide ratios are not log-normally distributed.
If outlier removal is configured, then outliers will be removed before normality testing. If this makes the normality p-value fall below 0.05, then the outliers will be restored. In this case the original sample was likely not normal to start with, and the normality p-value is calculated based on the original sample. If outlier removal is successful, then the normality p-value is based on the sample from which outliers have been removed, and it always exceeds 0.05.
The second p-value is for the null hypothesis. The null hypothesis is that the protein ratio equals 1.0 (component intensities have equal values). The p-value is -1 if there is only one peptide ratio, and otherwise a positive number between 0 and 1. The test is conducted after outlier removal, if any.
Note that the hypothesis test is done regardless of the p-value of the normality test. This means that you need to decide first if you accept peptide ratio normality before deciding whether to reject or not reject the null hypothesis. If normality is violated, then the hypothesis p-value is meaningless.
You can inspect which peptide quant keys were used in protein ratio calculation and which were ignored, due to being excluded or being outliers, with ms_protein_quant_ratio::getActiveKeys(), ms_protein_quant_ratio::getExcludedKeys() and ms_protein_quant_ratio::getOutlierKeys(). You can "move" peptide quant keys between the last two categories and the first by using the method getProteinRatio(const std::string &, int, const std::string &, const ms_peptide_quant_key_vector &, const ms_peptide_quant_key_vector &) const.
Note about weighted protein ratios: Parser 2.5 and 2.6 do not calculate the standard deviation, standard error or p-values when protein ratio type is weighted in Reporter data. The values are set to -1 ("unavailable"); see ms_protein_quant_ratio::getStandardDeviation(). The values are available in ms_customquantitation, which uses a different weighting formula.
Using the Average protocol in ms_customquantitation: If quantitation protocol is Average, the only supported protein ratio type is "average", which does not mean a geometric average. Rather, the protein ratio is the sum of the "top N" peptide intensities, divided by the sum of the top N peptide intensities of the reference protein (see ms_customquantitation::setAverageReferenceProtein()). Neither outlier removal nor normalisation have any meaning in this protocol, which means no significance tests are done and the returned protein ratio object will not contain any p-values.
For more details on configuring other aspects of protein ratio calculation, please consult the quantitation help pages.
accession | The protein accession. |
dbIdx | The protein database index. |
ratioName | The name of the ratio. |
Implements ms_quantitation.
Reimplemented in ms_ms1quantitation.
|
virtual |
Given the protein accession, database ID and ratio name, return the protein ratio data, overriding the default inclusion and exclusion of the specified peptide quant keys.
The protein ratio is calculated as described in getProteinRatio(const std::string &, int, const std::string &) const, but the two peptide quant key vectors includeKeys and excludeKeys can be used to override default decisions about globally excluded and outlier peptide ratios. The rules are as follows:
If the peptide quant key is in both includeKeys and excludeKeys, the latter takes precedence and the peptide quant key is excluded.
Note that if outlier detection is enabled, then a peptide quant key determined to be an outlier cannot be included back using includeKeys, i.e. the inclusion mechanism does not undo outlier removal. You can disable outlier removal entirely before calling getProteinRatio() if you do not want peptide quant keys to be removed.
Using the Average protocol in ms_customquantitation: If quantitation protocol is Average, then the effect of excludeKeys depends on whether the peptide quant key describes a "top N" peptide intensity. If the peptide intensity is one of the top N intensities assigned to this protein, then excluding it means the next highest outside the top N intensities will take its place. No peptide quant keys will ever be excluded automatically as outliers, since outlier removal has no meaning in this protocol.
accession | The protein accession. |
dbIdx | The protein database index. |
ratioName | The name of the ratio. |
includeKeys | Peptide quant keys to always include, even if they are globally excluded or would be marked as outliers. |
excludeKeys | Peptide quant keys to always exclude, even if they are not outliers. |
Implements ms_quantitation.
Reimplemented in ms_ms1quantitation.
|
protectedinherited |
Find the peptide quant keys associated with the protein, collect their unique peptide ratios, remove outliers (if desired) and return the values as the sample of peptide ratios.
This method uses getSortedFinitePeptideRatioValues() internally to collect the vector of peptide ratios. If there are no peptide quant keys associated with the protein, or if no peptide ratios are associated with with those peptide quant keys, then sample, logSample, activeKeys and inactiveKeys will be empty and normalityPvalue will have an undefined value.
accession | Protein accession. |
dbIdx | Protein database index. |
ratioName | Name of the ratio. |
includeKeys | Prevent these peptide quant keys from being excluded. |
excludeKeys | Prevent these peptide quant keys from being included. |
sample | Peptide ratios associated with ratioName and the protein's peptide quant keys, in numerically increasing order. |
logSample | Log transform of sample. |
weights | Weighting factors corresponding to the order of sample (and logSample). |
activeKeys | Peptide quant keys corresponding to the order of sample (and logSample). |
inactiveKeys | Peptide quant keys marked as skipped, excluded or outlier. |
normalityPvalue | The p-value that the sample appears to be normally distributed after outlier removal. If less than 0.05, no outliers will have been removed. |
|
inherited |
Return the current quantitation method.
The current (or effective) quantitation method is the original quantitation method given as argument to the constructor (or loaded from the Mascot results file), with possible later modifications, such as changing normalisation or outlier settings.
For ms_ms2quantitation, you cannot change the protocol settings, component definitions or peptide quality settings. You must create a new object with the new settings instead. You are free to change how protein ratios are calculated and set new normalisation parameters. These changes will be reflected in this method's output value.
For ms_customquantitation, same restrictions apply, although it makes little difference, as the class does not use any protocol settings, component definitions or peptide quality settings.
|
protectedvirtual |
Given a list of q,p values and ratio name, find the non-infinite peptide ratio values and return them in numerically increasing order.
The method looks up all peptide ratios associated with keys (ignoring duplicates) and returns them in numerically increasing order in values. Infinite and missing ratios are ignored. The vector activeKeys contains active peptide quant keys in the same order as values, and the map inactiveKeys contains peptide quant keys associated with the protein ratio but for indicated reasons not included in ratio calculation.
ratioName | The name of the peptide ratio. |
keys | A list of (sorted or unsorted) peptide quant keys for which to look up the ratios. |
includeKeys | Prevent these peptide quant keys from being excluded. |
excludeKeys | Prevent these peptide quant keys from being included. |
values | Peptide ratios associated with ratioName and the given peptide quant keys. |
weights | Weighting factors of corresponding to the order of values. |
activeKeys | Peptide quant keys corresponding to the order of values. |
inactiveKeys | Peptide quant keys skipped or excluded. |
Implements ms_quantitation.
double getUnnormalisedAveragePeptideRatio | ( | const std::string & | ratioName, |
const std::string & | averageType | ||
) | const |
Calculate the unnormalised average peptide ratio.
All peptide ratios currently stored in the object are used in calculation. If there are no peptide ratios associated with the ratio name, the method returns 1.0. Negative and infinite values are ignored.
averageType determines the kind of average to compute. Allowed values are described in Type mqm:normaliseType, except that "sum" is not supported. If the kind is "none" or an unsupported value, the method returns 1.0.
Using the Average protocol: If quantitation protocol is average, normalisation has no meaning. It is still possible to get a geometric mean or median of all peptide intensities, but you should not use it for normalisation purposes.
ratioName | Peptide ratio name. |
averageType | Peptide ratio normalisation type; one of Type mqm:normaliseType. |
double getUnnormalisedAveragePeptideRatio | ( | const std::string & | ratioName, |
const std::string & | averageType, | ||
const ms_peptide_quant_key_vector & | keys | ||
) | const |
Calculate the unnormalised average of selected peptide quant keys.
All peptide ratios matching ratioName and whose peptide quant key is in keys are chosen for calculation. If there are no such peptide ratios, the method returns 1.0. Negative and infinite values are ignored.
averageType determines the kind of average to compute. Allowed values are described in Type mqm:normaliseType, except that "sum" is not supported. If the kind is "none" or an unsupported value, the method returns 1.0.
Using the Average protocol: If quantitation protocol is average, normalisation has no meaning. It is still possible to get a geometric mean or median of all peptide intensities, but you should not use it for normalisation purposes.
ratioName | Peptide ratio name. |
averageType | Peptide ratio normalisation type; one of Type mqm:normaliseType. |
keys | Peptide quant keys of peptide ratios to use in calculation. |
double getUnnormalisedAveragePeptideRatio | ( | const std::string & | ratioName, |
const std::string & | averageType, | ||
const std::string & | accession, | ||
int | dbIdx | ||
) | const |
Calculate the unnormalised average of peptide quant keys of a protein accession.
All peptide ratios matching ratioName and associated with the protein accession and database index are chosen for calculation. If there are no such peptide ratios, the method returns 1.0. Negative and infinite values are ignored. You can alter the protein-peptide mapping with addPeptideQuantKey().
averageType determines the kind of average to compute. Allowed values are described in Type mqm:normaliseType, except that "sum" is not supported. If the kind is "none" or an unsupported value, the method returns 1.0.
Using the Average protocol: If quantitation protocol is average, normalisation has no meaning. It is still possible to get a geometric mean or median of all peptide intensities, but you should not use it for normalisation purposes.
ratioName | Peptide ratio name. |
averageType | Peptide ratio normalisation type; one of Type mqm:normaliseType. |
accession | Protein accession. |
dbIdx | Protein database index. |
|
virtual |
Existence check: return true if a peptide ratio with the associated peptide quant key and ratio name exists.
Often, most peptide matches in a Mascot results file have no ratio data. For example, the peptide match could be non-significant or not quantitable (quality check fails); or with Reporter or Multiplex protocol, the MS/MS spectrum may not contain all component intensities required for ratio calculation.
Using the Average protocol in ms_customquantitation: If quantitation protocol is Average, peptide ratios are interpreted as raw intensity values. It is usually meaningless to define more than one ratio name in this case.
key | The peptide quant key of the peptide ratio. |
ratioName | The name of the ratio. |
Implements ms_quantitation.
|
protectedinherited |
Initialise quantitation method settings from the two method objects.
For any method settings which are not consistent between the passed qmBase and qmConfig, the values from qmConfig will be used.
qmBase | The base quantitation method as defined on the Mascot server. |
qmConfig | The quantitation method to use to calculate quantitation results using. |
|
virtual |
Boolean flag: is the given peptide ratio globally excluded from protein ratio calculation?
(This method is redundant; you could also look up the peptide ratio and use ms_peptide_quant_ratio::isExcluded().)
key | The peptide quant key of the peptide ratio. |
ratioName | The name of the ratio. |
Implements ms_quantitation.
|
inherited |
Call this function to determine if there have been any errors.
This will return true unless there have been any fatal errors.
See Error Handling.
void removePeptideQuantKey | ( | const std::string & | accession, |
int | dbIdx, | ||
const ms_peptide_quant_key & | key | ||
) |
Deassociate a peptide quant key from the given protein.
accession | Protein accession. |
dbIdx | Protein database index. |
key | Peptide quant key. |
void removePeptideRatio | ( | const ms_peptide_quant_key & | key, |
const std::string & | ratioName | ||
) |
Remove a particular peptide ratio.
However, the protein-peptide mapping related to the peptide quant key will not be changed.
key | Peptide quant key. |
ratioName | Ratio name. |
|
inherited |
Reset the peptide ratio normalisation base of the given ratio name.
Resetting means the report ratio normalisation constant is set to 1.0. This has the same effect as calling setPeptideRatioNormalisationBase() with b = 1
.
In ms_ms2quantitation, resetting a normalisation constant is possible even if normalisation settings have been configured with setQuantNormalisation() and normalisePeptideRatios() has been called. It is generally not a good idea to reset normalisation bases, because it will lead to inconsistent peptide ratios.
ratioName | Ratio name whose normalisation base is to be reset. |
|
inherited |
Reset all peptide ratio normalisation bases.
Resetting all report ratio normalisation bases means all peptide and protein ratios become unnormalised.
In ms_ms2quantitation, resetting a normalisation constant is possible even if normalisation settings have been configured with setQuantNormalisation() and normalisePeptideRatios() has been called. It is generally not a good idea to reset normalisation bases, because it will lead to inconsistent peptide ratios.
|
inherited |
Set the minimum number of peptides needed for protein ratio calculation.
Changing the minimum number of peptides changes the current quantitation method. It does not alter the original quantitation method object.
Using the Average protocol in ms_customquantitation: The Average protocol has two settings for minimum number of peptides. This setting defines how many peptide intensities are needed for a protein before its ratio can be calculated. It is usually meaningless to choose a value other than 1. Use ms_customquantitation::setAverageNumPeptides() to define how many intensities should be used in protein ratio calculation.
value | The minimum number of peptide ratios (the sample size) a protein must have for protein ratio calculation purposes. Values less than 1 are interpreted as 1. |
|
virtual |
Globally exclude a particular peptide ratio from protein ratio calculation.
All peptide matches associated with a protein ratio are used in calculating that protein's ratio, assuming the peptide ratio passes outlier testing (if used). This may not be desirable in some cases; for example, visual inspection could indicate the peptide match is incorrect. You can use setPeptideRatioExcluded() and setPeptideRatioIncluded() to globally exclude or include individual peptide ratios.
key | The peptide quant key of the peptide ratio. |
ratioName | The name of the ratio. |
Implements ms_quantitation.
|
virtual |
Globally include a particular peptide ratio in protein ratio calculation.
All peptide matches associated with a protein ratio are used in calculating that protein's ratio, assuming the peptide ratio passes outlier testing (if used). This may not be desirable in some cases; for example, visual inspection could indicate the peptide match is incorrect. You can use setPeptideRatioExcluded() and setPeptideRatioIncluded() to globally exclude or include individual peptide ratios.
key | The peptide quant key of the peptide ratio. |
ratioName | The name of the ratio. |
Implements ms_quantitation.
|
inherited |
Set the peptide ratio normalisation base of the given ratio name.
Setting peptide ratio normalisation to a particular value means all peptide ratios with ratioName will be divided by b before they are returned by getPeptideRatio(). That is, the underlying peptide ratios remain unaffected, which means this method will always return immediately without computing anything.
In ms_ms2quantitation, normalisation constants can most easily be calculated with ms_ms2quantitation::normalisePeptideRatios(), if normalisation is enabled and configured in the quantitation method. You are free to override this, but keeping track of who calculated which constant is up to you.
It is not a good idea to define both peptide ratio normalisation and component intensity normalisation at the same time. In fact, you can only configure one or the other using setQuantNormalisation(), and neither normalisePeptideRatios() nor normaliseIntensities() will step on each other's toes.
It is possible, but not recommended, to manually set normalisation bases for both peptide ratios and component intensities. The resulting peptide ratios are most likely meaningless.
In ms_customquantitation, you can use ms_customquantitation::getUnnormalisedAveragePeptideRatio() to calculate the mean or median of peptide ratios currently stored in the class, for normalisation purposes.
You can always set b to 1 to disable peptide ratio ratioName normalisation.
Using the Average protocol in ms_customquantitation: If quantitation protocol is Average, peptide ratio normalisation has no meaning. It is strongly recommended to not set normalisation constants.
ratioName | Peptide ratio name to normalise. |
b | New normalisation base. If it is zero, the old base will be kept. If this is the first time the base is set, a value of 0 means it is set to 1.0. |
|
virtual |
Set the protein ratio type.
Changing the protein ratio type changes the current quantitation method. It does not alter the original quantitation method object.
ms_ms2quantitation supports "median", "average" and "weighted", and ms_customquantitation supports "median" and "average. If the ratio type is not implemented, it is set to "median". <strong>Using the Average protocol in ms_customquantitation</strong>: If quantitation protocol is Average, the only supported protein ratio type is "average". Setting it to anything else will result in an error. You should inspect isValid() and use clearAllErrors() should you accidentally do so.
value | Protein ratio type (e.g. median, average, weighted). Accepted values are defined in the quantitation XML schema. |
Implements ms_quantitation.
|
virtual |
Set new peptide ratio outlier settings.
Peptide ratio outlier detection can be configured in several ways. Please consult the quantitation configuration help page for details.
Changing outlier settings changes the current quantitation method. It does not alter the original quantitation method object.
Using the Average protocol in ms_customquantitation: It is an error to define outlier removal if quantitation protocol is Average. You will need to inspect isValid() and clear the error with clearAllErrors() should you accidentally do so.
qo | An outlier configuration object. If this is NULL , outlier detection will be disabled (equivalent to "none"). |
Implements ms_quantitation.