抖动散点图
今天我们复现一幅2022年3月发表在Cell
上的抖动散点图
。
Title:Tissue-resident FOLR2+ macrophages associate with CD8+ T cell infiltration in human breast cancer
之前复现过的散点图:
Snipaste_2022-06-17_08-56-10
读图
本期抖动散点图
亮点:
- 与
蜂群图
不同,只是单纯的抖动散点图
。 y轴刻度
log10
转换x轴刻度标签
修改,上标
的添加。- 差异结果注释在图形区域外。
结果展示
复现结果
绘制
# 示例数据准备及预处理 gene = data.frame( A = runif(100,2,900), B = runif(100,0.1,5)) # 长宽转换 library(reshape2) gene_exp = melt(gene, measure.vars = c("A","B"), variable.name = "gene",value.name = "exp") # 绘制 library(ggplot2) library(ggpubr) p <- ggplot(gene_exp,aes(x = gene, y = exp),color = 'balck')+ geom_jitter(aes(fill = gene), width = 0.2, height =0, size = 3, shape = 21, stroke = 0.4, show.legend = FALSE)+ scale_fill_manual(values = c("#bc382d","#314494"))+ ## 先算一下显著性差异,再手动添加 # geom_signif(comparisons = list(c("A","B")), # test = "t.test", # map_signif_level = T)+ scale_y_log10()+ scale_x_discrete(labels = c('',''))+ xlab(" ") + theme_classic() p p1 <- p + coord_cartesian(clip = 'off',ylim = c(0.1,1000))+ #在非图形区域绘图,且要定好y轴范围 theme(plot.margin = margin(0.5,0,0,0.5,'cm'))+ #自定义图片上左下右的边框宽度 annotate('segment',x=1,xend=2,y=1500,yend=1500,color='black',cex=.4)+ annotate("text", x = 1.5, y = 1500, label ="***",size = 6)+ annotate("text",label = bquote (FOLR^high),x=1,y=0.03)+ annotate("text",label = bquote (FOLR^low),x=2,y=0.03) p1
复现结果