Determines relative protein abundances from ion quantification. Only proteins with at least three peptides are considered for quantification.

calculate_protein_abundance(
  data,
  sample,
  protein_id,
  precursor,
  peptide,
  intensity_log2,
  method = "iq",
  for_plot = FALSE,
  retain_columns = NULL
)

Arguments

data

a data frame that contains at least the input variables.

sample

a character column in the data data frame that contains the sample name.

protein_id

a character column in the data data frame that contains the protein accession numbers.

precursor

a character column in the data data frame that contains precursors.

peptide

a character column in the data data frame that contains peptide sequences. This column is needed to filter for proteins with at least 3 unique peptides. This can equate to more than three precursors. The quantification is done on the precursor level.

intensity_log2

a numeric column in the data data frame that contains log2 transformed precursor intensities.

method

a character value specifying with which method protein quantities should be calculated. Possible options include "sum", which takes the sum of all precursor intensities as the protein abundance. Another option is "iq", which performs protein quantification based on a maximal peptide ratio extraction algorithm that is adapted from the MaxLFQ algorithm of the MaxQuant software. Functions from the iq package are used. Default is "iq".

for_plot

a logical value indicating whether the result should be only protein intensities or protein intensities together with precursor intensities that can be used for plotting using qc_protein_abundance. Default is FALSE.

retain_columns

a vector indicating if certain columns should be retained from the input data frame. Default is not retaining additional columns retain_columns = NULL. Specific columns can be retained by providing their names (not in quotations marks, just like other column names, but in a vector).

Value

If for_plot = FALSE, protein abundances are returned, if for_plot = TRUE also precursor intensities are returned in a data frame. The later output is ideal for plotting with qc_protein_abundance and can be filtered to only include protein abundances.

Examples

# Create example data data <- data.frame( sample = c( rep("S1", 6), rep("S2", 6), rep("S1", 2), rep("S2", 2) ), protein_id = c( rep("P1", 12), rep("P2", 4) ), precursor = c( rep(c("A1", "A2", "B1", "B2", "C1", "D1"), 2), rep(c("E1", "F1"), 2) ), peptide = c( rep(c("A", "A", "B", "B", "C", "D"), 2), rep(c("E", "F"), 2) ), intensity = c( rnorm(n = 6, mean = 15, sd = 2), rnorm(n = 6, mean = 21, sd = 1), rnorm(n = 2, mean = 15, sd = 1), rnorm(n = 2, mean = 15, sd = 2) ) ) data
#> sample protein_id precursor peptide intensity #> 1 S1 P1 A1 A 14.22198 #> 2 S1 P1 A2 A 17.42079 #> 3 S1 P1 B1 B 15.46983 #> 4 S1 P1 B2 B 12.13064 #> 5 S1 P1 C1 C 13.15656 #> 6 S1 P1 D1 D 13.91581 #> 7 S2 P1 A1 A 19.84879 #> 8 S2 P1 A2 A 21.91756 #> 9 S2 P1 B1 B 19.31334 #> 10 S2 P1 B2 B 19.86415 #> 11 S2 P1 C1 C 20.92364 #> 12 S2 P1 D1 D 21.61400 #> 13 S1 P2 E1 E 17.27711 #> 14 S1 P2 F1 F 14.72923 #> 15 S2 P2 E1 E 14.20492 #> 16 S2 P2 F1 F 13.51658
# Calculate protein abundances protein_abundance <- calculate_protein_abundance( data, sample = sample, protein_id = protein_id, precursor = precursor, peptide = peptide, intensity_log2 = intensity, method = "iq", for_plot = FALSE ) protein_abundance
#> # A tibble: 2 × 3 #> sample intensity protein_id #> <chr> <dbl> <chr> #> 1 S1 14.2 P1 #> 2 S2 20.8 P1
# Calculate protein abundances and retain precursor # abundances that can be used in a peptide profile plot complete_abundances <- calculate_protein_abundance( data, sample = sample, protein_id = protein_id, precursor = precursor, peptide = peptide, intensity_log2 = intensity, method = "iq", for_plot = TRUE ) complete_abundances
#> # A tibble: 14 × 4 #> precursor sample intensity protein_id #> <chr> <chr> <dbl> <chr> #> 1 protein_intensity S1 14.2 P1 #> 2 protein_intensity S2 20.8 P1 #> 3 A1 S1 14.2 P1 #> 4 A1 S2 19.8 P1 #> 5 A2 S1 17.4 P1 #> 6 A2 S2 21.9 P1 #> 7 B1 S1 15.5 P1 #> 8 B1 S2 19.3 P1 #> 9 B2 S1 12.1 P1 #> 10 B2 S2 19.9 P1 #> 11 C1 S1 13.2 P1 #> 12 C1 S2 20.9 P1 #> 13 D1 S1 13.9 P1 #> 14 D1 S2 21.6 P1