Skip to contents

Embed declared factor coordinates using native uwot

Usage

embed_factors(
  object,
  reduction = "ebmf",
  method = "umap",
  dims = NULL,
  seed = NULL,
  overwrite = FALSE,
  ...
)

Arguments

object

Seurat object containing a factor reduction.

reduction

Source factor reduction.

method

Only umap is supported.

dims

Explicit unique positive source dimension indices; NULL uses all.

seed

Optional scoped RNG seed, also passed to native uwot.

overwrite

Replace an existing output reduction explicitly.

...

Native uwot settings, plus reduction_name (default source name + umap).

Value

Seurat object with exploratory embedding and resolved settings in Misc.

Details

Origin: WRAPPER / call_only. Credits Seurat/uwot public embedding APIs; use factor_provenance("embed_factors") for audited sources and runtime versions. Input units and basis are retained; display/conditional results do not establish biological replication.

Author

David Zemmour / Zemmour Lab (ImmGenT workflows); James Melville and uwot contributors (full list in credits article). 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)
# Adapter mechanics on simulated cells; no biological inference.
counts <- Matrix::Matrix(matrix(1, 16, 24, dimnames = list(colnames(X), rownames(X))), sparse = TRUE)
object <- SeuratObject::CreateSeuratObject(counts, assay = "panel")
object <- add_factors_to_seurat(object, view)
object <- embed_factors(object, seed = 4, n_neighbors = 4, n_epochs = 20, init = "random")
SeuratObject::Embeddings(object[["ebmfumap"]])[1:3, , drop = FALSE]
}