The data container of prolfqua: one table in long format, one row per feature (for example peptide) and sample,
plus an AnalysisConfiguration that names the hierarchy, factor, sample and response columns. Its decorators
(get_Transformer(), get_Aggregator(), get_Stats(), get_Plotter(), get_Summariser()) transform, aggregate,
summarise and plot the data, and build_contrast_analysis() fits models to it.
Missing Data Assumptions
The filtering and imputation methods in this package assume that
missing values are Missing Completely At Random (MCAR) or Missing At
Random (MAR). Abundance-dependent missingness (MNAR), which is common
in DDA proteomics, is not modelled. When low intensities are missing,
fold changes of down-regulated proteins shrink toward zero; LOD imputation
(the _impute methods) caps estimates at the LOD and does not remove
this bias. MNAR can also inflate false discovery rates. How NA,
zero and non-finite intensities are treated is described in
prolfqua-package, section "Missing and non-finite values".
Methods
LFQData$new()
initialize
Usage
LFQData$new(data, config, prefix = "ms_", setup = FALSE, provenance = NULL)Arguments
datalong-format data.frame, tibble or data.table; stored as a tibble
configAnalysisConfiguration naming the column roles
prefixone character string, used as output prefix
setupone TRUE/FALSE, default FALSE; TRUE calls
setup_analysison data firstprovenanceinternal: record of an LFQData this one continues (the same data transformed or subset); a copy is kept. NULL starts a new record.
LFQData$provenance()
problems and dropped items recorded for this data: values set to NA, rows, features or proteins removed
LFQData$get_provenance_log()
internal: the record this data continues, passed to LFQData$new() for derived data
LFQData$print()
print samples, response, hierarchy counts, samples per factor level, missing responses and provenance
LFQData$is_aggregatable()
can the data be aggregated, i.e. is there a hierarchy level below the
modelled one (hierarchy_depth)
LFQData$remove_small_intensities()
some software is reporting NA's as 0, you must remove it from your data
LFQData$filter_proteins_by_peptide_count()
remove parents (e.g. proteins) with fewer than threshold distinct
children (e.g. peptides) and add the count as a column. By default the
second hierarchy level is counted within the first, independent of
hierarchy_depth; a hierarchy with one level is an error.
LFQData$remove_decoys()
remove decoy / reverse-database entries (rows whose top-level hierarchy id,
e.g. protein_Id, is a decoy). Detection uses the configured
pattern_decoys unioned with the built-in defaults (see
is_decoy); decoys are always detectable even when no pattern
is configured. Returns a new decoy-free LFQData (self is not modified).
LFQData$remove_contaminants()
remove contaminant entries (rows whose top-level hierarchy id, e.g.
protein_Id, is a contaminant). Detection uses the configured
pattern_contaminants unioned with the built-in defaults (see
is_contaminant). Returns a new contaminant-free LFQData
(self is not modified).
LFQData$decoy_proportion()
proportion of modelling-level keys (subject_id, e.g. protein or peptide by
hierarchy_depth) that are decoys - an empirical-FDR / target-decoy QC
signal. Decoy status derives from the top-level hierarchy id (protein_Id).
LFQData$data_wide()
converts the data to wide
LFQData$relevant_hierarchy_keys()
return hierarchy column names at current depth (alias for subject_id)
LFQData$rename_response()
new name of response variable. Renaming to the current response name changes nothing; renaming to another existing column is an error.
LFQData$get_Stats()
Get LFQDataStats. For more details see LFQDataStats.
Usage
LFQData$get_Stats(stats = c("everything", "interaction", "all"))LFQData$get_Aggregator()
get Aggregator
Examples
istar <- sim_lfq_data_peptide_config()
#> `protein_Id`: columns `proteinID`, `idtype2` united with separator '~'.
#> creating sampleName from file_name column
#> setup_analysis: dropped 6 unconfigured columns: average_prot_abundance, sd, mean, N, avg_peptide_abd, Replicate.
#> setup_analysis: added 36 rows with NA response for feature and sample combinations absent from the input.
lfqdata <- LFQData$new(istar$data, istar$config)
lfqdata$filter_proteins_by_peptide_count()
#> filter_proteins_by_peptide_count: column added: nr_peptide_Id_IN_protein_Id
#> filter_proteins_by_peptide_count: 4 protein_Id removed (e.g. 7cbcrd~5725, 9VUkAq~4703, CGzoYe~2147, DoWup2~5896): fewer than 2 peptide_Id
#> See $provenance().
tmp <- lfqdata$data_wide()
stopifnot(nrow(tmp$data) == nrow(tmp$rowdata))
stopifnot(ncol(tmp$data) == nrow(tmp$annotation) + ncol(tmp$rowdata))
stopifnot("data.frame" %in% class(tmp$data))
tmp <- lfqdata$data_wide(as.matrix = TRUE)
stopifnot("matrix" %in% class(tmp$data))
stopifnot(lfqdata$is_transformed()==FALSE)
lfqdata$summarize_hierarchy()
#> # A tibble: 6 × 2
#> protein_Id peptide_Id_n
#> <chr> <int>
#> 1 0EfVhX~0087 3
#> 2 BEJI92~5282 2
#> 3 Fl4JiV~8625 4
#> 4 HvIpHG~9079 2
#> 5 JcKVfU~9653 7
#> 6 SGIVBl~5782 6
lfqdata$response()
#> [1] "abundance"
lfqdata$rename_response("peptide.intensity")
lfqdata$response()
#> [1] "peptide.intensity"
stopifnot("LFQData" %in% class(lfqdata$get_copy()))
stopifnot("LFQDataTransformer" %in% class(lfqdata$get_Transformer()))
stopifnot("LFQDataStats" %in% class(lfqdata$get_Stats()))
stopifnot("LFQDataSummariser" %in% class(lfqdata$get_Summariser()))
stopifnot("LFQDataPlotter" %in% class(lfqdata$get_Plotter()))
stopifnot("AggregateMedpolish" %in% class(lfqdata$get_Aggregator("medpolish")))
#> Warning: You did not transform the intensities. medpolish works best with already variance stabilized intensities. Use LFQData$get_Transformer to transform the data: peptide.intensity
tmp <-lfqdata$get_sample(5, seed = 4)
stopifnot(nrow(tmp$hierarchy()) == 5)