Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can densMAP (in development version of Seurat) yield reproducible clustering? #9

Open
NicolaasVanRenne opened this issue Jul 16, 2021 · 3 comments

Comments

@NicolaasVanRenne
Copy link

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)

@NicolaasVanRenne NicolaasVanRenne changed the title densMAP reproducible? Can densMAP (in development version of Seurat) yield reproducible clustering? Jul 16, 2021
@alanocallaghan
Copy link
Contributor

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.

@alanocallaghan
Copy link
Contributor

alanocallaghan commented Oct 14, 2021

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.

@alanocallaghan
Copy link
Contributor

This is fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants