flashier utils

Interpret a flashier matrix
factorization. After one call you get a view: a named samples × factors
activity matrix and a named features × factors effects matrix that share factor
columns and reconstruct the fit. From a view you can rank the features that
drive each factor, plot activity across samples, summarize and test factors
against sample metadata, back-project a group contrast into feature units, and
check posterior uncertainty, stability and held-out prediction.
Installation
Requires R 4.3 or later and flashier 1.0.60 or later. The install pulls the
pinned flashier commit (willwerscheid/flashier@fd44811). CRAN flashier 1.0.7
is not enough: it rejects data with an all-missing row or column, which masked
factor_holdout() creates, and it lacks flash_plot_scree(). The committed
article tables and every recorded basis_id come from flashier 1.0.60.
install.packages("remotes")
remotes::install_github("mdmanurung/flashier-utils")
Optional packages unlock some functions: psych and clue for
factor_replicability() and factor_stability(); limma or variancePartition
for the matching test_factor_association() engines; gbcd for fit_gbcd_programs();
fastTopics for test_gom_de(); harmony for harmony_assignments(). Each page in the function reference names what
it needs.
Quick start
Use the GTEx association z-scores bundled with flashier. Tissues occupy columns;
SNP–gene pairs occupy rows.
library(flashier.utils)
data("gtex", package = "flashier")
set.seed(1)
fit <- flashier::flash(gtex, greedy_Kmax = 3, backfit = TRUE, verbose = 0)
view <- standardize_factors(fit, sample_side = "columns",
feature_scale = "association_z_score")
plot_factor_activity(view)
factor_features(view, factor = "F1", select = "largest", n = 5)
Your matrix needs unique row and column names. Tell standardize_factors()
which side holds samples and what the values measure; the package records both
and never preprocesses or rescales your data. Keep the native fit as well as
the view: uncertainty functions need the fit, everything else takes the view.
Workflow
| Step | Functions |
|---|
| Remove batch shifts before fitting | correct_feature_batch(), harmony_assignments() |
| Fit, or standardize an existing fit | fit_ebmf(), standardize_factors(), factor_activity(), factor_effects(), factor_pve() |
| Interpret factors | factor_features(), plot_factor_features(), plot_factor_weights(), plot_factor_activity(), plot_factor_scatter(), plot_factor_data(), plot_factor_embedding(), plot_factor_pve() |
| Relate factors to metadata | summarize_factor_activity(), compare_factor_groups(), test_factor_association(), backproject_contrast() |
| Check uncertainty and reproducibility | factor_uncertainty(), factor_intervals(), factor_stability(), factor_replicability(), factor_holdout() |
| Transfer programs to new data | project_factor_activity(), project_factor_features() |
Four focused tutorials
| Task | Tutorial |
|---|
| Beginner: native fit, extraction, features, one plot | Get started |
| Coordinates, uncertainty, group contrasts, nonnegative programs | Advanced use |
| Different priors: prediction, program agreement and known truth | Compare priors |
| Real-data interpretation and reference transfer | Pancreas programs |
The first uses bundled GTEx data; the middle two use explicit simulations.
The pancreas example uses attributed published Jamboree data, prepared once
outside package builds (about 86 MB downloaded):
FLASHIER_UTILS_PANCREAS_DIR=~/pancreas-example scripts/run-r.sh .github/scripts/prepare-pancreas.R