🍭棒棒糖图/哑铃图的绘制
2022-08-02 本文已影响0人
Hayley笔记
单细胞绘图系列:
- Seurat绘图函数总结
- 使用ggplot2优化Seurat绘图
- scRNAseq灵活的点图绘制:FlexDotPlot
- 富集分析结果雷达图
- DoHeatmap的优化+ComplexHeatmap绘制带特定基因的单细胞热图
- 不同单细胞群之间的相关性分析
- 单细胞RunPCA()结果解读+DimHeatmap的用法
- 桑基图:不同分辨率下的细胞分群可视化
- 单细胞亚群差异基因火山图
- 甜甜圈图展示细胞比例
- 单细胞密度散点图的绘制
在读Chronic Stress下的心脏高分辨率转录图谱揭示心脏纤维化和肥厚的驱动因素的时候,看到了这样的不同处理组之间所有细胞群差异基因数的展示方法
感觉还挺好看的。来做一下复现吧
library(Seurat)
library(ggplot2)
library(ggthemes)
df <- data_frame(celltype=unique(pbmc@meta.data$cell_type))
df$up <- c(sample(1:200,9))
df$down <- c(sample(1:200,9))
df
## A tibble: 9 × 3
# celltype up down
# <fct> <int> <int>
# 1 CD14+ Mono 88 158
# 2 B 42 193
# 3 Memory CD4 T 103 2
# 4 NK 2 16
# 5 CD8 T 76 45
# 6 Naive CD4 T 65 118
# 7 FCGR3A+ Mono 51 71
# 8 DC 44 102
# 9 Platelet 128 66
得到的df就是包含了细胞群,上调基因数,下调基因数的三列。
ggplot(df) +
geom_segment( aes(x=celltype, xend=celltype, y=0, yend=up),
size=0.7,linetype=1,color="grey")+ # 此处y起始点为0,终止点为up
geom_segment( aes(x=celltype, xend=celltype, y=0, yend= -down),
size=0.7,linetype=1,color="grey")+ # 此处y起始点为0,终止点为down
geom_hline (aes (yintercept = 0),color = "gray50" , linetype = "dashed")+
geom_point(aes(x=celltype,y=up),size = 6, pch = 20, color="lightsalmon2") +
geom_point(aes(x=celltype,y=-down),size = 6, pch = 20, color="gray33") +
xlab("Cell type") +
scale_y_continuous("Number of gene") +
theme_base()+
theme(axis.text.x = element_text(angle = 90),
axis.ticks.y = element_blank(),
)
差不多了,还可以再做一下调整