Compute mean, sd, and CV for all Peptides, or proteins, for all interactions and all samples.

Compute mean, sd, and CV for e.g. Peptides, or proteins, for all samples.

summarize stats output (compute quantiles)

summarize_stats(pdata, config, factor_key = config$table$factor_keys_depth())

summarize_stats_all(pdata, config)

summarize_stats_quantiles(
  stats_res,
  config,
  stats = c("sd", "CV"),
  probs = c(0.1, 0.25, 0.5, 0.75, 0.9)
)

Arguments

pdata

data.frame

config

AnalysisConfiguration

stats_res

result of running `summarize_stats`

stats

summarize either sd or CV

probs

for which quantiles 10, 20 etc.

all

also compute for all samples (default), or only of conditions (set to FALSE)

Examples



bb <- prolfqua::sim_lfq_data_protein_config()
#> creating sampleName from fileName column
#> completing cases
config <- bb$config
data <- bb$data

res1 <- summarize_stats(data, config)
#> [1] "group_"
#> completing cases

res2 <- prolfqua::sim_lfq_data_2Factor_config()
#> creating sampleName from fileName column
#> completing cases
res2$config$table$factorDepth <- 2
stats <- summarize_stats(res2$data, res2$config)
#> [1] "Treatment"  "Background"
#> completing cases
stopifnot(nrow(stats) == 40)

stats <- summarize_stats(res2$data, res2$config, factor_key = res2$config$table$factor_keys()[1])
#> [1] "Treatment"
#> completing cases
stopifnot(nrow(stats) == 20)
stats <- summarize_stats(res2$data, res2$config, factor_key = res2$config$table$factor_keys()[2])
#> [1] "Background"
#> completing cases
stopifnot(nrow(stats) == 20)
stats <- summarize_stats(res2$data, res2$config, factor_key = NULL)
#> NULL
#> completing cases
stopifnot(nrow(stats) == 10)



bb <- prolfqua::sim_lfq_data_protein_config()
#> creating sampleName from fileName column
#> completing cases

res1 <- summarize_stats_all(bb$data, bb$config)
#> NULL
#> completing cases

stopifnot((res1 |> dplyr::filter(group_ == "All") |> nrow()) == (res1 |> nrow()))
res2 <- prolfqua::sim_lfq_data_2Factor_config()
#> creating sampleName from fileName column
#> completing cases
resSt <- summarize_stats_all(res2$data, res2$config)
#> NULL
#> completing cases
library(ggplot2)
bb1 <- prolfqua::sim_lfq_data_peptide_config()
#> creating sampleName from fileName column
#> Warning: no nr_children column specified in the data, adding column nr_children and setting to 1.
#> completing cases
config <- bb1$config
data <- bb1$data
stats_res <- summarize_stats(data, config)
#> [1] "group_"
#> completing cases
sq <- summarize_stats_quantiles(stats_res, config)
sq <- summarize_stats_quantiles(stats_res, config, stats = "CV")
bb <- prolfqua::sim_lfq_data_peptide_config()
#> creating sampleName from fileName column
#> Warning: no nr_children column specified in the data, adding column nr_children and setting to 1.
#> completing cases
config <- bb$config
data <- bb$data
config$table$get_response()
#> [1] "abundance"
stats_res <- summarize_stats(data, config)
#> [1] "group_"
#> completing cases
sq <- summarize_stats_quantiles(stats_res, config)
sq <- summarize_stats_quantiles(stats_res, config, stats = "sd")
stats_res <- summarize_stats(data, config)
#> [1] "group_"
#> completing cases
xx <- summarize_stats_quantiles(stats_res, config, probs = seq(0,1,by = 0.1))
ggplot2::ggplot(xx$long, aes(x = probs, y = quantiles, color = group_)) + geom_line() + geom_point()