Skip to contents

Reorder native factors by exact named permutation

Usage

reorder_factors(fit, order)

Arguments

fit

Native flash fit.

order

Exact permutation of retained factor IDs.

Value

Native fit with stable identities in requested order.

Details

Origin: WRAPPER / call_only. Credits flash_factors_reorder; use factor_provenance("reorder_factors") 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

if (FALSE) {
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)
reordered <- reorder_factors(fit, rev(view$manifest$factor_ids))
colnames(factor_activity(reordered))
}