同样P=0.01,为什么你的被拒稿,他的却上了顶刊?
本期主角-P value。
p value是统计学中用于检验假设显著性的一个指标,常被用于判断结果是否具有统计意义。它在包括生物学、医学、社会科学等许多领域的数据分析中具有重要作用。
P value常用数值、“*”和“ns”等符号表示大小,下面使用R实现添加统计P value。
数值P value
使用ggplot2、ggbeeswarm、ggtext和ggsignif添加统计p value,
## 15.1_01
# 未经过允许禁止转载!
# @Author : 公众号:pythonic生物人
# @Desc : ## 15.1 数值P value
ggplot(iris_data, aes(species, sepal_width, fill = species)) +
geom_boxplot(fill = "transparent", size = 0.2, width = 0.3) + # 绘制箱图
geom_quasirandom(shape = 21, color = "black", alpha = 0.8, size = 4) + # 使用ggbeeswarm中的geom_quasirandom方法绘制抖动图
scale_fill_manual(values = custom_colors1) + # 定义填充颜色,scale_fill_manual介绍见上文“10.2.4 离散型颜色标度(discrete colour scales) (1)scale_fill_manual()方法”
geom_signif( # 使用ggsignif中的geom_signif方法添加p值
comparisons = list( # 添加比较组
c("setosa", "virginica"),
c("setosa", "versicolor"),
c("virginica", "versicolor")
),
test = "t.test", # 使用t.test检验
step_increase = 0.1, textsize = 4,
size = 0.2, # 设置连接线粗细
map_signif_level = function(p) sprintf("%.2g", p), # 设置p值显示样式:数值P value
)
一般p value小于0.05被认为差异显著。
“*” P value
## 15.2_01
# 未经过允许禁止转载!
# @Author : 公众号:pythonic生物人
# @Desc : ## 15.2 “*” P value
ggplot(iris_data, aes(species, sepal_width, fill = species)) +
geom_boxplot(fill = "transparent", size = 0.2, width = 0.3) + # 绘制箱图
geom_quasirandom(shape = 21, color = "black", alpha = 0.8, size = 4) + # 绘制抖动图
scale_fill_manual(values = custom_colors1) + # 定义填充颜色,scale_fill_manual介绍见上文“10.2.4 离散型颜色标度(discrete colour scales) (1)scale_fill_manual()方法”
geom_signif( # 使用ggsignif中的geom_signif方法添加p值
comparisons = list( # 添加比较组
c("setosa", "virginica"),
c("setosa", "versicolor"),
c("virginica", "versicolor")
),
test = "t.test", # 使用t.test检验
step_increase = 0.1, textsize = 4,
size = 0.2, # 设置连接线粗细
map_signif_level = T, # 设置p值显示样式:数值P value
)
“*”与数值对应关系:
*: 1.00e-02 < p <= 5.00e-02
**: 1.00e-03 < p <= 1.00e-02
***: 1.00e-04 < p <= 1.00e-03
****: p <= 1.00e-04
“ns” 和“*” P value
## 15.3_01
# 未经过允许禁止转载!
# @Author : 公众号:pythonic生物人
# @Desc : ## 15.3 “ns” P value
ggplot(iris_data, aes(species, sepal_width, fill = species)) +
geom_boxplot(fill = "transparent", size = 0.2, width = 0.3) + # 绘制箱图
geom_quasirandom(shape = 21, color = "black", alpha = 0.8, size = 4) + # 绘制抖动图
scale_fill_manual(values = custom_colors1) + # 定义填充颜色,scale_fill_manual介绍见上文“10.2.4 离散型颜色标度(discrete colour scales) (1)scale_fill_manual()方法”
geom_signif( # 使用ggsignif中的geom_signif方法添加p值
comparisons = list( # 添加比较组
c("setosa", "virginica"),
c("setosa", "versicolor"),
c("virginica", "versicolor")
),
test = "t.test", # 使用t.test检验
step_increase = 0.1, textsize = 4,
annotations = c("***", "***", "NS"), #设置
size = 0.2# 设置连接线粗细
)
ns”与数值对应关系:
ns: 5.00e-02 < p <= 1.00e+00
-推荐阅读-
👇加入学习(备注:628)