Variance explained by each term, pooled over features
Source:R/tidyMS_variance_explained.R
pooled_variance_explained.RdSums the sums of squares of summarize_variance_explained() over features.
For each term the result is sum(Sum.Sq) / sum(SS_total); one minus the
share of the residuals is the pooled R^2. On features without missing values
the pooled R^2 equals the PERMANOVA R^2 with Euclidean distances between
samples. Features with a large total variance weigh more than in the median
of the per-feature R2.
Arguments
- x
the tibble returned by
summarize_variance_explained().
Value
A data.frame with columns factor and eta2, one row per term in
the order of the ANOVA table, residuals included.
Examples
bb <- prolfqua::sim_lfq_data_2factor_config(n_proteins = 20)
#> `protein_Id`: columns `proteinID`, `idtype2` united with separator '~'.
#> creating sampleName from file_name column
#> setup_analysis: dropped 6 unconfigured columns: average_prot_abundance, sd, group, mean, N, Replicate.
#> setup_analysis: added 44 rows with NA response for feature and sample combinations absent from the input.
bb$config$factor_depth <- 2
lfqdata <- LFQData$new(bb$data, bb$config)
lfqdata$is_transformed(TRUE)
pooled <- pooled_variance_explained(summarize_variance_explained(lfqdata))
#> fit (Model): 44 missing responses dropped (e.g. 0EfVhX~5954, 0m5WN4~1448, 7cbcrd~8305, 9VUkAq~4562, At886V~3296, ...): NA response (missing observation) left out of the fit
#> See $provenance().
pooled
#> factor eta2
#> 1 Treatment 0.4180986
#> 2 Background 0.1680539
#> 3 Treatment:Background 0.1393417
#> 4 Residuals 0.2745057
# pooled R^2
1 - pooled$eta2[pooled$factor == "Residuals"]
#> [1] 0.7254943