| Title: | Minimal Protein Set Explaining Peptide Spectrum Matches |
|---|---|
| Description: | Determine the minimal set of proteins that explains the peptide spectrum matches (PSMs) of a mass spectrometry experiment, using a greedy parsimony algorithm. Annotate peptides with the proteins they match in 'FASTA' sequence databases, and create 'FASTA' databases with reversed decoy sequences and contaminant proteins. Compute and plot the coverage of protein sequences by the matched peptides. Estimate the false discovery rate (FDR) of target-decoy search results at the PSM, precursor, peptide and protein level, following Elias and Gygi (2007) <doi:10.1038/nmeth1019> and Käll et al. (2008) <doi:10.1021/pr700600n>. Compute variable precursor isolation windows for data-independent acquisition (DIA) from the distribution of precursor (MS1) masses. |
| Authors: | Witold Wolski [aut, cre] (ORCID: <https://orcid.org/0000-0002-6468-120X>), Jonas Grossmann [ctb] (ORCID: <https://orcid.org/0000-0002-6899-9020>), Functional Genomics Center Zurich [fnd] (ROR: <https://ror.org/04tgr1802>), University of Zurich [cph] (ROR: <https://ror.org/02crff812>) |
| Maintainer: | Witold Wolski <[email protected]> |
| License: | GPL-3 |
| Version: | 0.5.0 |
| Built: | 2026-11-25 21:54:03 UTC |
| Source: | https://github.com/prolfqua/prozor |
Searches all peptides at once with AhoCorasickTrie::AhoCorasickSearch(). Peptides that occur in no protein
are dropped.
annotate_aho(peptides, fasta, peptide = "peptide_seq")annotate_aho(peptides, fasta, peptide = "peptide_seq")
peptides |
Peptide sequences: upper-case letters only, without whitespace or modifications.
|
fasta |
A list of protein sequences with unique names, as returned by |
peptide |
Name of the result column that holds the peptide sequences. |
The protein sequences are searched in upper case, with each character other than a letter, such as the stop
codon * of a translated database or a blank, replaced by X. The offsets are those of the sequences in fasta.
A data frame with one row per occurrence and the columns protein_id, peptide (named by the
argument), offset (1-based start of the peptide) and protein_sequence (the sequence as searched); with 0
rows if no peptide occurs.
Other protein inference:
annotate_peptides(),
greedy_parsimony(),
greedy_to_table(),
pepprot,
protpepmetashort
file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") fasta <- read_fasta(fasta_file) hits <- annotate_aho(peptides[1:20], fasta) dim(hits)file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") fasta <- read_fasta(fasta_file) hits <- annotate_aho(peptides[1:20], fasta) dim(hits)
Finds every occurrence of each peptide in fasta with annotate_aho() and flags whether it is preceded by a
tryptic cleavage site. Peptides that occur in no protein are dropped.
annotate_peptides( peptides, fasta, peptide = "peptide_seq", prefix = "(([RK])|(^)|(^M))", suffix = "" )annotate_peptides( peptides, fasta, peptide = "peptide_seq", prefix = "(([RK])|(^)|(^M))", suffix = "" )
peptides |
A character vector of peptide sequences, or a data frame (or tibble) with the column named by
|
fasta |
A list of protein sequences with unique names, as returned by |
peptide |
Name of the column with the peptide sequences. |
prefix |
Regular expression the residues before a match must end with. |
suffix |
Regular expression the residues after a match must start with. |
Each occurrence of a peptide in a protein is one row. matched is TRUE when the residues before that
occurrence match prefix and the residues after it match suffix. With the defaults, matched means: preceded
by K or R or the protein N-terminus (or by the Met at position 1). The end of the peptide is not checked, neither
its last residue nor a following proline; pass a suffix to check the residues after it.
Whitespace around the peptide sequences, such as the "\r" of a file with Windows line endings, is removed
before the search, and the result holds the trimmed sequences.
A data frame with one row per row of peptides and protein occurrence: the columns of peptides,
protein_id, offset (1-based start of the peptide), protein_sequence (as searched, see annotate_aho()),
matched and peptide_length. With 0 rows and a warning if no peptide occurs in fasta.
Other protein inference:
annotate_aho(),
greedy_parsimony(),
greedy_to_table(),
pepprot,
protpepmetashort
file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") fasta <- read_fasta(fasta_file) annot <- annotate_peptides(peptides[1:20], fasta) head(annot[, c("protein_id", "peptide_seq", "offset", "peptide_length", "matched")])file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") fasta <- read_fasta(fasta_file) annot <- annotate_peptides(peptides[1:20], fasta) head(annot[, c("protein_id", "peptide_seq", "offset", "peptide_length", "matched")])
Peptide-spectrum matches as produced by the COMET search engine, with its column names.
bcdbcd
A data frame with 4,557 rows and 18 columns:
scan: scan number.
num: rank of the match for the scan.
charge: precursor charge.
exp_neutral_mass, calc_neutral_mass: experimental and calculated neutral mass.
e.value: E-value (smaller is better).
xcorr: cross-correlation score.
delta_cn: difference to the next best xcorr, normalized.
sp_score: preliminary score (Sp).
ions_matched, ions_total: matched and theoretical fragment ions.
plain_peptide: peptide sequence.
modified_peptide: peptide with flanking residues and modification masses.
prev_aa, next_aa: residues before and after the peptide.
protein: comma-separated protein IDs; decoys start with REV_.
protein_count: number of proteins.
modifications: modifications as position, residue and mass.
COMET search (low-resolution HCD settings) of the FGCZ quality-control run
FUSION_1.20180713_005_autoQC4L against human UniProt sequences with reversed decoys.
Other FDR:
TargetDecoyFDR,
fdr_sample
An R6 class that splits the MS1 mass range into n_bins windows with about equal numbers of precursors. The window
boundaries (breaks) are computed once, when the object is created, with one of three methods:
"mixture" (default): the quantile breaks of the masses mixed with uniformly spread data, with the smallest share
of uniform data that keeps all window widths within [min_window, max_window]; the quantile breaks themselves if
they fit. The limits hold for the rounded and padded breaks. Stops if even windows of equal width violate the
limits.
"quantile": windows with equal numbers of masses, of any width.
"constant": windows of equal width.
The breaks are rounded to digits decimals, and the outer breaks are rounded outward and padded by 1 / 10^digits,
so that the windows enclose all masses.
The object cannot be changed: its fields are read-only and its methods only read them, so their results do not
depend on the order in which they are called. To compare methods or settings, create one object for each.
clone() copies an object.
Cdsw$new() returns a Cdsw R6 object; see Methods.
massesMS1 masses (read-only).
n_binsNumber of windows (read-only).
methodMethod that placed the breaks (read-only).
breaksWindow boundaries, n_bins + 1 values (read-only).
Cdsw$new()Compute the breaks of n_bins windows over the masses with method.
Cdsw$new(
masses,
n_bins = 25,
method = c("mixture", "quantile", "constant"),
max_window = 150,
min_window = 5,
digits = 2
)
massesMS1 masses (m/z): a numeric vector of finite values.
n_binsNumber of windows.
methodHow to place the breaks: "mixture" (default), "quantile" or "constant"; see Description.
max_window, min_windowLargest and smallest window width in m/z; used by method = "mixture" only.
digitsNumber of decimal places of the breaks.
A new Cdsw object.
Cdsw$print()Print the number of masses and windows, the method and the range of window widths.
Cdsw$print(...)
...Not used.
The object, invisibly.
Cdsw$as_table()The windows as a data frame.
Cdsw$as_table(overlap = 1)
overlapOverlap of neighboring windows in m/z, at least 0: each window is widened by overlap / 2 on both
sides.
A data frame with one row per window: start from, end to, center mid, width and the number of
precursors with from < m/z <= to (n_precursors).
Cdsw$error()Deviation of the windows from equal numbers of precursors.
Cdsw$error()
A list with manhattan (Manhattan distance), euclidean (Euclidean distance), normalized_counts
(precursors per window) and equal_counts (the counts of windows with equal numbers of precursors), both
counts normalized to length 1.
Cdsw$optimize_windows()Move window starts and ends to regions with few precursors, with readjust_windows().
Cdsw$optimize_windows(bin_width = 0.1, min_count = 15, overlap = 1)
bin_widthWidth of the bins (m/z) into which the masses are binned.
min_countBins with fewer than min_count precursors count as empty.
overlapOverlap of neighboring windows in m/z, as in as_table().
A data frame with the columns of as_table().
Cdsw$plot()Plot the precursors per window (from < m/z <= to); the dashed line marks equal counts.
Cdsw$plot()
A ggplot object.
Cdsw$plot_breaks()Plot the breaks of this object against the constant and quantile breaks of the same masses.
Cdsw$plot_breaks()
A ggplot object.
Cdsw$plot_cycle()Plot the DIA cycle, one window per step.
Cdsw$plot_cycle(overlap = 1)
overlapOverlap of neighboring windows in m/z, as in as_table().
A ggplot object.
Cdsw$clone()The objects of this class are cloneable with this method.
Cdsw$clone(deep = FALSE)
deepWhether to make a deep clone.
Other DIA windows:
masses,
plot_windows(),
readjust_windows()
data(masses) cdsw <- Cdsw$new(masses, max_window = 100) cdsw cdsw$plot_breaks() cdsw$plot() head(cdsw$as_table()) head(cdsw$optimize_windows()) cdsw$plot_cycle() # one object per method quantile_windows <- Cdsw$new(masses, method = "quantile") c(mixture = cdsw$error()$manhattan, quantile = quantile_windows$error()$manhattan)data(masses) cdsw <- Cdsw$new(masses, max_window = 100) cdsw cdsw$plot_breaks() cdsw$plot() head(cdsw$as_table()) head(cdsw$optimize_windows()) cdsw$plot_cycle() # one object per method quantile_windows <- Cdsw$new(masses, method = "quantile") c(mixture = cdsw$error()$manhattan, quantile = quantile_windows$error()$manhattan)
Reads one or more FASTA files, adds contaminants and reversed decoy sequences, and puts first a dummy
entry CRAPCRAPCRAP whose header records the source of the database. Of entries with the same name, only
the first is kept. See vignette("CreatingDecoyDB", package = "prozor").
create_decoy_db( files, contaminants = load_contaminants(), rev_lab = "REV_", header = "zz|sourceOf|database" )create_decoy_db( files, contaminants = load_contaminants(), rev_lab = "REV_", header = "zz|sourceOf|database" )
files |
Paths to one or more FASTA files. |
contaminants |
A list of contaminant sequences, e.g. from |
rev_lab |
Prefix of the reversed decoy sequences, or |
header |
Header of the dummy entry that records the source of the database, with or without the leading |
A list of SeqFastaAA objects with unique names: the dummy entry, the targets, the contaminants and,
unless rev_lab is NULL, the reversed decoys of the targets and contaminants.
Other FASTA databases:
create_fgcz_fasta_db(),
load_contaminants(),
make_chain_id(),
make_chain_id_uniprot(),
make_fasta_summary(),
read_fasta(),
remove_signal_peptide(),
reverse_seq(),
write_fasta()
file <- system.file("extdata/fgcz_contaminants2022_20220405.fasta.gz", package = "prozor") targets <- read_fasta(file) cont <- load_contaminants("fgcz2022") # the file, read twice, holds the same entries as `cont`: each is kept once db <- create_decoy_db(c(file, file), contaminants = cont) stopifnot(length(db) == 1 + 2 * length(targets), identical(names(targets), names(cont))) db <- create_decoy_db(file, rev_lab = NULL, contaminants = NULL) stopifnot(length(db) == 1 + length(targets))file <- system.file("extdata/fgcz_contaminants2022_20220405.fasta.gz", package = "prozor") targets <- read_fasta(file) cont <- load_contaminants("fgcz2022") # the file, read twice, holds the same entries as `cont`: each is kept once db <- create_decoy_db(c(file, file), contaminants = cont) stopifnot(length(db) == 1 + 2 * length(targets), identical(names(targets), names(cont))) db <- create_decoy_db(file, rev_lab = NULL, contaminants = NULL) stopifnot(length(db) == 1 + length(targets))
Reads all FASTA files in database_dir (*.fasta, *.fa or *.faa, optionally gzipped), adds
contaminants and decoys with create_decoy_db(), which drops duplicated entries, and writes the result to
output_dir as <name>[_d]_<date>.fasta, where _d marks a database with decoys. The first line of
annotation.txt in database_dir becomes the header of the dummy source entry.
create_fgcz_fasta_db( database_dir, output_dir, contaminants = load_contaminants(), rev_lab = "REV_", make_summary = TRUE )create_fgcz_fasta_db( database_dir, output_dir, contaminants = load_contaminants(), rev_lab = "REV_", make_summary = TRUE )
database_dir |
Directory with the FASTA files and |
output_dir |
Existing directory the FASTA file is written to; must not be |
contaminants |
Contaminant sequences to add, e.g. from |
rev_lab |
Prefix of the reversed decoy sequences, or |
make_summary |
If |
The whole database, decoys included, is held in memory. Peak memory grows linearly with the database, by about 4 KB per written sequence or 6 to 7 times the size of the written file: 250,000 target proteins (500,000 sequences with decoys, a 320 MB file) take 2.2 GB.
A list with the elements fasta (the sequences written), file_path, summary (text with the argument
values, the file name and the number of sequences), call and db_name.
Other FASTA databases:
create_decoy_db(),
load_contaminants(),
make_chain_id(),
make_chain_id_uniprot(),
make_fasta_summary(),
read_fasta(),
remove_signal_peptide(),
reverse_seq(),
write_fasta()
res <- create_fgcz_fasta_db( system.file("p1000_db1_example", package = "prozor"), output_dir = tempdir(), make_summary = FALSE ) basename(res$file_path) unlink(res$file_path)res <- create_fgcz_fasta_db( system.file("p1000_db1_example", package = "prozor"), output_dir = tempdir(), make_summary = FALSE ) basename(res$file_path) unlink(res$file_path)
Target and decoy hits with two scores, the input of TargetDecoyFDR.
fdr_samplefdr_sample
A data frame with 40,000 rows and 3 columns:
protein_id: protein ID (factor); decoys start with REV_.
score: score where smaller is better.
neg_log10_score: -log10(score), a score where larger is better.
Other FDR:
TargetDecoyFDR,
bcd
Repeatedly assigns all unexplained peptides of the protein that explains the most of them. Proteins that
explain exactly the same unexplained peptides are reported together, separated by ;. The groups are formed
on the peptides that remain in each round: proteins B (peptides p1, p5, p6) and C (p2, p5, p6) form the group
"B;C" for p5 and p6 after protein A has taken p1 and p2.
greedy_parsimony(annotation, peptide = "peptide_seq")greedy_parsimony(annotation, peptide = "peptide_seq")
annotation |
A data frame (or tibble) with one row per peptide-protein match, e.g. from
|
peptide |
Name of the column with the peptide IDs. For precursors, add a column such as
|
Proteins are ranked by the number of distinct peptides they explain; a peptide-protein pair that occurs in
several rows counts once. Of the proteins that tie, the one first in the order of the IDs is taken first. The
IDs of a character column are in C-locale order, as by sort(method = "radix"), whatever the locale: upper case
before lower case; those of a factor column in the level order.
A named character vector with one element per distinct peptide ID, named by the peptide ID: the protein,
or ;-separated protein group, it is assigned to. The elements are in the order in which the groups are chosen,
and the peptides of a group, like the proteins of a group, in the order of the IDs.
Other protein inference:
annotate_aho(),
annotate_peptides(),
greedy_to_table(),
pepprot,
protpepmetashort
data(protpepmetashort) groups <- greedy_parsimony(protpepmetashort, peptide = "peptide_mod_seq") # every modified peptide is assigned to exactly one protein group stopifnot(setequal(names(groups), protpepmetashort$peptide_mod_seq)) head(groups)data(protpepmetashort) groups <- greedy_parsimony(protpepmetashort, peptide = "peptide_mod_seq") # every modified peptide is assigned to exactly one protein group stopifnot(setequal(names(groups), protpepmetashort$peptide_mod_seq)) head(groups)
Convert a greedy_parsimony() result to a table
greedy_to_table(groups)greedy_to_table(groups)
groups |
A result of |
A data frame with the columns peptide, precursor_charge (integer) and protein_group, and the
precursor IDs as row names.
Other protein inference:
annotate_aho(),
annotate_peptides(),
greedy_parsimony(),
pepprot,
protpepmetashort
data(protpepmetashort) protpepmetashort$precursor <- paste( protpepmetashort$peptide_mod_seq, protpepmetashort$precursor_charge, sep = "." ) head(greedy_to_table(greedy_parsimony(protpepmetashort, peptide = "precursor")))data(protpepmetashort) protpepmetashort$precursor <- paste( protpepmetashort$peptide_mod_seq, protpepmetashort$precursor_charge, sep = "." ) head(greedy_to_table(greedy_parsimony(protpepmetashort, peptide = "precursor")))
The sets:
"fgcz2024" (default): the FGCZ default, the sets "special2024" and "universal2024" together; used by
create_decoy_db(), create_fgcz_fasta_db() and inst/script/fgcz_create_fasta.R.
"fgcz2019", "fgcz2021", "fgcz2022": FGCZ contaminant lists of 2019, 2021 and 2022.
"universal2024": universal contaminants from
https://github.com/HaoGroup-ProtContLib/Protein-Contaminant-Libraries-for-DDA-and-DIA-Proteomics,
described by Frankenfield et al. (2022). See system.file("COPYRIGHTS", package = "prozor").
"special2024": FGCZ special proteins of 2024.
load_contaminants( set = c("fgcz2024", "fgcz2019", "fgcz2021", "fgcz2022", "universal2024", "special2024"), no_human = FALSE )load_contaminants( set = c("fgcz2024", "fgcz2019", "fgcz2021", "fgcz2022", "universal2024", "special2024"), no_human = FALSE )
set |
Name of the contaminant set: |
no_human |
If |
A named list of SeqFastaAA objects.
Frankenfield AM, Ni J, Ahmed M, Hao L (2022). Protein Contaminants Matter: Building Universal Protein Contaminant Libraries for DDA and DIA Proteomics. Journal of Proteome Research, 21(9), 2104-2113. doi:10.1021/acs.jproteome.2c00145
Other FASTA databases:
create_decoy_db(),
create_fgcz_fasta_db(),
make_chain_id(),
make_chain_id_uniprot(),
make_fasta_summary(),
read_fasta(),
remove_signal_peptide(),
reverse_seq(),
write_fasta()
length(load_contaminants()) cont <- load_contaminants("fgcz2022") length(cont) length(load_contaminants("fgcz2022", no_human = TRUE))length(load_contaminants()) cont <- load_contaminants("fgcz2022") length(cont) length(load_contaminants("fgcz2022", no_human = TRUE))
Make an ID for a protein chain
make_chain_id(sequence, id, start)make_chain_id(sequence, id, start)
sequence |
The protein sequence, as one string; not used. |
id |
The ID of the protein, e.g. |
start |
Start position of the chain. |
id followed by s and start, e.g. "sp|P30443|1A01_HUMANs24".
Other FASTA databases:
create_decoy_db(),
create_fgcz_fasta_db(),
load_contaminants(),
make_chain_id_uniprot(),
make_fasta_summary(),
read_fasta(),
remove_signal_peptide(),
reverse_seq(),
write_fasta()
make_chain_id("ABCDE", "sp|P30443|1A01_HUMAN", 24)make_chain_id("ABCDE", "sp|P30443|1A01_HUMAN", 24)
Make a UniProt-style ID for a protein chain
make_chain_id_uniprot(sequence, id, start)make_chain_id_uniprot(sequence, id, start)
sequence |
The protein sequence, as one string; the chain ends at its last residue. |
id |
The UniProt ID of the protein, e.g. |
start |
Start position of the chain. |
The first two fields of id, followed by the range of the chain as UniProt writes it: start, - and the
length of sequence (the end of the chain), e.g. "sp|P30443|21-148".
Other FASTA databases:
create_decoy_db(),
create_fgcz_fasta_db(),
load_contaminants(),
make_chain_id(),
make_fasta_summary(),
read_fasta(),
remove_signal_peptide(),
reverse_seq(),
write_fasta()
make_chain_id_uniprot(strrep("A", 148), "sp|P30443|1A01_HUMAN", 21)make_chain_id_uniprot(strrep("A", 148), "sp|P30443|1A01_HUMAN", 21)
Counts the sequences and amino acids and summarizes the sequence lengths.
make_fasta_summary(fasta)make_fasta_summary(fasta)
fasta |
A list of sequences, as returned by |
A list with the elements n_sequences, length_summary and aa_freq (counts per amino acid).
Other FASTA databases:
create_decoy_db(),
create_fgcz_fasta_db(),
load_contaminants(),
make_chain_id(),
make_chain_id_uniprot(),
read_fasta(),
remove_signal_peptide(),
reverse_seq(),
write_fasta()
file <- system.file("extdata/fgcz_contaminants2022_20220405.fasta.gz", package = "prozor") fasta <- read_fasta(file) make_fasta_summary(fasta)file <- system.file("extdata/fgcz_contaminants2022_20220405.fasta.gz", package = "prozor") fasta <- read_fasta(file) make_fasta_summary(fasta)
Precursor masses, the input of Cdsw for computing DIA windows.
massesmasses
A numeric vector of 146,009 precursor m/z values.
Other DIA windows:
Cdsw,
plot_windows(),
readjust_windows()
Sequence, charge and m/z of identified precursors, without proteins; protpepmetashort holds the proteins of some of them.
pepprotpepprot
A data frame with 4,938 rows and 4 columns:
peptide_seq: peptide sequence (factor).
peptide_mod_seq: modified peptide sequence (factor).
precursor_charge: precursor charge (integer).
precursor_mz: precursor m/z.
Other protein inference:
annotate_aho(),
annotate_peptides(),
greedy_parsimony(),
greedy_to_table(),
protpepmetashort
Writes the protein sequence in rows of width residues. Each residue is a tile colored by the number of
peptides that cover it; uncovered residues are gray.
plot_coverage(residues, protein_id, width = 50)plot_coverage(residues, protein_id, width = 50)
residues |
A result of |
protein_id |
The protein to plot: one protein ID, a value of |
width |
Residues per row: a positive whole number. |
A ggplot object; the y axis labels the position of the first residue of each row.
Other sequence coverage:
residue_coverage(),
sequence_coverage()
file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") annot <- annotate_peptides(peptides, read_fasta(fasta_file)) coverage <- sequence_coverage(annot) best <- coverage$protein_id[which.max(coverage$coverage)] plot_coverage(residue_coverage(annot), best)file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") annot <- annotate_peptides(peptides, read_fasta(fasta_file)) coverage <- sequence_coverage(annot) best <- coverage$protein_id[which.max(coverage$coverage)] plot_coverage(residue_coverage(annot), best)
Plot precursor masses with DIA window boundaries
plot_windows(windows, masses, bin_width = 0.1)plot_windows(windows, masses, bin_width = 0.1)
windows |
A data frame or list with the columns |
masses |
Precursor masses (m/z): a numeric vector of finite values. |
bin_width |
Width of the histogram bins (m/z). |
A ggplot object.
Other DIA windows:
Cdsw,
masses,
readjust_windows()
data(masses) cdsw <- Cdsw$new(masses, max_window = 100) windows <- cdsw$optimize_windows(min_count = 10) plot_windows(windows, masses) # zoom into one window start <- windows$from[5] plot_windows(windows, masses) + ggplot2::coord_cartesian(xlim = c(start - 3, start + 3))data(masses) cdsw <- Cdsw$new(masses, max_window = 100) windows <- cdsw$optimize_windows(min_count = 10) plot_windows(windows, masses) # zoom into one window start <- windows$from[5] plot_windows(windows, masses) + ggplot2::coord_cartesian(xlim = c(start - 3, start + 3))
Peptide-protein pairs for 241 mouse proteins and 9 FGCZ contaminants; small, so the examples stay fast.
protpepmetashortprotpepmetashort
A data frame with 423 rows and 7 columns:
peptide_seq: peptide sequence (factor).
protein_length: length of the protein sequence.
protein_id: UniProt protein ID (factor), e.g. sp|Q62009|POSTN_MOUSE.
peptide_mod_seq: modified peptide sequence (factor).
precursor_charge: precursor charge (integer).
precursor_mz: precursor m/z.
peptide_length: length of the peptide sequence.
Precursors of pepprot, annotated with annotate_peptides() against mouse UniProt sequences and FGCZ
contaminants.
Other protein inference:
annotate_aho(),
annotate_peptides(),
greedy_parsimony(),
greedy_to_table(),
pepprot
Reads amino-acid sequences, each sequence as one string. Lines starting with ; and lines before the first
header are skipped; an entry without sequence lines gets the empty string.
read_fasta(file)read_fasta(file)
file |
Path to a FASTA file, optionally gzip-compressed. |
A named list with one SeqFastaAA object per sequence: the sequence as a string, with the attributes
name (the first word of the header, up to the first whitespace, without >; also the list name) and Annot
(the header line).
Other FASTA databases:
create_decoy_db(),
create_fgcz_fasta_db(),
load_contaminants(),
make_chain_id(),
make_chain_id_uniprot(),
make_fasta_summary(),
remove_signal_peptide(),
reverse_seq(),
write_fasta()
file <- system.file("extdata/fgcz_contaminants2021_20210929.fasta.gz", package = "prozor") fasta <- read_fasta(file) length(fasta) attributes(fasta[[1]])file <- system.file("extdata/fgcz_contaminants2021_20210929.fasta.gz", package = "prozor") fasta <- read_fasta(file) length(fasta) attributes(fasta[[1]])
Moves each window start down, and each window end up, to the mid of the nearest empty bin. A boundary already on
such a mid stays, so readjust_windows() returns its own result unchanged.
readjust_windows(windows, masses, bin_width = 0.1, min_count = 15)readjust_windows(windows, masses, bin_width = 0.1, min_count = 15)
windows |
A data frame or list with the columns |
masses |
Precursor masses (m/z): a numeric vector of finite values. |
bin_width |
Width of the bins (m/z) into which the masses are binned. |
min_count |
Bins with fewer than |
A data frame with one row per window and the columns from, to, mid, width and n_precursors
(precursors with from < m/z <= to).
Other DIA windows:
Cdsw,
masses,
plot_windows()
data(masses) cdsw <- Cdsw$new(masses, max_window = 100) windows <- cdsw$as_table() head(readjust_windows(windows, masses, min_count = 10))data(masses) cdsw <- Cdsw$new(masses, max_window = 100) windows <- cdsw$as_table() head(readjust_windows(windows, masses, min_count = 10))
Remove signal peptides from protein sequences
remove_signal_peptide(fasta, signal, id_fun = make_chain_id)remove_signal_peptide(fasta, signal, id_fun = make_chain_id)
fasta |
A list of UniProt protein sequences, as returned by |
signal |
A data frame with one row per entry of |
id_fun |
Function that makes the ID of the remaining chain from the protein sequence, its ID and the start of
the chain, e.g. |
fasta with the signal peptides removed. A shortened sequence gets the ID made by id_fun as its list
name, its name and the first word of its header; the rest of the header is kept.
Other FASTA databases:
create_decoy_db(),
create_fgcz_fasta_db(),
load_contaminants(),
make_chain_id(),
make_chain_id_uniprot(),
make_fasta_summary(),
read_fasta(),
reverse_seq(),
write_fasta()
file <- system.file("extdata/fgcz_contaminants2021_20210929.fasta.gz", package = "prozor") fasta <- read_fasta(file)[2:3] names(fasta) signal <- data.frame( Entry = c("Y-FGCZCont00001", "Y-FGCZCont00002"), Signal.peptide = c("SIGNAL 1 20", "") ) res <- remove_signal_peptide(fasta, signal) nchar(fasta[[1]]) nchar(res[[1]])file <- system.file("extdata/fgcz_contaminants2021_20210929.fasta.gz", package = "prozor") fasta <- read_fasta(file)[2:3] names(fasta) signal <- data.frame( Entry = c("Y-FGCZCont00001", "Y-FGCZCont00002"), Signal.peptide = c("SIGNAL 1 20", "") ) res <- remove_signal_peptide(fasta, signal) nchar(fasta[[1]]) nchar(res[[1]])
Counts, for every residue of the proteins in annotation, how many distinct peptide sequences cover it.
Repeated rows of the same peptide, such as several charge states from annotate_peptides(), count once. A
peptide that occurs twice in a protein covers both places, and where its occurrences overlap it counts once.
residue_coverage(annotation, peptide = "peptide_seq")residue_coverage(annotation, peptide = "peptide_seq")
annotation |
A data frame with the columns |
peptide |
Name of the column with the peptide sequences. |
A data frame with one row per residue of each protein in annotation, ordered by protein_id and
position: protein_id, position, residue and n_peptides, the number of peptides covering it; 0 rows
if annotation has none.
Other sequence coverage:
plot_coverage(),
sequence_coverage()
file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") annot <- annotate_peptides(peptides, read_fasta(fasta_file)) residues <- residue_coverage(annot) head(residues)file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") annot <- annotate_peptides(peptides, read_fasta(fasta_file)) residues <- residue_coverage(annot) head(residues)
Reverse protein sequences to create decoys
reverse_seq(fasta, rev_lab = "REV_")reverse_seq(fasta, rev_lab = "REV_")
fasta |
A list of |
rev_lab |
Prefix added to the names and headers of the reversed sequences. |
A list of reversed SeqFastaAA objects, named with the prefixed protein names.
Other FASTA databases:
create_decoy_db(),
create_fgcz_fasta_db(),
load_contaminants(),
make_chain_id(),
make_chain_id_uniprot(),
make_fasta_summary(),
read_fasta(),
remove_signal_peptide(),
write_fasta()
file <- system.file("extdata/fgcz_contaminants2021_20210929.fasta.gz", package = "prozor") fasta <- read_fasta(file) decoys <- reverse_seq(fasta) names(decoys)[1:3] # an entry as read_fasta() returns it tag <- structure( "DYKDDDDK", name = "Flag|FLAG|p2079", Annot = ">Flag|FLAG|p2079", class = "SeqFastaAA" ) reverse_seq(list(tag), rev_lab = "DECOY_")file <- system.file("extdata/fgcz_contaminants2021_20210929.fasta.gz", package = "prozor") fasta <- read_fasta(file) decoys <- reverse_seq(fasta) names(decoys)[1:3] # an entry as read_fasta() returns it tag <- structure( "DYKDDDDK", name = "Flag|FLAG|p2079", Annot = ">Flag|FLAG|p2079", class = "SeqFastaAA" ) reverse_seq(list(tag), rev_lab = "DECOY_")
Summarizes residue_coverage() per protein: how many distinct peptides match it and which fraction of its
residues they cover.
sequence_coverage(annotation, peptide = "peptide_seq")sequence_coverage(annotation, peptide = "peptide_seq")
annotation |
A data frame with the columns |
peptide |
Name of the column with the peptide sequences. |
A data frame with one row per protein, ordered by protein_id: protein_id, protein_length,
n_peptides (distinct peptides), n_covered (residues covered by at least one peptide) and coverage
(n_covered / protein_length); 0 rows if annotation has none.
Other sequence coverage:
plot_coverage(),
residue_coverage()
file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") annot <- annotate_peptides(peptides, read_fasta(fasta_file)) coverage <- sequence_coverage(annot) head(coverage[order(coverage$coverage, decreasing = TRUE), ])file <- system.file("extdata/IDResults.txt.gz", package = "prozor") peptides <- unique(utils::read.delim(file)$peptideSeq) fasta_file <- system.file("p1000_db1_example/Annotation_canSeq.fasta.gz", package = "prozor") annot <- annotate_peptides(peptides, read_fasta(fasta_file)) coverage <- sequence_coverage(annot) head(coverage[order(coverage$coverage, decreasing = TRUE), ])
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").
TargetDecoyFDR$new() returns a TargetDecoyFDR R6 object; see Methods.
larger_betterTRUE if a larger score is better (read-only).
nNumber of hits (read-only).
tableThe 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].
TargetDecoyFDR$new()Sort the hits from best to worst score and compute both FDR estimates and their q-values.
TargetDecoyFDR$new(score, decoy_hit, larger_better = TRUE, id = NULL)
scoreSearch engine scores, at least one, without NA.
decoy_hitLogical, TRUE for decoy hits, one per score, without NA.
larger_betterTRUE if a larger score is better, FALSE if a smaller score is better.
idIDs of the hits, e.g. protein IDs, one per score; NULL (default) for none.
A new TargetDecoyFDR object.
TargetDecoyFDR$print()Print the numbers of hits and decoys, larger_better, and the scores at fdr_simple q-values of 0.01 and 0.05
(none if no score reaches them).
TargetDecoyFDR$print(...)
...Not used.
The object, invisibly.
TargetDecoyFDR$score_at()Find the score cut-off for a given FDR.
TargetDecoyFDR$score_at(
q_value = 0.01,
method = c("fdr_simple", "fdr_concatenated")
)
q_valueThe FDR as a fraction, like the q-values in table: 0.01 for 1 %.
methodThe FDR estimate to use: "fdr_simple" (default) or "fdr_concatenated".
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.
TargetDecoyFDR$plot(bins = 100)
binsNumber of histogram bins.
A ggplot object.
TargetDecoyFDR$clone()The objects of this class are cloneable with this method.
TargetDecoyFDR$clone(deep = FALSE)
deepWhether to make a deep clone.
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
Other FDR:
bcd,
fdr_sample
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 head(fdr$table) fdr$score_at(q_value = 0.01) fdr$score_at(q_value = 0.01, method = "fdr_concatenated") fdr$plot() # larger scores are better fdr2 <- TargetDecoyFDR$new( fdr_sample$neg_log10_score, decoy_hit = grepl("^REV_", fdr_sample$protein_id) ) fdr2$score_at(q_value = 0.01) fdr2$plot()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 head(fdr$table) fdr$score_at(q_value = 0.01) fdr$score_at(q_value = 0.01, method = "fdr_concatenated") fdr$plot() # larger scores are better fdr2 <- TargetDecoyFDR$new( fdr_sample$neg_log10_score, decoy_hit = grepl("^REV_", fdr_sample$protein_id) ) fdr2$score_at(q_value = 0.01) fdr2$plot()
Writes each sequence with its Annot header and 60 residues per line. A header without the leading > gets one.
write_fasta(fasta, file)write_fasta(fasta, file)
fasta |
A list of |
file |
Path of the FASTA file to write. |
file, invisibly.
Other FASTA databases:
create_decoy_db(),
create_fgcz_fasta_db(),
load_contaminants(),
make_chain_id(),
make_chain_id_uniprot(),
make_fasta_summary(),
read_fasta(),
remove_signal_peptide(),
reverse_seq()
file <- system.file("extdata/fgcz_contaminants2021_20210929.fasta.gz", package = "prozor") fasta <- read_fasta(file) decoy_db <- c(fasta, reverse_seq(fasta)) out <- tempfile(fileext = ".fasta") write_fasta(decoy_db, out) length(read_fasta(out)) unlink(out)file <- system.file("extdata/fgcz_contaminants2021_20210929.fasta.gz", package = "prozor") fasta <- read_fasta(file) decoy_db <- c(fasta, reverse_seq(fasta)) out <- tempfile(fileext = ".fasta") write_fasta(decoy_db, out) length(read_fasta(out)) unlink(out)