Skip to contents

Get each factor's proportion of variance explained (PVE) as flashier computes it. Uses native second-moment and residual-variance semantics. This is not unique variance decomposition or held-out prediction R squared.

Usage

factor_pve(fit, factors = NULL)

Arguments

fit

Native flash fit or a view that carries native PVE.

factors

Optional character factor IDs in the order wanted. Default all.

Value

Table with columns factor, pve, definition and denominator. flashier's PVE is a share of the uncentred second moment of the data, not of variance around the mean. In a fit with a feature intercept (fit_ebmf(intercept = "feature")) the hidden intercept stays in that denominator, so the biological shares are smaller than shares of what the intercept leaves; denominator says which case applies ("second_moment" or "second_moment_including_intercept").

Details

Origin: WRAPPER / none. Credits native pve field; use factor_provenance("factor_pve") for audited sources and runtime versions. Input units and basis are retained; display/conditional results do not establish biological replication.

Author

Jason Willwerscheid; Peter Carbonetto; Wei Wang; Matthew Stephens. Full source and dependency credits: https://github.com/mdmanurung/flashier-utils/blob/main/CREDITS.md.

Examples

set.seed(3)
X <- tcrossprod(matrix(rnorm(48), 24, 2), matrix(rnorm(32), 16, 2)) +
  matrix(rnorm(384, sd = 0.2), 24, 16)
dimnames(X) <- list(paste0("s", 1:24), paste0("g", 1:16))
fit <- fit_ebmf(X, "rows",
  max_factors = 2, seed = 4, verbose = 0,
  ebnm_fn = list(ebnm::ebnm_normal, ebnm::ebnm_point_laplace),
  nullcheck = FALSE, backfit = TRUE, feature_scale = "simulated_centered_intensity"
)
view <- standardize_factors(fit)
factor_pve(fit)
#>   factor       pve      definition   denominator
#> 1     F1 0.5083222 flashier_native second_moment
#> 2     F2 0.4510312 flashier_native second_moment