prolfqua works on one table in
long format, one row per feature (protein, peptide or precursor) and
sample, together with an AnalysisConfiguration that says
which column holds what. This vignette builds both from a table you
already have.
For the output of common quantification software, the prolfquapp package has
readers that return a ready LFQData object together with
the protein annotation:
prolfquapp::preprocess_DIANN()prolfquapp::preprocess_MQ_peptide()prolfquapp::preprocess_BGS()prolfquapp::preprocess_FP_PSM()prolfquapp::preprocess_MSstats()They need the FASTA file used for the search. prolfquapp is installed
from GitHub; see its README. The rest of this vignette shows how to
build an LFQData object from any other table.
Frequently, the data are available in tables where the rows are proteins and the columns are samples. In the example, the first column holds the protein identifier and the other columns the intensities of samples A to D.
df <- data.frame(
protein_Id = c("tr|A|HUMAN", "tr|B|HUMAN", "tr|C|HUMAN", "tr|D|HUMAN"),
Intensity_A = c(100, 10000, 10, NA),
Intensity_B = c(NA, 9000, 20, 100),
Intensity_C = c(200, 8000, NA, 150),
Intensity_D = c(130, 11000, 50, 50)
)
df## protein_Id Intensity_A Intensity_B Intensity_C Intensity_D
## 1 tr|A|HUMAN 100 NA 200 130
## 2 tr|B|HUMAN 10000 9000 8000 11000
## 3 tr|C|HUMAN 10 20 NA 50
## 4 tr|D|HUMAN NA 100 150 50
This table can be converted into a table in long format:
table_long <- tidyr::pivot_longer(df, dplyr::starts_with("Intensity_"), names_to = "Sample", values_to = "Intensity")
table_long## # A tibble: 16 × 3
## protein_Id Sample Intensity
## <chr> <chr> <dbl>
## 1 tr|A|HUMAN Intensity_A 100
## 2 tr|A|HUMAN Intensity_B NA
## 3 tr|A|HUMAN Intensity_C 200
## 4 tr|A|HUMAN Intensity_D 130
## 5 tr|B|HUMAN Intensity_A 10000
## 6 tr|B|HUMAN Intensity_B 9000
## 7 tr|B|HUMAN Intensity_C 8000
## 8 tr|B|HUMAN Intensity_D 11000
## 9 tr|C|HUMAN Intensity_A 10
## 10 tr|C|HUMAN Intensity_B 20
## 11 tr|C|HUMAN Intensity_C NA
## 12 tr|C|HUMAN Intensity_D 50
## 13 tr|D|HUMAN Intensity_A NA
## 14 tr|D|HUMAN Intensity_B 100
## 15 tr|D|HUMAN Intensity_C 150
## 16 tr|D|HUMAN Intensity_D 50
In addition you need a table with the sample annotation. In this example there are three groups, A, B and C.
annot <- data.frame(
Sample = c("Intensity_A", "Intensity_B", "Intensity_C", "Intensity_D"),
Group = c("A", "A", "B", "C")
)Join the annotation to the intensities. Protein-level data should also say from how many peptides each protein intensity was computed in each sample; some methods use this count as a weight. It is unknown here, so it is set to 1.
Create an AnalysisConfiguration and name the columns:
which one identifies the sample and which one holds the intensities.
config <- prolfqua::AnalysisConfiguration$new()
config$file_name <- "Sample"
config$work_intensity <- "Intensity"The columns identifying the measured features, which are proteins,
peptides or precursors, are described using the named list
hierarchy. The values of the list are the column names,
while the names are arbitrary as long as they are valid R column names.
Here we use the same names as the column names.
The list factors points to the columns with the
explanatory variables of the analysis (Group).
setup_analysis() checks the table against the
configuration and completes it, and LFQData$new() creates
the data object.
analysis_data <- prolfqua::setup_analysis(table_long, config)
lfqdata <- prolfqua::LFQData$new(analysis_data, config)## # A tibble: 1 × 1
## protein_Id
## <int>
## 1 4
When the intensities are already a matrix, with features in rows and
samples in columns, plus a table describing the rows and one describing
the samples, lfqdata_from_wide() builds the
LFQData object directly. It is the inverse of
LFQData$data_wide(as.matrix = TRUE); row i of
the matrix belongs to row i of the row table.
intensities <- as.matrix(df[, -1])
rowdata <- data.frame(protein_Id = df$protein_Id)
samples <- data.frame(
sampleName = annot$Sample,
Sample = annot$Sample,
Group = annot$Group
)
children <- matrix(1L, nrow = nrow(intensities), ncol = ncol(intensities), dimnames = dimnames(intensities))
from_wide <- prolfqua::lfqdata_from_wide(
list(Intensity = intensities, nr_children = children),
rowdata,
samples,
config
)
from_wide$hierarchy_counts()## # A tibble: 1 × 1
## protein_Id
## <int>
## 1 4
Long tables, such as the reports of Spectronaut, Skyline or DIA-NN, need only a configuration. Here a simulated peptide table stands in for such a report:
dataLongFormat <- prolfqua::sim_lfq_data(level = "peptide", n_proteins = 20, with_missing = FALSE)$data
dataLongFormat <- dataLongFormat[, c("sample", "group_", "protein_Id", "peptide_Id", "abundance")]
head(dataLongFormat)## # A tibble: 6 × 5
## sample group_ protein_Id peptide_Id abundance
## <chr> <chr> <chr> <chr> <dbl>
## 1 A_V1 A 0EfVhX~5954 jsxCTNN1 30.0
## 2 A_V1 A 0m5WN4~1448 UwJbtbRY 17.0
## 3 A_V1 A 0m5WN4~1448 wpHqGLYB 18.8
## 4 A_V1 A 7cbcrd~8305 O9LMQBev 29.0
## 5 A_V1 A 9VUkAq~4562 6mb5eKpF 12.9
## 6 A_V1 A 9VUkAq~4562 AYQOqCVO 15.9
The sample is in the column sample and the intensity in
abundance. Each row is one peptide, so it counts as one
child of its protein:
dataLongFormat$nr_children <- 1L
config <- prolfqua::AnalysisConfiguration$new()
config$file_name <- "sample"
config$work_intensity <- "abundance"The hierarchy has two levels here, protein and peptide. The names of
factors are the names used in model formulas, figures and
legends; they can differ from the column names, for example
config$factors[["Condition"]] <- "R.Condition" for a
Spectronaut report. A table can hold several factors.
config$hierarchy[["protein_Id"]] <- "protein_Id"
config$hierarchy[["peptide_Id"]] <- "peptide_Id"
config$factors[["group"]] <- "group_"setup_analysis() creates from the long table a table
that matches the configuration, and LFQData$new() the data
object, which is the start of every further analysis.
analysis_data <- prolfqua::setup_analysis(dataLongFormat, config)
lfqdata <- prolfqua::LFQData$new(analysis_data, config)
lfqdata$summarize_hierarchy()## # A tibble: 20 × 2
## protein_Id peptide_Id_n
## <chr> <int>
## 1 0EfVhX~5954 1
## 2 0m5WN4~1448 2
## 3 7cbcrd~8305 1
## 4 9VUkAq~4562 16
## 5 At886V~3296 5
## 6 BEJI92~9143 4
## 7 CGzoYe~2857 1
## 8 CtOJ9t~2837 5
## 9 DoWup2~2934 7
## 10 DuwH7n~3402 3
## 11 Fl4JiV~7526 1
## 12 HC8K98~4958 2
## 13 HvIpHG~4015 2
## 14 I1Jk2Z~0821 10
## 15 JV3Z7t~2956 1
## 16 JcKVfU~0815 1
## 17 JfvT8X~2727 11
## 18 R2i6w7~0288 2
## 19 SGIVBl~9558 2
## 20 r2J0Eh~2687 1
With this, it is possible for example to use the
get_Summariser function to visualize and summarise the
data.
Number of peptides found in each sample
The prolfqua package is described in (Wolski et al.
2023).
## R version 4.6.2 (2026-10-29)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] prolfqua_1.10.0 dplyr_1.2.1 BiocStyle_2.43.0
##
## loaded via a namespace (and not attached):
## [1] tidyselect_1.2.1 viridisLite_0.4.3 farver_2.1.2
## [4] S7_1.0.0 fastmap_1.2.0 promises_1.5.0
## [7] digest_0.6.39 mime_0.13 lifecycle_1.0.5
## [10] cluster_2.1.8.3 statmod_1.5.2 magrittr_2.0.5
## [13] compiler_4.6.2 progress_1.2.3 rlang_1.3.0
## [16] sass_0.5.0 tools_4.6.2 utf8_1.2.6
## [19] yaml_2.3.12 data.table_1.18.6.1 knitr_1.52
## [22] prettyunits_1.2.0 labeling_0.4.3 htmlwidgets_1.6.4
## [25] RColorBrewer_1.1-3 KernSmooth_2.23-27 withr_3.0.3
## [28] purrr_1.2.2 BiocGenerics_0.61.1 sys_3.4.3
## [31] grid_4.6.2 stats4_4.6.2 xtable_1.8-8
## [34] colorspace_2.1-4 ggplot2_4.0.5 scales_1.4.0
## [37] iterators_1.0.14 MASS_7.3-66 cli_3.6.6
## [40] rmarkdown_2.32 crayon_1.5.3 generics_0.1.4
## [43] otel_0.3.0 httr_1.4.9 rjson_0.2.23
## [46] cachem_1.1.0 stringr_1.6.0 parallel_4.6.2
## [49] BiocManager_1.30.27 matrixStats_1.5.0 vctrs_0.7.3
## [52] jsonlite_2.0.0 hms_1.1.4 IRanges_2.49.0
## [55] GetoptLong_1.1.1 S4Vectors_0.53.1 ggrepel_0.9.8
## [58] clue_0.3-68 maketools_1.3.2 crosstalk_1.2.2
## [61] foreach_1.5.2 limma_4.1.3 plotly_4.12.1
## [64] tidyr_1.3.2 jquerylib_0.1.4 glue_1.8.1
## [67] codetools_0.2-20 stringi_1.8.9 gtable_0.3.6
## [70] shape_1.4.6.1 later_1.4.8 ComplexHeatmap_2.31.0
## [73] tibble_3.3.1 pillar_1.11.1 htmltools_0.5.9
## [76] circlize_0.4.18 R6_2.6.1 doParallel_1.0.17
## [79] evaluate_1.0.5 shiny_1.15.0 png_0.1-9
## [82] httpuv_1.6.17 bslib_0.12.0 Rcpp_1.1.2
## [85] gridExtra_2.3.1 xfun_0.63 buildtools_1.0.0
## [88] pkgconfig_2.0.3 GlobalOptions_0.1.4