Heatmap or bar chart of the top features for one or more factors, selected
as in factor_features(). Independent signed-safe adaptation of the ZemmourLib tile workflow. The
displayed values use the declared matched representation, never positive-only.
Usage
plot_factor_features(
fit,
factors,
representation = NULL,
select = "largest",
n = 20L,
style = "heatmap",
compare_factors = NULL,
features = NULL,
direction = "absolute",
display_normalization = "none",
transpose = FALSE,
annotation = NULL,
...
)Arguments
- fit
Native fit or a view from
standardize_factors().- factors
Character factor IDs to display, e.g.
c("F1", "F2").- representation
For a native fit: a matched view or
standardize_factors()settings.- select
Per-factor
largest/distinctive/both(seefactor_features()) orglobalfor cross-factor selection bymax_k(abs(effect))over the given factors (seefactor_features_global()).- n
Maximum number of features per selection (default 20).
- style
"heatmap"(default) or"bar".- compare_factors
Optional character factor IDs that compete for
"distinctive";NULLuses all other factors.- features
Optional character feature IDs to show instead of a ranked selection.
- direction
"absolute"(default),"positive"or"negative".- display_normalization
"none"(default, effect units) or"max_abs"(scale each factor to max 1 for display only).- transpose
Put features on the x axis (default
FALSE).- annotation
Optional named numeric vector, one value per factor, shown as a strip; e.g. correlations.
- ...
Optional
palette(negative, zero, positive colours) andlimits.
Details
Origin: ADAPTED / none. Credits MyGeneTilePlot workflow; native flashier optional; use factor_provenance("plot_factor_features") for audited sources and runtime versions. Input units and basis are retained; display/conditional results do not establish biological replication.
Author
David Zemmour. 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)
plot_factor_features(view, factors = "F1", n = 3)