Add exactly aligned cell activities to a Seurat reduction
Source:R/seurat.R
add_factors_to_seurat.RdAdd exactly aligned cell activities to a Seurat reduction
Value
Seurat object with basis metadata in reduction Misc. Loadings are added only when the assay and effects have exactly the same feature IDs.
Details
Origin: ADAPTED / call_only. Credits CreateDimReducObject workflow; AddLatentData conceptual context; use factor_provenance("add_factors_to_seurat") 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); Paul Hoffman; Rahul Satija; David Collins; Yuhan Hao; Austin Hartman; Gesmira Molla; Andrew Butler; Tim Stuart; Madeline Kowalski; Saket Choudhary; Skylar Li; Longda Jiang; Anagha Shenoy; Jeff Farrell; Shiwei Zheng; Christoph Hafemeister; Patrick Roelli (SeuratObject). 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)
SeuratObject::Embeddings(object[["ebmf"]])[1:3, , drop = FALSE]
}