Seurat Clustering - Cluster Numbers from 1 instead of 0
1
0
Entering edit mode
4.3 years ago
David_emir ▴ 500

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 • 13k views
ADD COMMENT
0
Entering edit mode

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!

ADD REPLY
2
Entering edit mode
4.3 years ago

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)
ADD COMMENT
0
Entering edit mode

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
ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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)
ADD REPLY
1
Entering edit mode

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")
ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1221 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