用ggplot来改善Seurat包的画图

2020-04-01 15:37:51 浏览数 (1)

Seurat是分析单细胞数据一个非常好用的包,几句代码就可以出图,如feature plot,violin plot,heatmap等,但是图片有些地方需要改善的地方,默认的调整参数没有提供,好在Seurat的画图底层是用ggplot架构的,我们可以用ggplot的参数进行调整。

默认的feature plot是坐标轴形式

代码语言:javascript复制
FeaturePlot(seurat.object,features = c("Thy1"))

image.png

改成加框:

代码语言:javascript复制
FeaturePlot(seurat.object,features = c("Thy1")) annotate(geom = 'segment', y = Inf, yend = Inf, color = 'black', x = -Inf, xend = Inf, size = 1) annotate(geom = 'segment', x = Inf, xend = Inf, color = 'black', y = -Inf, yend = Inf, size = 0.5) 

image.png

去掉框顺便改个颜色

代码语言:javascript复制
FeaturePlot(object = seurat.object, features = c('Thy1'),cols = c("lightgrey" ,"#DE1F1F"),slot = "data",label.size = 6,pt.size = 1.2)   theme(axis.line = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), axis.title = element_blank())   guides(color=F)

image.png

可以将通过rgb颜色改个透明度

代码语言:javascript复制
print(FeaturePlot(object = CDCs, features = c('Thy1'),cols = c(rgb(220,212,213,180,maxColorValue = 255),rgb(174,27,52,50, maxColorValue = 255)),slot = "scale.data",label.size = 6,pt.size = 1.5,min.cutoff = "q10", max.cutoff = "q90")   theme(axis.line = element_blank(), axis.text = element_blank(), axis.ticks = element_blank(), axis.title = element_blank()))

image.png

欢迎关注~

0 人点赞