OpenMS
Loading...
Searching...
No Matches
PercolatorReset.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: Oliver Kohlbacher $
7// --------------------------------------------------------------------------
8
9#pragma once
10
13
14#include <cstdint>
15#include <optional>
16#include <string>
17#include <vector>
18
19namespace OpenMS
20{
75 class OPENMS_DLLAPI PercolatorReset
76 {
77 public:
79 struct Input
80 {
82 std::vector<std::vector<double>> features;
85 std::vector<double> feature_matrix;
86 std::vector<std::string> feature_names;
87 std::vector<bool> is_decoy;
88 std::vector<double> search_scores;
89 std::vector<Size> spectrum;
90 std::vector<std::string> stems;
94 std::vector<char> decoy_set;
95
97 Size rowCount() const
98 {
99 return features.empty() && !feature_matrix.empty() ? is_decoy.size() : features.size();
100 }
101
103 const double* row(Size i) const
104 {
105 return !features.empty() ? features[i].data() : feature_matrix.data() + i * feature_names.size();
106 }
107 };
108
109 struct Options
110 {
112 std::optional<std::uint64_t> salt;
113 int iterations = 25;
114 double train_fdr = 0.01;
115 std::vector<double> c_values = {0.1, 1.0, 10.0};
116 std::string learner = "svm";
122 std::string representative = "model";
123 bool audit = false;
125 int decoy_databases = 1;
126 std::vector<std::string> zero_features = {"enzInt"};
127 int threads = 1;
128 int mlp_members = 8;
129 int mlp_hidden = 16;
130 int mlp_epochs = 30;
133 int mlp_warm_epochs = 3;
137 bool mlp_crossfit = true;
141 int mlp_norm_min_decoys = 1000;
142 };
143
145 enum class Role : int { TARGET = 0, ESTIMATING_DECOY = 1, TRAINING_DECOY = 2 };
146
148 struct Stem
149 {
150 std::string stem;
151 Size representative = 0;
152 bool decoy = false;
154 Role role = Role::TARGET;
155 bool considered = false;
156 double search_score = 0.0;
157 double score = 0.0;
158 double q_value = 1.0;
159 };
160
162 {
163 std::string name;
164 double auc = 0.5;
165 double ks = 0.0;
166 bool flagged = false;
167 };
168
169 struct Output
170 {
172 std::vector<double> scores;
180 std::vector<double> psm_q_values;
184 std::vector<double> psm_peps;
186 std::vector<double> stem_q_values;
188 std::vector<Role> roles;
190 std::vector<Stem> stems;
191 std::vector<AuditFeature> audit;
192 double audit_multivariate_auc = 0.5;
193 bool audit_flagged = false;
194 double audit_proxy_ratio = 0.0;
195 Size audit_decoys = 0, audit_proxy = 0;
197 std::vector<std::string> rounds;
198 Size target_stems = 0, decoy_stems = 0, training_decoys = 0, estimating_decoys = 0;
202 Size decoy_stems_second_set = 0, decoy_stems_both_sets = 0;
203 Size discoveries_1pct = 0;
204 std::vector<std::string> used_features;
205 std::vector<double> weights;
206 std::uint64_t salt = 0;
207 std::string learner;
208 std::string learner_settings;
209 };
210
212 static Output run(const Input& input, const Options& options);
213
216 static std::vector<double> seqStepQValues(const std::vector<bool>& is_decoy, double factor, double plus_one);
217
219 static bool isTrainingDecoy(std::uint64_t salt, const std::string& stem);
220 };
221}
Percolator-RESET: semi-supervised rescoring with FDR control at the peptide (stem) level.
Definition PercolatorReset.h:76
std::vector< std::string > used_features
features the learner used (non-constant, not zeroed)
Definition PercolatorReset.h:204
std::vector< std::string > rounds
training summary per round: chosen C+, C-, held-out discoveries, positives
Definition PercolatorReset.h:197
std::vector< double > scores
per row: score of the final model (all rows, also those that lost a competition)
Definition PercolatorReset.h:172
std::string learner_settings
learner "mlp": its settings (for reports); empty for "svm"
Definition PercolatorReset.h:208
Role
Role of a row's stem (decoy stems by their coin)
Definition PercolatorReset.h:145
static bool isTrainingDecoy(std::uint64_t salt, const std::string &stem)
The coin of a decoy stem: true = training decoy. Exposed for tests.
std::vector< double > stem_q_values
per row: q-value of the row's stem (Stem::q_value)
Definition PercolatorReset.h:186
std::vector< AuditFeature > audit
Definition PercolatorReset.h:191
std::string stem
unmodified sequence
Definition PercolatorReset.h:150
static std::vector< double > seqStepQValues(const std::vector< bool > &is_decoy, double factor, double plus_one)
std::string learner
Definition PercolatorReset.h:207
static Output run(const Input &input, const Options &options)
Runs RESET; throws Exception::InvalidValue on malformed input or without decoy stems.
std::string name
Definition PercolatorReset.h:163
std::vector< Stem > stems
all stems (considered or not)
Definition PercolatorReset.h:190
std::vector< double > psm_q_values
Definition PercolatorReset.h:180
std::optional< std::uint64_t > salt
coin salt (never pick the best of several salts); unset = a fresh random salt, recorded in Output::sa...
Definition PercolatorReset.h:112
std::vector< Role > roles
per row: role of the row's stem
Definition PercolatorReset.h:188
std::vector< double > psm_peps
Definition PercolatorReset.h:184
std::vector< double > weights
linear learner: raw-feature weights of the final model, bias last
Definition PercolatorReset.h:205
Definition PercolatorReset.h:162
Definition PercolatorReset.h:110
Definition PercolatorReset.h:170
One considered or dropped stem.
Definition PercolatorReset.h:149
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
Rows: one per PSM (all hits of all spectra), in any order.
Definition PercolatorReset.h:80
const double * row(Size i) const
Row i: of features, or else of the dense feature_matrix.
Definition PercolatorReset.h:103
std::vector< std::string > feature_names
one name per feature column
Definition PercolatorReset.h:86
Size rowCount() const
Number of rows: of features, or else of the dense feature_matrix.
Definition PercolatorReset.h:97
std::vector< Size > spectrum
per row: spectrum (competition unit) of the PSM
Definition PercolatorReset.h:89
std::vector< bool > is_decoy
per row
Definition PercolatorReset.h:87
std::vector< double > search_scores
per row: search engine score, higher = better
Definition PercolatorReset.h:88
std::vector< std::vector< double > > features
feature rows (all of the same length); empty if the rows are in the dense feature_matrix
Definition PercolatorReset.h:82
std::vector< char > decoy_set
Definition PercolatorReset.h:94
std::vector< std::string > stems
Definition PercolatorReset.h:90
std::vector< double > feature_matrix
Definition PercolatorReset.h:85