1. 文章的效果图
Fig1C: https://www.nature.com/articles/s41586-023-06050-3
c, Left, fluorescence intensity quantifications of puncta of eGFP-tagged Cse4, Mmm1, Mdm12 and Mdm34, represented as dot plots and half-violin plots. Three experimental repeats are shown. Each data point is one punctum. Large dots represent the median and horizontal lines show MAD.
2. 模仿和代码
(1) 水平版本
install.packages("ggsignif") #显著性
install.packages("ggsci") #颜色
install.packages("ggdist") #云雨图:半个小提琴图,半个散点图jitter
# barplot with p====
library(ggplot2)
library(ggsignif) # 显著性标记
# 模拟数据
library(dplyr)
dat=iris[, c(1,2,3,5)]
colnames(dat)[1:3]=paste0("epi_", c(1:3))
plot.data=dat %>% tidyr::gather(key="celltype", value="value", -c("Species") )
head(plot.data)
# plot
ggplot(plot.data, aes(celltype, value)) +
# 如果不想安装ggdist包,使用这个也凑合
#geom_violin( aes(fill=celltype, color=celltype), scale="width", show.legend = F )+
ggdist::stat_halfeye(aes(color=celltype,fill=celltype), adjust = .5,
width = .7, .width = 0, justification = -.2, point_colour = NA) +
geom_boxplot(aes(color=celltype),width = .2, outlier.shape = NA, show.legend = F) + #boxplot
geom_jitter(aes(color=celltype),width = .05, alpha = .3)+ #散点图
ggsci::scale_color_nejm()+ggsci::scale_fill_nejm() + #颜色
coord_flip()+ xlab(" ")+theme_classic()+
labs(title = "Expression Level ")+
geom_signif(comparisons = list(
c('epi_1', 'epi_2'), c('epi_2', 'epi_3'),
c('epi_1', 'epi_3')
),
test = "wilcox.test",
map_signif_level = F, ## p valuey
y_position = c(7.5, 8, 8.5), #position
size = 0.5, textsize = 4 )+
theme(
plot.title = element_text(size =15,hjust = 0.5, face="bold"), # #标题
axis.text.x=element_text(size=15,face="bold",angle=0,hjust = 1,vjust = 1),
axis.text.y=element_text(size=15,face="bold"),
axis.title.x=element_text(size = 0,vjust = 1,face="bold"),
axis.title.y=element_text(size = 15,face="bold")
)
(2) 竖直版本
ggplot(plot.data, aes(celltype, value)) +
# 如果不想安装ggdist包,使用这个也凑合
#geom_violin( aes(fill=celltype, color=celltype), scale="width", show.legend = F )+
ggdist::stat_halfeye(aes(color=celltype,fill=celltype), adjust = .5,
width = .7, .width = 0, justification = -.2, point_colour = NA) +
geom_boxplot(aes(color=celltype),width = .2, outlier.shape = NA, show.legend = F) + #boxplot
geom_jitter(aes(color=celltype),width = .05, alpha = .3)+ #散点图
ggsci::scale_color_nejm()+ggsci::scale_fill_nejm() + #颜色
labs(x=" ", y="Expression Level", title="CD1234")+theme_classic()+
geom_signif(comparisons = list(
c('epi_1', 'epi_2'), c('epi_2', 'epi_3'),
c('epi_1', 'epi_3')
),
test = "wilcox.test",
map_signif_level = F, ## p valuey
y_position = c(7.5, 8, 8.5), #position
size = 0.3, textsize = 4 )+
theme(
plot.title = element_text(size =15,hjust = 0.5), # #标题
axis.text.x=element_text(size=15,angle=30,hjust = 1,vjust = 1),
axis.text.y=element_text(size=15),
axis.title.x=element_text(size = 0,vjust = 1),
axis.title.y=element_text(size = 15)
)
Ref
- https://mp.weixin.qq.com/s?__biz=Mzg3MDQ3MDI4Mg==&mid=2247497859&idx=1&sn=71d32ff3b0ed9f7eeb424f5742371ae6
- xx