Skip to contents

Adapted from singlecelljamboreeR compute_le_effects. The margin to the most extreme same-direction competitor includes zero. By default all factors compete. Distinctiveness depends on the recorded common scale and orientation.

Usage

factor_distinctiveness(
  fit,
  representation = NULL,
  engine = "singlecelljamboreeR",
  direction = "both",
  format = "long",
  compare_factors = NULL
)

Arguments

fit

Native fit or a view from standardize_factors().

representation

For a native fit: a matched view or standardize_factors() settings.

engine

singlecelljamboreeR selects the audited local implementation.

direction

"absolute" (default), "positive" or "negative": which effects are eligible.

format

long or matrix.

compare_factors

Optional competition pool; NULL uses all factors.

Value

Original estimate and distinctiveness separately, or margin matrix. Distinctiveness compares a feature's effect across factor columns, so it depends on how those columns are scaled. Use a view with scaling = "ldf" and d_location = "activity" (unit-norm effect columns) for a comparison on one scale; "raw" and "rms" scalings leave the columns on different scales, and a warning is given. The scaling and d_location are recorded in analysis_metadata$comparison_scaling.

Details

Origin: ADAPTED / modified. Credits compute_le_effects; use factor_provenance("factor_distinctiveness") for audited sources and runtime versions. Input units and basis are retained; display/conditional results do not establish biological replication.

Author

Peter Carbonetto; 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)
head(factor_distinctiveness(view))
}