Set.seed in Seurat
1
0
Entering edit mode
3.5 years ago
Laven9 • 0

I am trying to use Seurat for Sing-cell sequencing data analysis learning. Being told by somewhere else that if I use set.seed I will make my project repeatable. Then I use set.seed(42) before running seurat.

But recently I found if I use different number for set.seed, I will have different clusers for the same resolution of the object.

For example, if I use set.seed(42), I got 27 clusters. But I would have only 26 if I use set.seed(0) or set.seed(2020).

I am quite confused about it. Please give me some advice!

Seurat • 4.3k views
ADD COMMENT
0
Entering edit mode

Is this behaviour reproducible? The clustering algorithm should (by best knowledge) not have a random element (others may correct me) so the cluster number should stay the same. UMAP may look different yes, but this has nothing to do with the numbers of clusters.

ADD REPLY
0
Entering edit mode
3.5 years ago
fracarb8 ★ 1.6k

From the python implementation documentation:

UMAP is a stochastic algorithm – 
it makes use of randomness both to speed up approximation steps, and to aid in solving hard optimization problems. 
This means that different runs of UMAP can produce different results.

By setting the seed to a specific number (e.g. set.seed(42)), you are basically returning the same value instead of a random one.

Keep in mind that, by setting a seed, you are affecting the behaviour not only of Seurat, but of anything that uses pseudorandom numbers.

ADD COMMENT
0
Entering edit mode

Thank you so much for your advice!

So should I use RunTSNE(see.use=42) And FindCluster(random.seed=42) instead? OR just let it random?

BTW, how can I release the affect of set.seed(42) in my Rstudio?

ADD REPLY
0
Entering edit mode

you could set.seed(42) before running the commands, or you could put it at the beginning of the script.

ADD REPLY

Login before adding your answer.

Traffic: 2948 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6