An R6 class that estimates the false discovery rate (FDR) of target-decoy search results. When the object is created, the hits are sorted from best to worst score and two FDR estimates are computed at each score:
fdr_concatenated: the FDR of a concatenated target-decoy search, estimated as 2 * decoys / all hits (Elias and Gygi 2007).
fdr_simple: the FDR estimated as decoys / targets (Käll et al. 2008).
Both estimates are fractions in [0, 1]: values above 1, e.g. where the best hits are decoys, are set to 1.
The q-value of a hit is the lowest FDR at which it is accepted: the smallest estimate at its own or any worse score. The estimate at a score counts all hits with that score or a better one, so tied hits share their estimates and q-values, whatever the input order; within a tie, decoys are listed before targets.
The decoys are given as logical flags. For protein IDs whose decoys start with REV_, pass decoy_hit = grepl(“^REV_”, id), and id = id to keep the IDs in table.
The object cannot be changed: its fields are read-only and its methods only read them. clone() copies an object. See vignette(“TargetDecoyFDR_Example”, package = “prozor”).
Value
TargetDecoyFDR$new() returns a TargetDecoyFDR R6 object; see Methods.
Active bindings
larger_better
TRUE if a larger score is better (read-only).
n
Number of hits (read-only).
table
The hits from best to worst score, as a data frame (read-only) with the columns:
order: the position of the hit in the input.
id: the ID of the hit; only when id was given.
score, decoy_hit: the sorted input.
fdr_concatenated, fdr_simple: the FDR estimates at the score, as fractions in [0, 1].
q_value_fdr_concatenated, q_value_fdr_simple: the q-values of both estimates, as fractions in [0, 1].
The FDR as a fraction, like the q-values in table: 0.01 for 1 %.
method
The FDR estimate to use: “fdr_simple” (default) or “fdr_concatenated”.
Returns
The least strict score whose q-value is at most q_value. An error if no score reaches it.
TargetDecoyFDR$plot()
Plot the score distributions and q-values: two panels on a shared score axis, the histogram of target and decoy scores, and the q-values of both FDR estimates in percent. When smaller scores are better and all scores are positive, the score axis is logarithmic. Every hit is drawn: one million hits take about 2 s to render as PDF and 20 s as PNG.
Usage
TargetDecoyFDR\$plot(bins = 100)
Arguments
bins
Number of histogram bins.
Returns
A ggplot object.
TargetDecoyFDR$clone()
The objects of this class are cloneable with this method.
Usage
TargetDecoyFDR\$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
References
Elias JE, Gygi SP (2007). Target-decoy search strategy for increased confidence in large-scale protein identifications by mass spectrometry. Nature Methods, 4(3), 207-214. doi:10.1038/nmeth1019
Käll L, Storey JD, MacCoss MJ, Noble WS (2008). Assigning significance to peptides identified by tandem mass spectrometry using decoy databases. Journal of Proteome Research, 7(1), 29-34. doi:10.1021/pr700600n
See Also
Other FDR: bcd, fdr_sample
Examples
library("prozor")data(fdr_sample)# smaller scores are better; decoy IDs start with REV_fdr <- TargetDecoyFDR$new( fdr_sample$score,decoy_hit =grepl("^REV_", fdr_sample$protein_id),larger_better =FALSE,id = fdr_sample$protein_id)fdr
<TargetDecoyFDR> hits: 40,000, decoys: 858, larger_better: FALSE
score at fdr_simple q-value 0.01: 0.03395, at 0.05: 0.09992