boxplot加显著性

boxplot加显著性

library(ggplot2)
library(ggsignif)
head(iris)
#自动添加显著性标记
compaired <- list(c(“versicolor”, “virginica”))
ggplot(iris, aes(x=Species, y=Sepal.Width, fill=Species)) +
geom_boxplot() +
geom_signif(comparisons = compaired,
map_signif_level = T)

#手动添加显著性标记
dat <- data.frame(Group = c(“S1”,“S1”,“S2”,“S2”),
Sub = c(“A”,“B”,“A”,“B”),
Value = c(3,5,7,8))
dat
ggplot(dat, aes(Group, Value)) +
geom_bar(aes(fill = Sub), stat = “identity”, position = “dodge”, width = .5) +
geom_signif(y_position = c(5.3, 8.3), xmin = c(0.8, 1.8), xmax = c(1.2, 2.2),
annotations = c("**",“NS”), tip_length = 0) +
geom_signif(comparisons = list(c(“S1”,“S2”)),
y_position = 9.3, tip_length = 0, vjust = 0) +
scale_fill_manual(values = c(“grey80”,“grey20”))

??geom_signif
ggplot(mpg, aes(class, hwy, fill= class)) +
geom_boxplot() +
geom_signif(comparisons = list(c(“compact”, “pickup”),
c(“subcompact”, “suv”)))

ggplot(mpg, aes(class, hwy, fill= class)) +
geom_boxplot() +
geom_signif(comparisons = list(c(“compact”, “pickup”),
c(“subcompact”, “suv”)),
map_signif_level = T)

ggplot(mpg, aes(class, hwy, fill=class)) +
geom_boxplot() +
geom_signif(comparisons = list(c(“compact”, “pickup”),
c(“subcompact”, “suv”)),
map_signif_level=function§sprintf(“p = %.2g”, p))

ggplot(mpg, aes(class, hwy, fill= class)) +
geom_boxplot() +
geom_signif(annotations = c(“First”, “Second”),
y_position = c(30, 40), xmin=c(4,1), xmax=c(5,3))
据此,将文章R绘图应用实例:成组的t检验及绘图添加显著性做适当修改,参数如下:
ggplot(result_long_count2, aes(x=variable, y=value, fill=Treated)) +
geom_bar(position=position_dodge(.9), stat=“identity”,
colour=“black”,size=.3) +
geom_errorbar(aes(ymin=value-se, ymax=value+se),
size=.3, width=.2,
position=position_dodge(.9)) +
geom_signif(annotations = c("**", “*”), y_position = c(1.15,1.25),
xmin = c(0.78, 1.78),xmax = c(1.23, 2.23),
tip_length = c(c(0.05, 0.8),c(0.05, 0.55)), vjust = 0) +
scale_color_brewer(“Set1”) +
xlab(“RNAi Treated”) +
ylab(“Relative Expression”) +
ggtitle(“The Effect of RNAi on two genes”)

作者:谢俊飞
链接:https://www.jianshu.com/p/4d9d13ae8744
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值