Skip to contents

Each candidate uses a distinct native initializer seed. Native-random starts preserve audited prior sign constraints. softImpute and IRLBA starts require signed priors on both native sides; IRLBA also requires dense complete input. Candidate failures are retained. ELBO ranks optimization solutions under the fitted model and does not measure biological interpretability or uncertainty.

Usage

fit_multistart_ebmf(
  X,
  sample_side,
  ebnm_fn = ebnm::ebnm_point_normal,
  S = NULL,
  var_type = 0L,
  max_factors = 50L,
  backfit = FALSE,
  nullcheck = TRUE,
  id_policy = "require",
  feature_scale = "unknown",
  independent_unit = NULL,
  n_starts = 10L,
  init_method = c("native_random", "softImpute", "irlba"),
  init_seeds = NULL,
  seed = NULL,
  select = c("elbo", "none"),
  keep_fits = TRUE,
  verbose = 1L,
  control = list()
)

Arguments

X

Named numeric matrix or double sparse Matrix; NA is observed missingness. Only dimnames are kept; other attributes are dropped.

sample_side

"rows" or "columns": which side holds samples. Required.

ebnm_fn

Prior family: one ebnm::ebnm_* function for both sides, or a list of two in native row/column order (not sample/feature order). Default ebnm::ebnm_point_normal. Use ebnm_point_exponential for nonnegative sides.

S

Optional known observation standard errors (scalar, vector or matrix). NULL (default) estimates noise from the data.

var_type

Residual variance structure passed to flashier: 0L (default) one constant, 1L per row, 2L per column, c(1L, 2L) both (in that order), NULL none, which requires S. With one constant variance (0L), features measured on larger scales dominate the fit, so use 2L or rescale the features first. No centering is assumed; an intercept is available through intercept.

max_factors

Positive bound on each candidate's greedy rank.

backfit

Run the native backfit after greedy addition (default FALSE).

nullcheck

Drop factors that do not improve the objective (default TRUE).

id_policy

"require" (default) stops on missing dimnames; "generate" creates them.

feature_scale

Free-text label for what the matrix values measure, e.g. "log1p_normalized_counts". Default "unknown". Recorded, never applied.

independent_unit

Optional free-text description of the biological replicate, e.g. "donor"; recorded, not inferred.

n_starts

Integer number of candidates, at least two.

init_method

native_random, softImpute or irlba.

init_seeds

Optional unique nonnegative integer initializer seeds, one per candidate. Supply these or a master seed.

seed

Optional scoped master seed used to generate initializer seeds.

select

elbo chooses the largest finite native ELBO; exact ties choose the smallest start ID. none leaves best_fit and selected_start unset.

keep_fits

Retain all successful native candidates; the selected best_fit is available even when FALSE.

verbose

Native flashier verbosity; 0 is silent.

control

Native pipeline settings; greedy init_fn is owned by this wrapper.

Value

A multistart_result with best_fit, selected_start, candidates, optional fits and analysis_metadata. All-fail errors retain their candidates table. Candidate digests identify numerical coordinates and exclude elapsed time and time-based fit IDs. Initializer traces include native validation probes. Stability refits require an explicit callback for the full selection recipe.

Author

Mikhael Manurung; native FLASH authors Jason Willwerscheid, Peter Carbonetto, Wei Wang and Matthew Stephens. No native source is copied. Optional initializers: Trevor Hastie, Rahul Mazumder and Balasubramanian Narasimhan (softImpute); Jim Baglama, Lothar Reichel and B. W. Lewis (irlba).

Examples

if (FALSE) {
set.seed(3)
X <- matrix(rnorm(192), 16, 12,
  dimnames = list(paste0("s", 1:16), paste0("g", 1:12))
)
starts <- fit_multistart_ebmf(X, "rows",
  n_starts = 2, max_factors = 1,
  seed = 4, verbose = 0
)
starts$candidates[, c("start", "init_seed", "status", "rank", "elbo", "selected")]
}