This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Labeling Clusters in ggplot

I have a data matrix I extracted from seurat and I want to plot the tSNE plot by using ggplot. I don't know how to label the clusters on the plot with 0..15. Help is appreciated.

ggplot single cell

You have to show sample input data. Also, please show what you have already tried.

Why do you want to plot the t-SNE outside from seurat? As far as I know seurat uses ggplot2 package, meaning that you can add layers to the plot in the same way you do in ggplot2.

Therefore my question is: what do you expect to plot in ggplot2 that the seurat can't do (since it uses ggplot2)?

With this I don't mean that there is not advantages of using ggplot2 instead of using it with the seurat functions interface, but I'm just curious...

Agreed. If you just want more viz options and some convenience, you could also consider dittoSeq.

Hi, I just came across this thread and wanted to comment on it. Seurat is really nice and easy to use but it can get slow when you plot big datasets. This can be an issue if you want to publish the data in an interactive platform like Shiny. That's why some people, or at least for me, only extract the info needed for plotting from Seurat object and use ggplot to speed up calculation.

1 answer

This is what ended up working for me:

data$seurat_clusters <- factor(data$seurat_clusters,labels=c("..",".."))

data2 <- data %>% group_by(seurat_clusters) %>% select(tSNE_1, tSNE_2) %>% summarize_all(mean)
View(data$seurat_clusters)

ggplot(data, aes(tSNE_1,tSNE_2, col = factor(seurat_clusters, labels= c("..",".."))),label= TRUE)+ geom_point(size=0.3,alpha=0.3) +   labs(color= "Clusters") +  ggrepel::geom_label_repel(data = data2,aes(label = seurat_clusters))

Log in to answer this question.