Seurat包展示出來的umap/tsne圖都是帶有橫縱坐標(biāo)腕窥,基于Seurat包可能比較難調(diào)整圖片的樣式俯萎,只能借助AI或者PS處理圖片火俄。這次借助ggplot2進(jìn)行可視化巢墅,對(duì)于Seurat出來的umap/tsne后期的微調(diào)架谎。
ggplot2常規(guī)繪制的umap圖
目前使用R繪制的umap圖跟Seurat的umap圖有點(diǎn)類似炸宵,但是這樣的圖片發(fā)文章的時(shí)候會(huì)再次進(jìn)行美化。
geom_segment
查閱反找發(fā)現(xiàn)geom_segment()函數(shù)狐树,本次主要借助的ggplot2的geom_segment()函數(shù)實(shí)現(xiàn)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)