绘制ggplot2风格的单细胞t-SNE聚类图
2021-03-12 本文已影响0人
佳名
library(ggplot2)
p1 <- DimPlot(pbmc,reduction ="tsne",group.by="singleR",label=F)
p1$data$group <- substr(row.names(p1$data),1,4)
p1<-ggplot(p1$data,aes(tSNE_1,tSNE_2))+
geom_point(aes(color=singleR))+
facet_wrap(~group)
p1
Rplot03.png
p1<-ggplot(p1$data,aes(tSNE_1,tSNE_2))+
geom_point(aes(color=singleR))+
facet_grid(group~singleR,scale="free")
p1
Rplot04.png
Rplot05.png
library(scales)
p <- ggplot(pbmc@meta.data,aes(x=singleR,fill= orig.ident))+
geom_bar(position ="fill")+
xlab(NULL)+ylab("PERCENT")+
theme(axis.text.x = element_text(angle = 45, hjust = 0.5, vjust = 0.5))+
scale_y_continuous(labels = percent,breaks=seq(0,1,by=0.2))
p
Rplot06.png