Closed rekren closed 1 year ago
Hi,
Not member of dev team but curious. Does this effect occur when using louvain algorithm for clustering or just when using Leiden?
Best, Sam
Hi Samuel,
Thanks for your interest. To address your curiosity, I also run;
FindClusters(object = seurat_object, algorithm =1,resolution= 0.5, random.seed = 2206,verbose = T )
and
FindClusters(object = seurat_object, algorithm =1,resolution= seq(0.1,1,0.1), random.seed = 2206,verbose = T )
For the resolution 0.5, the results are not overlapping, again.
P.S: For default Louvain parameters, cluster names start from "0" if you give constant resolution, but if it's a sequence of values, cluster names start from "1".
You can try with your data, too.
Hi,
So just quick look at things myself and at least with basic attempt I can't seem to replicate the issue. Can you provide full code for reprex with example data? Below is what I ran and every time the results of identical()
were TRUE.
Best, Sam
pbmc <- pbmc3k.SeuratData::pbmc3k
pbmc <- pbmc %>% NormalizeData() %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA() %>% FindNeighbors()
pbmc_val <- pbmc
pbmc_val_igraph <- pbmc
pbmc_seq <- pbmc
pbmc_seq_igraph <- pbmc
pbmc_val <- FindClusters(object = pbmc_val, resolution = 0.5)
pbmc_seq <- FindClusters(object = pbmc_seq, resolution = seq(0.1, 1,0.1))
identical(pbmc_val@meta.data$RNA_snn_res.0.5, pbmc_seq@meta.data$RNA_snn_res.0.5)
pbmc_val_igraph <- FindClusters(object = pbmc_val, resolution = 0.5, method = "igraph")
pbmc_seq_igraph <- FindClusters(object = pbmc_seq, resolution = seq(0.1, 1,0.1), method = "igraph")
identical(pbmc_val_igraph@meta.data$RNA_snn_res.0.5, pbmc_seq_igraph@meta.data$RNA_snn_res.0.5)
# Using harmony
pbmc_har <- pbmc3k.SeuratData::pbmc3k
pbmc_har$id <- sample(c("sample1", "sample2", "sample3", "sample4", "sample5", "sample6"), size = ncol(pbmc_har),
replace = TRUE)
pbmc_har <- pbmc_har %>% NormalizeData() %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA()
pbmc_har <- harmony::RunHarmony(object = pbmc_har, group.by.vars = "id")
pbmc_har <- FindNeighbors(pbmc_har,reduction = "harmony",dims = 1:20, ,assay = "RNA", force.recalc = T)
pbmc_har_val <- pbmc_har
pbmc_har_seq <- pbmc_har
pbmc_har_val <- FindClusters(object = pbmc_har_val, resolution = 0.5)
pbmc_har_seq <- FindClusters(object = pbmc_har_seq, resolution = seq(0.1, 1,0.1))
identical(pbmc_har_val@meta.data$RNA_snn_res.0.5, pbmc_har_seq@meta.data$RNA_snn_res.0.5)
Hello,
Thanks for the more concise, reproducible example.
I have also run this example and obtained the output of identical(pbmc_seq,pbmc_val)
was TRUE
.
However, In my real dataset, the output of identical()
was FALSE
.
The example dataset "pbmc3k" has 3k cells, my real dataset has 35k cells. Maybe the cell count of the Seurat object being greater than 30k(?), somehow, affects this outcome. So, I run both clustering approaches to the "hcabm40k" dataset containing 40k cells in it.
SeuratData::InstallData("hcabm40k.SeuratData")
hcabm40k <- hcabm40k.SeuratData::hcabm40k
The output of identical(hcabm40k_seq,hcabm40k_val)
was again TRUE
for the bigger dataset. I was quite puzzled.
Finally, after meticulous searches, a bunch of reruns, blood, and tears; I noticed I was comparing older iterations of the analysis file with the newer "practice". Bad practice of saving non-time-stamped analysis files.
Thanks for your support in this endeavor of troubleshooting this "bug" (!)
Best, Rüçhan.
Hi there,
While comparing the cluster assignments of
FindClusters( ..., resolution = 0.5)
and theseurat_object$RNA_snn_res.0.5
obtained fromFindClusters( ..., resolution = seq(0.1,1,0.1))
I noticed something weird. These cluster assignments are not overlapping. Even though the random seed is equally set.A: Sequential determination of clusters for resolution 0.1 to 1, with the increment of 0.1
B: Determination of clusters for resolution 0.5, directly.
Here is a visual comparison of how the cells are assigned differently, between directly determining clusters for resolution = 0.5 and then calling the 0.5 assignments from a serial of cluster assignments.