UMAP图上同时展示多个marker基因

最近有小伙伴问道一个问题,如何在一个单细胞UMAP/TSNE图上展示多个marker基因的表达,乍一看挺简单的,后来也是思考了一些时间,慢慢解决了这个问题。

image

首先,Seurat中的FeaturePlot函数能够完成两种marker的组合,但是不能超过两个,否则报错!

#使用Featureplot标记基因
FeaturePlot(human_data, features = c("CD3E", "IL1B"),
            cols = c("lightgrey", "blue", "blue"),
            blend=T,blend.threshold=0)

#三个基因的时候就不行了
FeaturePlot(human_data, features = c("CD3E", "IL1B","CD74"),
            cols = c("lightgrey", "blue", "blue"),
            blend=T,blend.threshold=0)
# Error in FeaturePlot(human_data, features = c("CD3E", "IL1B", "CD74"),  : 
#                        Blending feature plots only works with two features

image

后来我想到用ggplot叠加geom_point,但是有问题,不能显示渐变。

#找到表达这些基因的细胞坐标,添加上去
p1=DimPlot(human_data,group.by = 'celltype',
           cols = c("grey","grey",
                    "grey","grey","grey"),
           pt.size = 1)+NoLegend()

gene1 <- "CD3E"
gene2 <- "CD74"
gene3 <- "IL1B"

pos_gene=human_data@[email protected]
pos_gene1=pos_gene[human_data@assays$RNA@data[gene1,]>0,]
pos_gene2=pos_gene[human_data@assays$RNA@data[gene2,]>0,]
pos_gene3=pos_gene[human_data@assays$RNA@data[gene3,]>0,]


p1+geom_point(data = as.data.frame(pos_gene1),
              aes(x=UMAP_1,y=UMAP_2), 
              shape = 16,size = 0.5, color="blue")+
  geom_point(data = as.data.frame(pos_gene2),
             aes(x=UMAP_1,y=UMAP_2), 
             shape = 16,size = 0.5, color="blue")+
  geom_point(data = as.data.frame(pos_gene3),
             aes(x=UMAP_1,y=UMAP_2), 
             shape = 16,size = 0.5, color="blue")
image

所以最后我直接想着用ggplot实现,首先区分三个颜色看一下效果,看是不是有覆盖!可见三种基因都标记上了,而且表达量是渐变的。****

image
最后统一颜色,修饰下主题,就完成了。****
image

更多精彩请至我的公众号---KS科研分享与服务

你可能感兴趣的:(UMAP图上同时展示多个marker基因)