densvis
densvis copied to clipboard
Can densMAP (in development version of Seurat) yield reproducible clustering?
I"m running densMAP in the development version of Seurat, and it seems to work (hallelujah!) but the clustering is not reproducible. If I run the same pipeline twice over, the clustering is similar yet different. Is there a way to make it reproducible?
setting the seed doesn't help. Is this intrinsic to the densMAP algorithm? Or is there a way to make it reproducible?
thanks,
Nicolaas
ps command I run is: RunUMAP(MySeuratObject, dims = 1:UMAP.dimensions, densmap=TRUE)
This'll be because the seed is controlled in python, which has a separate RNG stream to R. Setting the R seed doesn't affect the python one.
https://github.com/satijalab/seurat/blob/13b615c27eeeac85e5c928aa752197ac224339b9/R/dimensional_reduction.R#L1298
If you want reproducible densmap in R might I suggest using densvis? Otherwise flag the issue with the Seurat team, as I'm fairly sure the issue isn't with the densmap algorithm itself.
eg,
library("densvis")
set.seed(42)
x <- matrix(rnorm(200), ncol=2)
d1 <- densmap(x, random_state = 42L)
d2 <- densmap(x, random_state = 42L)
identical(d1, d2)
# TRUE
vs
library(Seurat)
data("pbmc_small")
set.seed(42)
pbmc_small1 <- RunUMAP(pbmc_small, dims = 1:5, densmap = TRUE)
set.seed(42)
pbmc_small2 <- RunUMAP(pbmc_small, dims = 1:5, densmap = TRUE)
identical(Embeddings(Reductions(pbmc_small1, "umap")), Embeddings(Reductions(pbmc_small2, "umap")))
# FALSE
densvis also uses basilisk which means the umap version is conda-controlled.
This is fixed now