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

Measures the false discovery proportion (FDP) of identifications with an entrapment database. More...

#include <OpenMS/ANALYSIS/ID/EntrapmentEvaluation.h>

Classes

struct  Result
 result for one class at one q-value threshold and level More...
 

Public Types

enum class  Kind { TARGET , ENTRAPMENT , DECOY }
 how a PSM is counted More...
 
enum class  Level { PSM , PEPTIDE }
 what is counted as one discovery More...
 
using PeptidePairs = std::unordered_map< std::string, std::string >
 entrapment peptide -> the target peptide it was made from (both unmodified, I replaced by L)
 

Static Public Member Functions

static Kind classify (const PeptideHit &hit, const std::string &entrapment_prefix, const std::string &decoy_string="", bool decoy_is_prefix=true)
 Classify a peptide hit by its protein accessions.
 
static double estimateTERatio (const std::vector< FASTAFile::FASTAEntry > &db, const std::string &entrapment_prefix, const std::string &decoy_string, bool decoy_is_prefix, const std::string &enzyme="Trypsin", Size missed_cleavages=2, Size min_length=7, Size max_length=40)
 Estimate T/E, the ratio of distinct searchable target to entrapment peptides, from a database.
 
static std::unordered_set< std::string > targetPeptides (const std::vector< FASTAFile::FASTAEntry > &db, const std::string &entrapment_prefix, const std::string &decoy_string, bool decoy_is_prefix, const std::string &enzyme="Trypsin", Size missed_cleavages=2, Size min_length=7, Size max_length=40)
 The distinct searchable peptides of the target proteins of a database, with every I replaced by L.
 
static double qValue (const PeptideIdentification &pep_id, const PeptideHit &hit)
 Return the q-value of a hit.
 
static PeptidePairs pairPeptides (const std::vector< FASTAFile::FASTAEntry > &db, const std::string &entrapment_prefix, const std::string &decoy_string, bool decoy_is_prefix, const std::string &enzyme="Trypsin", Size missed_cleavages=2, Size min_length=7, Size max_length=40, Size *mismatched=nullptr)
 Pair every entrapment peptide with the target peptide it was made from.
 
static std::map< std::string, Result > evaluate (const PeptideIdentificationList &pep_ids, double q_threshold, const std::string &entrapment_prefix, double te_ratio, Level level=Level::PSM, const std::string &class_meta_value="", const std::unordered_set< std::string > *target_peptides=nullptr, const PeptidePairs *pairs=nullptr, const std::string &score_meta_value="", const std::string &decoy_string="", bool decoy_is_prefix=true)
 Evaluate the identifications at a q-value threshold.
 

Detailed Description

Measures the false discovery proportion (FDP) of identifications with an entrapment database.

An entrapment database adds sequences to the searched targets that cannot be in the sample (for example shuffled copies of the targets, see DecoyDatabase -entrapment_ratio). The entrapment sequences are searched as targets, so the target-decoy FDR does not know about them. A discovery that matches only entrapment sequences is false by construction, which gives estimates of the true FDP among the accepted discoveries that are independent of the decoys. With N_T accepted original-target and N_E accepted entrapment discoveries, N = N_T + N_E, and r the ratio of searchable entrapment to target peptides (T/E = 1/r), following Wen et al., "Assessment of false discovery rate control in tandem mass spectrometry analysis using entrapment", Nat. Methods (2025):

  • lower bound: FDP = N_E / N. A lower bound on the FDP; it can only show that FDR control fails.
  • combined: FDP = N_E * (1 + T/E) / N. An estimated upper bound; below the nominal FDR it is evidence of control.
  • paired: FDP = (N_E + N_{E>=s>T} + 2 * N_{E>T>=s}) / N, for r = 1 with every entrapment peptide paired to the target peptide it was made from. N_{E>=s>T} counts accepted entrapment peptides whose paired target is not accepted, N_{E>T>=s} those whose paired target is accepted but ranks below or level with them. Also an estimated upper bound, and a tighter one than the combined estimate. As in the paper's FDRBench, it is computed at the peptide level only.

Discoveries are counted at two levels: the top PSM of each spectrum, and peptides (distinct unmodified sequences, I and L taken as one residue). The paper evaluates peptides rather than PSMs. A peptide is accepted at its peptide-level q-value (meta value "peptide q-value", as written by FalseDiscoveryRate -peptide true) when its PSMs carry one; otherwise at the best q-value of its PSMs, which is then not a peptide-level FDR.

A discovery counts as entrapment only when all its proteins are entrapment proteins: a peptide that also occurs in a target protein is a target. Given the target peptides of the database (targetPeptides()), a PSM whose sequence equals a target peptide with I and L taken as one residue also counts as target: I and L have the same mass, so the two cannot be told apart. Decoy PSMs (target_decoy = decoy) are ignored.

Results can be stratified by a meta value of the peptide hits (for example a modification class), which shows whether the nominal FDR holds within each class. A peptide takes the class of its best PSM.

Member Typedef Documentation

◆ PeptidePairs

using PeptidePairs = std::unordered_map<std::string, std::string>

entrapment peptide -> the target peptide it was made from (both unmodified, I replaced by L)

Member Enumeration Documentation

◆ Kind

enum class Kind
strong

how a PSM is counted

Enumerator
TARGET 

matches at least one target (non-entrapment) protein

ENTRAPMENT 

matches only entrapment proteins

DECOY 

decoy PSM (ignored)

◆ Level

enum class Level
strong

what is counted as one discovery

Enumerator
PSM 

the top hit of each spectrum

PEPTIDE 

distinct unmodified peptide sequences (I = L)

Member Function Documentation

◆ classify()

static Kind classify ( const PeptideHit &  hit,
const std::string &  entrapment_prefix,
const std::string &  decoy_string = "",
bool  decoy_is_prefix = true 
)
static

Classify a peptide hit by its protein accessions.

Decoy proteins among the accessions are ignored: a peptide found in an entrapment protein and in a decoy protein is in no original target protein, so it is an entrapment discovery.

Parameters
hitThe hit; its peptide evidences carry the accessions
entrapment_prefixAccession prefix of entrapment proteins (e.g. "ENTRAP_")
decoy_stringDecoy string of the database (empty: no accession is treated as decoy)
decoy_is_prefixWhether decoy_string is a prefix (else a suffix, as for estimateTERatio())
Returns
DECOY if the hit is annotated as decoy, ENTRAPMENT if it has non-decoy accessions and all start with entrapment_prefix, TARGET otherwise

◆ estimateTERatio()

static double estimateTERatio ( const std::vector< FASTAFile::FASTAEntry > &  db,
const std::string &  entrapment_prefix,
const std::string &  decoy_string,
bool  decoy_is_prefix,
const std::string &  enzyme = "Trypsin",
Size  missed_cleavages = 2,
Size  min_length = 7,
Size  max_length = 40 
)
static

Estimate T/E, the ratio of distinct searchable target to entrapment peptides, from a database.

Proteins whose accession carries decoy_string are skipped: as a prefix, or (see decoy_is_prefix) as a suffix, optionally followed by "_<n>" as DecoyDatabase writes it with shuffle_decoy_ratio > 1. Peptides are counted after in-silico digestion with enzyme, within the length limits, with I and L taken as one residue; a peptide that occurs in a target protein counts as target only.

Returns
T/E, or 1 if the database has no entrapment peptides

◆ evaluate()

static std::map< std::string, Result > evaluate ( const PeptideIdentificationList &  pep_ids,
double  q_threshold,
const std::string &  entrapment_prefix,
double  te_ratio,
Level  level = Level::PSM,
const std::string &  class_meta_value = "",
const std::unordered_set< std::string > *  target_peptides = nullptr,
const PeptidePairs *  pairs = nullptr,
const std::string &  score_meta_value = "",
const std::string &  decoy_string = "",
bool  decoy_is_prefix = true 
)
static

Evaluate the identifications at a q-value threshold.

Parameters
pep_idsIdentifications (only the first hit of each is used; hits are expected to be sorted)
q_thresholdAccept discoveries with q <= this value
entrapment_prefixAccession prefix of entrapment proteins
te_ratioT/E (see estimateTERatio())
levelCount PSMs or peptides
class_meta_valueIf not empty, results are additionally reported per value of this hit meta value (hits without it are in class "NA")
target_peptidesIf given (see targetPeptides()), an entrapment-only hit whose unmodified sequence, with I replaced by L, is one of these counts as target
pairsIf given (see pairPeptides()) and level is PEPTIDE, the paired counts are computed. The paired target of an entrapment peptide is the target peptide entry of pep_ids (all classes). An entrapment peptide without a pair counts as if its target ranked below it.
score_meta_valueIf not empty, a hit meta value (higher is better) that ranks discoveries with equal q-values for the paired comparison; without it, or at equal scores, an entrapment peptide ranks level with its target, which counts against the FDP
decoy_stringDecoy string of the database, passed to classify()
decoy_is_prefixWhether decoy_string is a prefix (else a suffix)
Returns
Results keyed by class; key "all" holds the overall result (a class named "all" is reported as "class:all")

◆ pairPeptides()

static PeptidePairs pairPeptides ( const std::vector< FASTAFile::FASTAEntry > &  db,
const std::string &  entrapment_prefix,
const std::string &  decoy_string,
bool  decoy_is_prefix,
const std::string &  enzyme = "Trypsin",
Size  missed_cleavages = 2,
Size  min_length = 7,
Size  max_length = 40,
Size *  mismatched = nullptr 
)
static

Pair every entrapment peptide with the target peptide it was made from.

Expects entrapment proteins as DecoyDatabase -entrapment_ratio 1 writes them: the accession is entrapment_prefix followed by the target's accession, and the sequence is the target's with the residues permuted within each peptide, so cleavage sites and peptide boundaries stay in place. Each target peptide (as digested like estimateTERatio()) is paired with the entrapment peptide at the same position. Pairs whose two peptides differ in composition (the entrapment protein was not made this way) are skipped and counted in mismatched; an entrapment peptide that equals its target peptide (I = L) is not paired. Decoy proteins (decoy_string, as for estimateTERatio()) are skipped.

Returns
The pairs; empty if the database has no entrapment protein with a matching target (for example with entrapment_ratio > 1, whose accessions carry a "_<n>" suffix)

◆ qValue()

static double qValue ( const PeptideIdentification &  pep_id,
const PeptideHit &  hit 
)
static

Return the q-value of a hit.

Uses the hit's score when the score type of pep_id is a q-value (its name contains "q-value"), otherwise the meta values "q-value" or "MS:1001491" of the hit.

Exceptions
Exception::MissingInformationif no q-value is available

◆ targetPeptides()

static std::unordered_set< std::string > targetPeptides ( const std::vector< FASTAFile::FASTAEntry > &  db,
const std::string &  entrapment_prefix,
const std::string &  decoy_string,
bool  decoy_is_prefix,
const std::string &  enzyme = "Trypsin",
Size  missed_cleavages = 2,
Size  min_length = 7,
Size  max_length = 40 
)
static

The distinct searchable peptides of the target proteins of a database, with every I replaced by L.

Digests like estimateTERatio(); decoy and entrapment proteins are skipped. Pass the result to evaluate().