Labeling Clusters in ggplot
1
0
Entering edit mode
3.3 years ago
fouerghi20 ▴ 80

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

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

ADD REPLY
0
Entering edit mode

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...

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode
3.3 years ago
fouerghi20 ▴ 80

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))
ADD COMMENT

Login before adding your answer.

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