Run cell-feature coembedding for SRT data based on FAST model.
NCFM_fast(
object,
Adj_sp,
assay = NULL,
slot = "data",
nfeatures = 2000,
q = 10,
reduction.name = "fast",
var.features = NULL,
...
)
a Seurat object.
a sparse matrix, specify the adjacency matrix among spots.
an optional string, the name of assay used.
an optional string, the name of slot used.
an optional postive integer, the number of features to select as top variable features. Default is 2000.
an optional positive integer, specify the dimension of low dimensional embeddings to compute and store. Default is 10.
an optional string, dimensional reduction name, `fast` by default.
an optional string vector, specify the variable features, used to calculate cell embedding.
Other argument passed to the FAST_run
.
data(CosMx_subset)
pos <- as.matrix(CosMx_subset@meta.data[,c("x", "y")])
Adj_sp <- AddAdj(pos)
#> The spatial cooridnates are 2 dimensions
#> Find the adjacency matrix by bisection method...
#> Current radius is 70.16
#> Median of neighborhoods is 0
#> Current radius is 104.73
#> Median of neighborhoods is 2
#> Current radius is 104.73
#> Median of neighborhoods is 6
# Here, we set maxIter = 3 for fast computation and demonstration.
CosMx_subset <- NCFM_fast(CosMx_subset, Adj_sp = Adj_sp, maxIter=3)
#> Finish variable intialization
#> Satrt ICM and E-step!
#> Finish ICM and E-step!
#> iter = 2, loglik= -1408612.960642, dloglik=0.999344
#> Satrt ICM and E-step!
#> Finish ICM and E-step!
#> iter = 3, loglik= -1404516.571078, dloglik=0.002908
#> 2024-03-17 18:26:40 : ***** Finish CoFAST, 0.04 mins elapsed.