Seurat包展示出来的umap/tsne图都是带有横纵坐标,基于Seurat包可能比较难调整图片的样式,只能借助AI或者PS处理图片。这次借助ggplot2进行可视化,对于Seurat出来的umap/tsne后期的微调。
ggplot2常规绘制的umap图
目前使用R绘制的umap图跟Seurat的umap图有点类似,但是这样的图片发文章的时候会再次进行美化。
geom_segment
查阅反找发现geom_segment()函数,本次主要借助的ggplot2的geom_segment()函数实现SCI样式的umap图
library(ggplot2)
data<-read.csv("umap.csv",sep=",",header=T)
Theme2<-theme(panel.background = element_blank(),panel.border = element_blank(),panel.grid=element_blank(), axis.title = element_text(color='black',size=18),axis.ticks.length = unit(0.4,"lines"),axis.ticks = element_blank(),axis.line = element_blank(),axis.text=element_blank(),legend.title=element_blank(),legend.text=element_text(size=18),legend.key=element_blank(),legend.key.size=unit(1,'cm')) #定义一下主题格式
p<-ggplot(data,aes(x=tSNE_1,y=tSNE_2))+geom_point(aes(color=Lable))+scale_color_manual(values = allcolour)+geom_label(aes(label=Lable),data=class_avg,nudge_x=0,alpha=.5,size=5)+labs(x=" ",y=" ")+theme_bw()+theme(text=element_text(size=18))+Theme2+guides(colour = guide_legend(override.aes = list(size=5)))+geom_segment(aes(x = min(data$tSNE_1) , y = min(data$tSNE_2),xend = min(data$tSNE_1) +3, yend = min(data$tSNE_2)),colour = "black", size=1,arrow = arrow(length = unit(0.3,"cm")))+ geom_segment(aes(x = min(data$tSNE_1),y = min(data$tSNE_2),xend = min(data$tSNE_1),yend = min(data$tSNE_2) + 3),colour = "black", size=1,arrow = arrow(length = unit(0.3,"cm")))+annotate("text", x = min(data$tSNE_1) +1.5, y = min(data$tSNE_2) -1, label = "tSNE_1",color="black",size = 5, fontface="bold" ) +annotate("text", x = min(data$tSNE_1) -1, y = min(data$tSNE_2) + 1.5, label = "tSNE_2",color="black",size = 5, fontface="bold" ,angle=90)
参考链接
https://mp.weixin.qq.com/s/dgsAjDnLOtzgejzzr4RcFw