单细胞绘图系列:
- Seurat绘图函数总结
- 使用ggplot2优化Seurat绘图
- scRNAseq灵活的点图绘制:FlexDotPlot
- 富集分析结果雷达图
- DoHeatmap的优化+ComplexHeatmap绘制带特定基因的单细胞热图
- 不同单细胞群之间的相关性分析
- 单细胞RunPCA()结果解读+DimHeatmap的用法
- 桑基图:不同分辨率下的细胞分群可视化
做单细胞分析的时候,我们常规画的火山图和RNAseq的分析其实是一样的。见火山图EnhancedVolcano。但是因为单细胞自身特性导致,它两个分组的细胞数量太多,很大概率会导致p值过于显著,无限接近于0的情况,导致火山图的结果很诡异。
最近在文献里看到了这样的火山图
这种展现方式可以忽略这个统计学指标p值,因为反正都是统计学显著的,大于0.01即可,p值再小也不是我们关心的重点。
绘制方法
用pbmc3k数据集做演示
library(Seurat)
library(patchwork)
library(clusterProfiler)
library(org.Mm.eg.db) ##加载小鼠
library(org.Hs.eg.db) ##加载人类
library(tidyverse)
pbmc <-readRDS("pbmc.rds")
table(pbmc$cell_type)
object.markers <- FindMarkers(pbmc, ident.1 = 'Memory CD4 T',ident.2 = 'Naive CD4 T',
group.by = 'cell_type',logfc.threshold = 0,min.pct = 0,pseudocount.use = 0.01)
object.markers$names <- rownames(object.markers)
#sig_dge.all <- subset(object.markers, p_val_adj<0.05&abs(avg_log2FC)>0.15) #所有差异基因
#View(sig_dge.all)
library(dplyr)
object.markers <- object.markers %>%
mutate(Difference = pct.1 - pct.2)
library(ggplot)
library(ggrepel)
ggplot(object.markers, aes(x=Difference, y=avg_log2FC)) +
geom_point(size=0.5, color="#999999") +
geom_label_repel(data=subset(object.markers, avg_log2FC >= 1 & Difference >= 0.2 & pct.2 <= 0.05), aes(label=names), label.padding = 0.1, fill="tomato2", segment.size = 0.25, size=2.5)+
theme_classic()
ggsave("TopMarkerVol1.pdf", height=8, width=8)
object.markers$group=0
for (i in 1:nrow(object.markers)){
if (object.markers$avg_log2FC[i] >= 1 & object.markers$Difference[i] >= 0.2 & object.markers$pct.2[i] <= 0.05){
object.markers$group[i]='up'
}
else if(object.markers$avg_log2FC[i] <= -1 & object.markers$Difference[i] <= -0.2 & object.markers$pct.1[i] <= 0.05){
object.markers$group[i]='down'
}
else {
object.markers$group[i]='no'
}
}
ggplot(object.markers, aes(x=Difference, y=avg_log2FC)) +
geom_point(size=0.5,aes(color=group)) +
scale_color_manual(values=c('blue','grey','red'))+
geom_label_repel(data=subset(object.markers, group !='no'), aes(label=names), segment.size = 0.25, size=2.5)+
geom_vline(xintercept = 0.0,linetype=2)+
geom_hline(yintercept = 0,linetype=2)+
theme_classic()
ggsave("TopMarkerVol2.pdf", height=8, width=8)