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.
• 6,048 views
•
link
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))
• 0 views
•
link
Log in to answer this question.
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 knowseuratusesggplot2package, meaning that you can add layers to the plot in the same way you do inggplot2.Therefore my question is: what do you expect to plot in
ggplot2that theseuratcan't do (since it usesggplot2)?With this I don't mean that there is not advantages of using
ggplot2instead of using it with theseuratfunctions 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.