当我在 R 中绘制数据时,我遇到了问题,在某些情况下,统计显着性的括号在图中显示为双

问题描述 投票:0回答:0

我绘制了数据并将 p 值整合到图中,但不幸的是,在某些情况下,两组之间的统计显着差异在图中显示为双倍,但我只希望每次比较显示一次enter image description here

我尝试删除一个括号甚至一个比较,但我找不到一种方法来专门删除两个双括号之一。如果我使用更多的“n”,双括号就会消失。

#乳酸实验 ##准备数据集

Lactate.data_long <- Lactate.data %>%
                                    gather(key = "variable", value = "value", -Tube.Nr., -Oxygen.condition, -Cell.type, -Experiment, -Day, -Well, -Label)

Lactate.data_long$variable <- factor(Lactate.data_long$variable, levels = c("Lactate", "Glucose"))

levels(Lactate.data_long$variable) <- c("Lactate", "Glucose")

Lactate.data_long <- Lactate.data_long %>% 
                        dplyr::rename(test = variable)

##统计代谢物(所有孔)

stat_Metabolites.test <- Lactate.data_long %>%
                                  group_by(Oxygen.condition, Day, test) %>%
                                  dunn_test(value ~ Cell.type) %>%
                                  add_xy_position(x = "test") %>%
                                  arrange(p.adj)
stat_Metabolites.test

##统计代谢物(实验)

stat_Metabolites.test.exp <- Lactate.data_long %>%
                                  group_by(Oxygen.condition, Day, test, Experiment) %>%
                                  dunn_test(value ~ Cell.type) %>%
                                  add_xy_position(x = "test") %>%
                                  arrange(p.adj)
stat_Metabolites.test.exp

##剧情

Lactate_plot <- ggplot(Lactate.data_long, aes(x = test, y = value)) +
                    geom_boxplot(aes(fill = Cell.type),
                                  size = 0.8,
                                  alpha = 0.6,
                                 color = "black",
                                 lwd = 0.2,
                                 outlier.shape = NA,
                                 position = position_dodge(width = 0.75)) +
                    stat_summary(fun = mean,
                               geom = "point",
                               size = 1.7,
                               fill = "white",
                               shape = 23,
                               color = "black",
                               alpha = 1,
                               aes(group = Cell.type),
                               position = position_dodge(width = 0.75)) +
#                    coord_cartesian(ylim = c(0, 50)) +
#                    scale_y_continuous(breaks=seq(0,50, 5)) +
                    scale_fill_manual(values = colors_Lactate) +
                    ylab(expression(bold(paste("concentration")))) +
                    # geom_label(data = prolif_des.stat, aes(x = time, group = celltype, label = paste0("n=", n),
                    #                                        y = 0),
                    #            position = position_dodge(width = 0.75),
                    #            size = 2.5,
                    #            fontface = "bold",
                    #            color = "gray40") +
                    facet_grid(Oxygen.condition ~ Day) +
                    theme_bw() + 
                    stat_pvalue_manual(stat_Metabolites.test.exp,
                                                 label = "p.adj.signif",
                                                 size = 5,
#                                                 y.position = 40,
                                                 bracket.size = 0.3,
                                                 remove.bracket = FALSE,
                                                 hide.ns = TRUE) +
                              theme(legend.title = element_blank(),
                                    #legend.position = c(0.1, 0.9),
                                    legend.position = "top",
                                    legend.text = element_text(size = 7, face = "bold"),
                                    legend.text.align = 0,
                                    legend.background = element_blank(), 
                                    legend.key = element_blank(),
                                    panel.border = element_rect(colour = "black", size=.5),
                                    axis.title.y = element_text(size= 9, face = "bold", colour = "black"),
                                    axis.title.x = element_blank(),
                                    axis.ticks = element_line(colour = "black", size = .3),
                                    panel.grid.minor = element_blank(),
                                    panel.grid.major = element_line(size=0.2),
                                    axis.text.y = element_text(size = 7, face = "bold", colour = "black"),
                                    axis.text.x = element_text(size = 9, face = "bold", colour = "black"),
                                    axis.ticks.length=unit(.5, "mm"),
                                    strip.text = element_text(color = "black", size = 9, face = "bold"),
                                    panel.spacing = unit(1, "mm"))
Lactate_plot

#ggsave(paste0(export.dir, "_Lactate_plot.pdf"), plot = Lactate_plot, height = 4.5, width = 9, units = "cm")
r plot p-value
© www.soinside.com 2019 - 2024. All rights reserved.