Skip to contents

Initial factors are backfitted before adding adaptive factors. Their IDs are retained even when native estimation zeros them. Only newly added factors are automatically nullchecked and removed. No intercept is added.

Usage

fit_initialized_ebmf(
  X,
  sample_side,
  activity_init,
  effect_init,
  activity_prior = ebnm::ebnm_point_normal,
  effect_prior = ebnm::ebnm_point_laplace,
  fixed_side = c("none", "activity", "effects"),
  add_factors = 0L,
  nullcheck_new = TRUE,
  S = NULL,
  var_type = 0L,
  id_policy = "require",
  feature_scale = "unknown",
  independent_unit = NULL,
  seed = NULL,
  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.

activity_init

Named finite samples by factors matrix.

effect_init

Named finite features by factors matrix, with identical factor names and order. Rows of both matrices are matched to X by ID.

activity_prior

Native EBNM function for activities.

effect_prior

Native EBNM function for effects.

fixed_side

none, activity or effects; fixes that side of all initial factors.

add_factors

Nonnegative upper bound on additional greedy factors.

nullcheck_new

Whether to nullcheck newly added factors.

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.

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.

seed

Optional integer; the caller's RNG state is restored afterwards.

verbose

Native flashier verbosity; 0 is silent.

control

Named S_dim, greedy, backfit and nullcheck settings; kset is protected for backfit/nullcheck so initialized factors cannot be bypassed.

Value

Native flash fit with stable initialized IDs, role metadata and input hashes. Stability refits require an explicit callback recreating initialization.

Details

Origin: WRAPPER / call_only; no upstream implementation source copied. Priors use semantic sample/feature order and map to native axes once. Recognized nonnegative priors require nonnegative initial values; custom prior support remains unknown. Neither initialized side may have a zero column.

Author

Mikhael Manurung. Native FLASH: Jason Willwerscheid, Peter Carbonetto, Wei Wang and Matthew Stephens. EBNM authors are listed in credits.

Examples

if (FALSE) {
A <- cbind(program = seq(-1, 1, length.out = 12))
B <- cbind(program = c(2, -1, 0, 1, 3, -2, 4, 0))
rownames(A) <- paste0("s", 1:12)
rownames(B) <- paste0("g", 1:8)
X <- tcrossprod(A, B)
fit <- fit_initialized_ebmf(X, "rows", A, B,
  fixed_side = "effects",
  seed = 4, verbose = 0, feature_scale = "simulated_intensity"
)
factor_effects(fit, representation = list(scaling = "raw"))
}