【问题标题】:Why is the wilcox.test results overlapping when I try to plot a graph?当我尝试绘制图表时,为什么 wilcox.test 结果重叠?
【发布时间】:2022-01-04 04:29:23
【问题描述】:

我正在尝试获取关于我的分面图的统计信息,但 wilcoxon 测试的输出重叠如下:

我使用的代码是这样的:

ggplot(df, aes(y = count, x = time, group = time)) + 
  theme_bw() +
  geom_boxplot()+
  theme(legend.position = "none")+
  scale_y_log10(limits = c(1, 250)) +
  facet_wrap(vars(cluster), scales = "fixed")+
  stat_compare_means(method= "wilcox.test")
 labs(y = "Clone count", x = "Time point")

我的数据如下所示:

structure(list(time = c("Day 0", "Day 0", "Day 0", "Day 0", "Day 0", 
"Day 0", "Day 0", "Day 0", "Day 0", "Day 0", "Day 1", "Day 1", 
"Day 1", "Day 1", "Day 1", "Day 1", "Day 1", "Day 1", "Day 1", 
"Day 1", "Day 2", "Day 2", "Day 2", "Day 2", "Day 2", "Day 2", 
"Day 2", "Day 2", "Day 2", "Day 2", "Day 2", "Day 2", "Day 2", 
"Day 2", "Day 2", "Day 2", "Day 2", "Day 2", "Day 2", "Day 2", 
"Day 2", "Day 2", "Day 2", "Day 2", "Day 2"), count = c(1L, 4L, 
1L, 1L, 1L, 1L, 2L, 3L, 1L, 1L, 59L, 1L, 1L, 1L, 3L, 1L, 2L, 
5L, 3L, 1L, 1L, 2L, 1L, 1L, 1L, 54L, 3L, 6L, 1L, 1L, 1L, 2L, 
1L, 1L, 7L, 1L, 3L, 1L, 207L, 5L, 3L, 3L, 11L, 2L, 1L), cluster = c("C", 
"C", "C", "C", "D", "D", "D", "D", "D", "D", "A", "A", "D", "D", 
"D", "C", "C", "C", "C", "C", "D", "D", "D", "D", "D", "B", "C", 
"B", "B", "C", "C", "C", "C", "C", "B", "B", "B", "A", "A", "A", 
"A", "A", "A", "A", "A")), row.names = c(NA, -45L), class = "data.frame")

另外,我该如何添加重要性条?

【问题讨论】:

    标签: r graph statistics


    【解决方案1】:

    指定comparisons 可能会有所帮助。

    my_comparisons <- list(c("Day 0", "Day 1"), c("Day 1", "Day 2"), c("Day 0", "Day 2"))
    ggplot(df1, aes(y = count, x = time)) + 
      theme_bw() +
      geom_boxplot()+
      theme(legend.position = "none")+
      scale_y_log10() +
      stat_compare_means(method= "wilcox.test", comparisons = my_comparisons)  +
      facet_wrap(.~(cluster), scales = "fixed")+
      labs(y = "Clone count", x = "Time point") +
      ylim(c(0,400))
    

    【讨论】:

    • 谢谢!但是为什么Day0和Day2没有比较呢?
    • @Chinemerem 那是因为打字错误...对不起...您可以更改ylim的号码。
    猜你喜欢
    • 2013-06-05
    • 2018-08-26
    • 2019-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    • 1970-01-01
    相关资源
    最近更新 更多