OpenMS
Loading...
Searching...
No Matches
ConfidenceScoring Class Reference

Confidence scoring for SRM/MRM/PRM features against a targeted assay library. More...

#include <OpenMS/ANALYSIS/OPENSWATH/ConfidenceScoring.h>

Inheritance diagram for ConfidenceScoring:
[legend]
Collaboration diagram for ConfidenceScoring:
[legend]

Classes

struct  GLM_
 Binomial GLM used to map (squared-normalised-RT-diff, intensity-distance) -> [0, 1] confidence. More...
 
struct  RTNorm_
 Map RT values into the [0, 100] interval using min/max RT of the assay library. More...
 

Public Member Functions

 ConfidenceScoring (bool test_mode_=false)
 Construct an empty scorer.
 
 ~ConfidenceScoring () override
 Destructor.
 
void initialize (const TargetedExperiment &library, const Size n_decoys, const Size n_transitions, const TransformationDescription &rt_trafo)
 Install the configuration needed before scoreMap() can run.
 
void initializeGlm (double intercept, double rt_coef, double int_coef)
 Install the GLM coefficients fitted externally on a training set.
 
void scoreMap (FeatureMap &features)
 Score every feature in features in place, writing per-feature scores and an updated overall-quality value.
 
- Public Member Functions inherited from ProgressLogger
 ProgressLogger ()
 Constructor.
 
virtual ~ProgressLogger ()
 Destructor.
 
 ProgressLogger (const ProgressLogger &other)
 Copy constructor.
 
ProgressLoggeroperator= (const ProgressLogger &other)
 Assignment Operator.
 
void setLogType (LogType type) const
 Sets the progress log that should be used. The default type is NONE!
 
LogType getLogType () const
 Returns the type of progress log being used.
 
void setLogger (ProgressLoggerImpl *logger)
 Sets the logger to be used for progress logging.
 
void startProgress (SignedSize begin, SignedSize end, const std::string &label) const
 Initializes the progress display.
 
void setProgress (SignedSize value) const
 Sets the current progress.
 
void endProgress (UInt64 bytes_processed=0) const
 
void nextProgress () const
 increment progress by 1 (according to range begin-end)
 

Protected Member Functions

void chooseDecoys_ ()
 Permute decoy_index_ in place to pick a fresh random decoy sample for the next feature.
 
double manhattanDist_ (DoubleList x, DoubleList y)
 Manhattan (L1) distance between two equal-length vectors.
 
double getAssayRT_ (const TargetedExperiment::Peptide &assay)
 Read the (single) retention time from an assay's TargetedExperiment::Peptide; the assay is required to have an RT set (checked in debug builds)
 
double scoreAssay_ (const TargetedExperiment::Peptide &assay, double feature_rt, DoubleList &feature_intensities, const std::set< std::string > &transition_ids=std::set< std::string >())
 Score one feature against one candidate assay.
 
void scoreFeature_ (Feature &feature)
 Score one feature against its matching assay plus a random decoy sample; writes the per-assay scores into feature's MetaValues.
 

Protected Attributes

struct OpenMS::ConfidenceScoring::GLM_ glm_
 
struct OpenMS::ConfidenceScoring::RTNorm_ rt_norm_
 
TargetedExperiment library_
 Targeted-assay library: one peptide per assay, each with its transitions.
 
IntList decoy_index_
 Indexes into library_.getPeptides() used as decoys for the current feature.
 
Size n_decoys_
 Number of decoy assays to sample per feature (0 = use all unrelated assays as decoys)
 
std::map< std::string, IntListtransition_map_
 Lookup assay-id -> indexes into library_.getTransitions()
 
Size n_transitions_
 Number of top-intensity transitions to keep when computing the intensity-distance term (0 = keep all)
 
TransformationDescription rt_trafo_
 Optional RT transformation applied to measured feature RTs before comparison with library RTs.
 
Math::RandomShuffler shuffler_
 Random shuffler used to draw decoy samples (seed depends on test mode — see ctor)
 
- Protected Attributes inherited from ProgressLogger
LogType type_
 
time_t last_invoke_
 
ProgressLoggerImplcurrent_logger_
 

Additional Inherited Members

- Public Types inherited from ProgressLogger
enum  LogType { CMD , GUI , NONE }
 Possible log types. More...
 
- Static Protected Attributes inherited from ProgressLogger
static int recursion_depth_
 

Detailed Description

Confidence scoring for SRM/MRM/PRM features against a targeted assay library.

For each detected feature the algorithm scores the feature against

  • the matching true assay (referenced by the feature's PeptideRef MetaValue), and
  • a random sample of decoy assays (randomly chosen non-matching assays from the same library) used to estimate the score distribution under the null hypothesis.

The per-assay score is the output of a binomial GLM (see GLM_) on two features derived from the feature/assay pair:

  • the difference between the feature's RT and the assay's library RT, after normalisation to the 0–100 range (see RTNorm_); the GLM itself applies the square (its rt_coef multiplies diff_rt*diff_rt).
  • the Manhattan distance between the feature's transition-intensity vector and the assay's expected transition-intensity vector (intensities matched by Q3 m/z).

Initialisation flow:

  1. initialize() — install the library, decoy count, transition count, and RT transform.
  2. initializeGlm() — install the pre-fitted GLM coefficients (intercept / RT² / intensity).
  3. scoreMap() — iterate all features in the input FeatureMap and write the per-feature scoring result back (see scoreMap() for the exact MetaValue set + overall-quality update).

Feature → assay matching is by MetaValue: each feature must carry a "PeptideRef" string (the assay id), and each subordinate (one per transition) must carry a "native_id" string matching a transition id from the library.

Constructor & Destructor Documentation

◆ ConfidenceScoring()

ConfidenceScoring ( bool  test_mode_ = false)
explicit

Construct an empty scorer.

Parameters
[in]test_mode_If true, seed the internal random shuffler with time(NULL) so that decoy selection is deterministic only within a single process run. If false (default), seed with 0 for fully reproducible decoy draws across runs and platforms.

◆ ~ConfidenceScoring()

~ConfidenceScoring ( )
inlineoverride

Destructor.

Member Function Documentation

◆ chooseDecoys_()

void chooseDecoys_ ( )
protected

Permute decoy_index_ in place to pick a fresh random decoy sample for the next feature.

◆ getAssayRT_()

double getAssayRT_ ( const TargetedExperiment::Peptide assay)
protected

Read the (single) retention time from an assay's TargetedExperiment::Peptide; the assay is required to have an RT set (checked in debug builds)

◆ initialize()

void initialize ( const TargetedExperiment library,
const Size  n_decoys,
const Size  n_transitions,
const TransformationDescription rt_trafo 
)
inline

Install the configuration needed before scoreMap() can run.

Parameters
[in]libraryTargeted-assay library; must have at least 2 peptides for scoring to be defined.
[in]n_decoysNumber of decoy assays to sample per feature (clamped to all-available if larger, with warning).
[in]n_transitionsNumber of top-intensity transitions to keep when computing the intensity-distance term; 0 keeps all.
[in]rt_trafoRT transformation applied to feature RTs before comparison against library RTs.

◆ initializeGlm()

void initializeGlm ( double  intercept,
double  rt_coef,
double  int_coef 
)
inline

Install the GLM coefficients fitted externally on a training set.

Coefficients correspond to the GLM_ formula \(\mathrm{sigmoid}(\mathrm{intercept} + \mathrm{rt\_coef} \cdot \Delta\mathrm{RT}^2 + \mathrm{int\_coef} \cdot d_\mathrm{int})\).

Parameters
[in]interceptGLM intercept term.
[in]rt_coefCoefficient on \(\Delta\mathrm{RT}^2\) (using normalised RT in [0, 100]).
[in]int_coefCoefficient on the Manhattan intensity distance.

◆ manhattanDist_()

double manhattanDist_ ( DoubleList  x,
DoubleList  y 
)
protected

Manhattan (L1) distance between two equal-length vectors.

◆ scoreAssay_()

double scoreAssay_ ( const TargetedExperiment::Peptide assay,
double  feature_rt,
DoubleList feature_intensities,
const std::set< std::string > &  transition_ids = std::set< std::string >() 
)
protected

Score one feature against one candidate assay.

Reduces the assay's transitions to those listed in transition_ids (or all if the set is empty), matches them up with the feature's transition intensities by Q3 m/z, computes the Manhattan distance on the resulting paired intensity vectors, evaluates the GLM on (RT² diff, intensity distance) and returns the GLM output in [0, 1].

Parameters
[in]assayCandidate assay (true or decoy).
[in]feature_rtFeature retention time after rt_trafo_ and rt_norm_.
[in,out]feature_intensitiesFeature's transition intensities; reordered to match the assay's transition list.
[in]transition_idsOptional subset of transition ids to consider; empty means "use all transitions of the assay".
Returns
GLM-derived score in [0, 1].

◆ scoreFeature_()

void scoreFeature_ ( Feature feature)
protected

Score one feature against its matching assay plus a random decoy sample; writes the per-assay scores into feature's MetaValues.

◆ scoreMap()

void scoreMap ( FeatureMap features)
inline

Score every feature in features in place, writing per-feature scores and an updated overall-quality value.

Prerequisite: both initialize and initializeGlm must have been called first.

The input contract is:

  • features each carry the assay id in MetaValue "PeptideRef".
  • Each feature has one Feature::getSubordinates entry per assay transition, each carrying the transition id in MetaValue "native_id".
  • The targeted-assay library initialize() was called with must contain at least 2 peptides; the function throws Exception::IllegalArgument otherwise.

Per-feature side effects:

  • MetaValue "GLM_score" is set to the GLM score against the true assay.
  • MetaValue "local_FDR" is set to the rank-based local FDR estimated against the per-feature decoy scores.
  • The feature's overall quality is set to 1.0 - local_FDR.

Other side effects:

  • The library's RT range is computed here and cached in rt_norm_.
  • If n_decoys_ exceeds the number of unrelated assays in the library, it is clamped to 0 (= use all available assays as decoys) and a warning is logged.
Parameters
[in,out]featuresFeature map to score; per-feature MetaValues and overall quality are written in place.
Exceptions
Exception::IllegalArgumentIf library_ has fewer than 2 peptides.

References ExposedVector< VectorElement >::begin(), ExposedVector< VectorElement >::end(), TargetedExperiment::getPeptides(), TargetedExperiment::getTransitions(), OPENMS_LOG_DEBUG, OPENMS_LOG_WARN, and ExposedVector< VectorElement >::size().

Member Data Documentation

◆ decoy_index_

IntList decoy_index_
protected

Indexes into library_.getPeptides() used as decoys for the current feature.

◆ glm_

struct OpenMS::ConfidenceScoring::GLM_ glm_
protected

◆ library_

TargetedExperiment library_
protected

Targeted-assay library: one peptide per assay, each with its transitions.

◆ n_decoys_

Size n_decoys_
protected

Number of decoy assays to sample per feature (0 = use all unrelated assays as decoys)

◆ n_transitions_

Size n_transitions_
protected

Number of top-intensity transitions to keep when computing the intensity-distance term (0 = keep all)

◆ rt_norm_

struct OpenMS::ConfidenceScoring::RTNorm_ rt_norm_
protected

◆ rt_trafo_

TransformationDescription rt_trafo_
protected

Optional RT transformation applied to measured feature RTs before comparison with library RTs.

◆ shuffler_

Math::RandomShuffler shuffler_
protected

Random shuffler used to draw decoy samples (seed depends on test mode — see ctor)

◆ transition_map_

std::map<std::string, IntList> transition_map_
protected

Lookup assay-id -> indexes into library_.getTransitions()