在关于如何制作具有方面和显着性水平的箱形图的许多问题之后,特别是这个和这个,我还有一个小问题.
我设法制作了如下所示的情节,这正是我想要的.
我现在面临的问题是,我很少或没有重要的比较; 在这些情况下,专用于显示显着性水平的括号的整个空间仍然保留,但我想摆脱它.
请使用iris数据集检查此MWE:
library(reshape2)
library(ggplot2)
data(iris)
iris$treatment <- rep(c("A","B"), length(iris$Species)/2)
mydf <- melt(iris, measure.vars=names(iris)[1:4])
mydf$treatment <- as.factor(mydf$treatment)
mydf$variable <- factor(mydf$variable, levels=sort(levels(mydf$variable)))
mydf$both <- factor(paste(mydf$treatment, mydf$variable), levels=(unique(paste(mydf$treatment, mydf$variable))))
a <- combn(levels(mydf$both), 2, simplify = FALSE)#this 6 times, for each lipid class
b <- levels(mydf$Species)
CNb <- relist(
paste(unlist(a), rep(b, each=sum(lengths(a)))),
rep.int(a, length(b))
)
CNb
CNb2 <- data.frame(matrix(unlist(CNb), ncol=2, byrow=T))
CNb2
#new p.values
pv.df <- data.frame()
for (gr in unique(mydf$Species)){
for (i in 1:length(a)){
tis <- …Run Code Online (Sandbox Code Playgroud) 我试图显着性水平加入到我的箱线图中使用星号形式GGPLOT2和ggpubr包,但我有很多的比较,我只想展现显著的。
我尝试在stat_compare_means中使用选项hide.ns = TRUE,但显然不起作用,这可能是ggpubr软件包中的错误。
此外,您还可以从成对的wilcox.test比较中忽略 “ PGMC4”组;我怎样才能把这个小组也留给kruskal.test呢?
我有的最后一个问题是重要性水平如何工作?如*显着低于0.05,**低于0.025,***低于0.01?ggpubr使用的约定是什么?它显示的是p值还是调整后的p值?如果是后者,调整方法是什么?BH?
##############################
##MWE
set.seed(5)
#test df
mydf <- data.frame(ID=paste(sample(LETTERS, 163, replace=TRUE), sample(1:1000, 163, replace=FALSE), sep=''),
Group=c(rep('C',10),rep('FH',10),rep('I',19),rep('IF',42),rep('NA',14),rep('NF',42),rep('NI',15),rep('NS',10),rep('PGMC4',1)),
Value=rnorm(n=163))
#I don't want to compare PGMC4 cause I have only onw sample
groups <- as.character(unique(mydf$Group[which(mydf$Group!="PGMC4")]))
#function to make combinations of groups without repeating pairs, and avoiding self-combinations
expand.grid.unique <- function(x, y, …Run Code Online (Sandbox Code Playgroud)