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

In-process Percolator scoring for OpenSWATH OSW and OSWPQ results. More...

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

Inheritance diagram for OpenSwathPercolatorScoring:
DefaultParamHandler

Classes

struct  ScoreSummary
 Small execution summary returned by score() More...
 

Public Types

enum class  Level {
  MS1 , MS2 , MS1MS2 , TRANSITION ,
  SIZE_OF_LEVEL
}
 Supported OpenSWATH scoring levels. More...
 

Public Member Functions

 OpenSwathPercolatorScoring ()
 
 ~OpenSwathPercolatorScoring () override
 
ScoreSummary score (const std::string &input_path, Level level, const std::string &output_path="")
 Score an OpenSWATH OSW / OSWPQ file in place or into a copy.
 
- 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 &param)
 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.
 

Static Public Member Functions

static std::vector< Size > trainingRows (const RescoreInput &input, const std::string &main_score, Size max_others, UInt64 seed)
 The rows Percolator is trained on for peak-group (ms1, ms2, ms1ms2) rescoring.
 
- 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.
 

Static Public Attributes

static const std::array< std::string, static_cast< Size >(Level::SIZE_OF_LEVEL)> names_of_level
 String names of the supported scoring levels.
 

Protected Member Functions

void updateMembers_ () override
 This method is used to update extra member variables at the end of the setParameters() method.
 
- Protected Member Functions inherited from DefaultParamHandler
void defaultsToParam_ ()
 Updates the parameters after the defaults have been set in the constructor.
 

Private Attributes

std::unique_ptr< Impl > impl_
 

Additional Inherited Members

- 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;.
 

Detailed Description

In-process Percolator scoring for OpenSWATH OSW and OSWPQ results.

The scorer reads OpenSWATH feature tables, converts them into a domain-agnostic Percolator::RescoreInput, performs target/decoy rescoring, and writes the resulting score, q-value, PEP, and peak-group rank back to the source format. Rows with missing active OpenSWATH features are skipped instead of being imputed to zero, matching PyProphet's cleanup step.

Peak-group-level q-values / PEPs follow the OpenSWATH / PyProphet convention: Percolator provides the discriminant, top-ranked target/decoy peak groups define the error model, and the resulting statistics are then projected back onto all scored candidates.

Supported levels:

  • MS1: writes SCORE_MS1 (SQLite) or score_ms1_* columns (.oswpq)
  • MS2: writes SCORE_MS2 (SQLite) or score_ms2_* columns (.oswpq)
  • MS1MS2: uses combined MS2 + MS1 features and writes SCORE_MS2 / score_ms2_* (matching the historical PyProphet convention)
  • Transition: requires prior MS2/MS1MS2 scoring and writes SCORE_TRANSITION / score_transition_*

For MS1, MS2 and MS1MS2 scoring, Percolator is trained on a subset of the peak groups (see trainingRows()) and the model is then applied to all peak groups. The subset holds the best peak group of every precursor of every run by the parameter training_main_score, which brings in most of the rare true peak groups, and all peak groups of precursors drawn at random, up to percolator:subset_max_train further peak groups. Within these complete precursors, Percolator's choice of the best peak group per precursor in each training iteration (percolator:train_best_positive) can still promote a peak group that the main score ranked lower. percolator:subset_max_train = 0 trains on all peak groups. Transitions are always trained on all rows.

Transition-level scoring reuses the historical OpenMS / PyProphet-style candidate filters: only transitions from non-decoy precursors whose peak-group rank and PEP pass the configured thresholds and whose transition-level isotope-overlap / log-SN filters pass are rescored.


Class Documentation

◆ OpenMS::OpenSwathPercolatorScoring::ScoreSummary

struct OpenMS::OpenSwathPercolatorScoring::ScoreSummary

Small execution summary returned by score()

Class Members
Size decoy_rows = 0
Size feature_count = 0
Size target_rows = 0
Size total_rows = 0

Member Enumeration Documentation

◆ Level

enum class Level
strong

Supported OpenSWATH scoring levels.

Enumerator
MS1 
MS2 
MS1MS2 
TRANSITION 
SIZE_OF_LEVEL 

Constructor & Destructor Documentation

◆ OpenSwathPercolatorScoring()

◆ ~OpenSwathPercolatorScoring()

Member Function Documentation

◆ score()

ScoreSummary score ( const std::string &  input_path,
Level  level,
const std::string &  output_path = "" 
)

Score an OpenSWATH OSW / OSWPQ file in place or into a copy.

Input order is canonicalized by run filename, peptide or compound identity, charge and decoy label, then retention time and retained feature values. Generated IDs are used only to preserve the one-run/one-precursor grouping and to write results. Transition rows remain separate CV groups. Retained rows require run filenames and modified peptide sequences or compound identity. Native SQL compounds use name, formula, SMILES and adducts. Native Parquet molecules use the source library traml_id and precursor m/z when modified_sequence is empty. Source library identities must remain stable between runs. Incomplete active-score rows are discarded first. Distinct assay aliases with identical scientific sort keys keep their original partitions, but alias-specific CV assignments are not guaranteed invariant.

Parameters
[in]input_pathInput .osw SQLite file or .oswpq directory/archive
[in]levelOpenSWATH scoring level to rescore
[in]output_pathOptional output path. If empty, score in place. Non-empty outputs preserve the input container kind (SQLite -> SQLite, directory -> directory, archive -> archive).
Returns
Small execution summary for the rescored rows.
Exceptions
Exception::FileNotFoundif the input file does not exist
Exception::Preconditionif required prerequisite scores are missing
Exception::MissingInformationif a retained row has no run filename, scientific precursor identity, or valid transition decoy label
Exception::InvalidValueif no usable feature columns are available or a retention time is not finite

◆ trainingRows()

static std::vector< Size > trainingRows ( const RescoreInput &  input,
const std::string &  main_score,
Size  max_others,
UInt64  seed 
)
static

The rows Percolator is trained on for peak-group (ms1, ms2, ms1ms2) rescoring.

Rows sharing a value of RescoreInput::cv_group_keys form a group (one precursor in one run). The training set is the best row of every group by main_score (ties keep the first row) plus all rows of groups drawn at random, in the order of a shuffle with seed, as long as their other rows fit into max_others (the first group that does not fit ends the drawing).

Parameters
[in]inputPeak groups; cv_group_keys must hold one key per row
[in]main_scoreFeature name; prefix '-' if lower values are better
[in]max_othersRows besides the best of every group (0: all rows)
[in]seedSeed of the shuffle that draws the groups
Returns
Ascending row indices. All rows if max_others is 0, if cv_group_keys does not hold one key per row, if main_score is not among the features, or if all rows would fit.

◆ updateMembers_()

void updateMembers_ ( )
overrideprotectedvirtual

This method is used to update extra member variables at the end of the setParameters() method.

Also call it at the end of the derived classes' copy constructor and assignment operator.

The default implementation is empty.

Reimplemented from DefaultParamHandler.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> impl_
private

◆ names_of_level

const std::array<std::string, static_cast<Size>(Level::SIZE_OF_LEVEL)> names_of_level
static

String names of the supported scoring levels.