- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要一些有关 stat_compare_means 和多个组的帮助。
这是我的数据的样子。
> head(df_annot)
Row.names Diversity_sh Diversity_si Evenness Chao1 Location Bean Fungi Insect
1 R-B1 1.314181 0.6040213 0.3053349 91.00000 Root Bean M- NI
2 R-B2 1.323718 0.6117602 0.3075507 77.43750 Root Bean M- NI
3 R-B3 1.249950 0.5737293 0.2877545 81.50000 Root Bean M- NI
4 R-BF-1 1.177111 0.5414276 0.2693958 92.33333 Root Bean M+ NI
5 R-BF-2 1.191254 0.5252688 0.2742420 79.54545 Root Bean M+ NI
6 R-BF-3 1.397233 0.6285945 0.3179540 85.50000 Root Bean M+ NI
my_comparisons<- list( c("M+", "M-"), c("Insect", "NI"))
ggplot(df_annot,aes_string(x="Insect",y=index,fill="Fungi"))+
geom_boxplot(alpha=0.8)+
geom_point(aes(fill=Fungi),size = 3, shape = 21,position = position_jitterdodge(jitter.width = 0.02,jitter.height = 0))+
stat_compare_means(comparison=my_comparisons,label="p.format",method="wilcox.test")+
#ggtitle(df_name)+
ylab(paste(index))+
xlab("")+
# scale_x_discrete(labels= c("M+","M-","soil alone"))+
theme(plot.title = element_text(size = 18, face = "bold"))+
theme(axis.text=element_text(size=14),
axis.title=element_text(size=14)) +
theme(legend.text=element_text(size=14),
legend.title=element_text(size=14)) +
theme(strip.text.x = element_text(size = 14))
dput(df_annot)
structure(list(Row.names = structure(c("R-B1", "R-B2", "R-B3",
"R-BF-1", "R-BF-2", "R-BF-3", "R-BFi-1", "R-BFi-2", "R-Bi-1",
"R-Bi-2", "R-Bi-3"), class = "AsIs"), Diversity_sh = c(1.31418133185869,
1.32371839350534, 1.24994951615418, 1.17711111336449, 1.19125374868316,
1.39723272927515, 1.34145146126423, 1.21674449259962, 1.20721660188555,
1.17245529262564, 1.20912937911657), Diversity_si = c(0.604021268328531,
0.611760247980402, 0.573729285531772, 0.541427625516077, 0.525268755766239,
0.628594506768001, 0.597250229879166, 0.554646956896473, 0.548992316400345,
0.531291238688503, 0.583806537719818), Evenness = c(0.305334910927276,
0.307550737463383, 0.287754490536268, 0.269395848882803, 0.274241968272787,
0.317954009728278, 0.305260435164649, 0.276882141486585, 0.273949061455415,
0.269914321375221, 0.275929262855007), Chao1 = c(91, 77.4375,
81.5, 92.3333333333333, 79.5454545454545, 85.5, 87.5, 90.5454545454545,
89.3333333333333, 88.6666666666667, 88.0769230769231), Location = structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Root", "Rhizospheric Soil"
), class = "factor"), Bean = structure(c(1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L), .Label = "Bean", class = "factor"),
Fungi = structure(c(2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 2L,
2L), .Label = c("M+", "M-"), class = "factor"), Insect = structure(c(2L,
2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L), .Label = c("Insect",
"NI"), class = "factor")), row.names = c(NA, -11L), class = "data.frame")
最佳答案
facet_wrap()
可能会帮助您讨论 here
ggplot(df_annot, aes(x=df_annot$Insect, y= df_annot$Evenness)) +
facet_wrap(~df_annot$Fungi)+
geom_boxplot(alpha=0.8) +
geom_point()+
stat_compare_means(comparisons = list(c("Insect", "NI") ), label="p.format",method="wilcox.test")
df_annot$var <- paste(df_annot$Insect,df_annot$Fungi, sep = "_" )
my_comparisons <- rev(list(c("Insect_M-","Insect_M+"),c("NI_M-","Insect_M-"),c("NI_M+","Insect_M-"),
c("Insect_M+", "NI_M-"), c("Insect_M+", "NI_M+"), c("NI_M-","NI_M+")))
ggplot(df_annot,aes_string(x="var",y="Evenness",fill="Fungi"))+
geom_boxplot(alpha=0.8)+
geom_point(aes(fill=Fungi),size = 3, shape = 21,position = position_jitterdodge(jitter.width = 0.02,jitter.height = 0))+
stat_compare_means(comparison=my_comparisons,label="p.format",method="wilcox.test")+
#ggtitle(df_name)+
ylab(paste("Evenness"))+
xlab("")+
# scale_x_discrete(labels= c("M+","M-","soil alone"))+
theme(plot.title = element_text(size = 18, face = "bold"))+
theme(axis.text=element_text(size=14),
axis.title=element_text(size=14)) +
theme(legend.text=element_text(size=14),
legend.title=element_text(size=14)) +
theme(strip.text.x = element_text(size = 14))
关于r - stat_compare_means 与多个组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60457722/
我需要一些有关 stat_compare_means 和多个组的帮助。 这是我的数据的样子。 > head(df_annot) Row.names Diversity_sh Diversity_s
我正在查看 2 个治疗组(高脂或无高脂饮食)的豚鼠的生物学数据,当我对箱线图进行 facet_wrap 并添加 stat_compare_means (t.test) 函数时,p 值被截断。当我删除s
我正在查看 2 个治疗组(高脂或无高脂饮食)的豚鼠的生物学数据,当我对箱线图进行 facet_wrap 并添加 stat_compare_means (t.test) 函数时,p 值被截断。当我删除s
您好,当我尝试绘制此代码时: ggplot(subset(tabcourt, !is.na(Score) & !is.na(`PSA level (ng/ml)`))) +facet_wrap(.~M
我想使用 ggpubr 包中的 R 函数 stat_compare_means 将 Kruskal-Wallis 检验的 p 值绘制到我的 ggplot 中。 但是,绘制的值与我简单运行该函数时的值不
我尝试制作显示 p 值的箱线图 my_comparisons Loading required package: ggplot2 library(tidyverse) ## This works a
是否可以更改以下 ggpboxplot 中 p 值的字体系列?字体系列应为“Times New Roman”。 使用 theme_bw(base_family = "Times New Roman")
我正在尝试使用ggplot2和ggpubr包以星号的形式向我的箱线图添加显着性水平,但我有很多比较,我只想显示重要的。 我尝试在 stat_compare_means 中使用选项 hide.ns=TR
使用 ToothGrowth 数据集(内置于 R 中),我使用了以下代码。 library(ggplot2) library(tidyverse) library(ggpubr) p <- ggbox
我想在多面 ggplot 中绘制每个面板的 p 值。如果 p 值大于 0.05,我想按原样显示 p 值。如果 p 值小于 0.05,我想以科学计数法显示该值(即 0.0032 -> 3.20e-3;0
如何更改下图中 stat_compare_means 的字体大小?即,更改“Kruskal-Wallis,p = 1.5e-09”和其他 p 值字体大小?我想使用比默认字体更小的字体... 按照数据示
我想在多面 ggplot 中绘制每个面板的 p 值。如果 p 值大于 0.05,我想按原样显示 p 值。如果 p 值小于 0.05,我想以科学计数法显示该值(即 0.0032 -> 3.20e-3;0
我是一名优秀的程序员,十分优秀!