This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Seurat Clustering - Cluster Numbers from 1 instead of 0

Hi All,

I am analysing Single-cell RNAseq data with Seurat. When I cluster my samples using "FindClusters", Seurat starts cluster labels from 0 (Zero) instead of 1. is there a way where I can ask Seurat to start cluster numbers from 1 instead of 0?

Thanks a lot for your help! Have a great day ahead.

Dave.

rna-seq seurat cluster numbering

I've subsetted out a couple of clusters from a project of mine, but I'm trying to plug the numeric hole in my data. Is there a way to change the numbering of a Seurat cluster from, say, 10 to 9? Thanks!

1 answer

The newer versions of Seurat start with 1 instead of 0. However, since the clusters are stored as a column in a data.frame, it's easy to change them as necessary.

 seurat_object$seurat_clusters <- as.factor(as.numeric(as.character(seurat_object$seurat_clusters)) + 1)

Thanks a lot for your kind help, but when I run this code, my seurat clusters are starting from 2 instead of 1. please have a look

> alldata$seurat_clusters <- as.factor(as.numeric(alldata$seurat_clusters) + 1)
    > cbind(table(alldata$seurat_clusters))
   [,1]
2  2334
3  2086
4  2077
5  1961

I updated the code so it should work now. This was caused by as.numeric returning the factor levels instead of the the values.

Thanks a lot for your help, i am now able to get seurat clusters from 0 , but when i plot the UMAP or TSNE or PCA all labels still show from '0'th cluster.

DimPlot(alldata, reduction = "UMAP_on_CCA", label=T)

Try specifying which metadata column to use explicitly.

You can either set the identities.

Idents(alldata) <- "seurat_clusters"

Or you can specify what to use in the plotting function.

DimPlot(alldata, reduction = "UMAP_on_CCA", label=T, group.by="seurat_clusters")

Thanks a lot, this really works like a charm. Have a great day ahead.

Log in to answer this question.