I was supposed to use the code below to get the number of cells per cluster. The code works with Seurat version 2, but while using version 3 I got the error no slot of name "ident" for this object of class "Seurat". Does anyone have any idea about how to deal with this?

# Calculate number of cells per cluster from object@ident

cell.num <- table(shox2crepos_mtmg@ident)

# Add cell number per cluster to cluster labels

ClusterLabels = paste("Cluster", names(cell.num), paste0("(n = ", cell.num, ")"))

# Order legend labels in plot in the same order as 'ClusterLabels'

ClusterBreaks = names(cell.num)

# Plot tSNE with new legend labels for clusters

TSNEPlot(object = shox2crepos_mtmg, do.return = T) +
  scale_colour_discrete(breaks = ClusterBreaks,
                        labels = ClusterLabels) +
  labs(x = "t-SNE 1",
       y = "t-SNE 2")

1 Answer 1


The "identities" can be accessed with the Idents() function in Seurat v3.

You should change cell.num <- table(shox2crepos_mtmg@ident) to

cell.num <- table(Idents(shox2crepos_mtmg))


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.