【问题标题】:How to get P value in the accumulation density plot?如何在累积密度图中获得 P 值?
【发布时间】:2020-10-22 10:46:45
【问题描述】:

我有一个结构如下的数据框:

> str(mydata12)
'data.frame':   228459 obs. of  2 variables:
 $ intron_length: num  0.787 0.799 2.311 2.396 1.77 ...
 $ intron_type  : Factor w/ 3 levels "All_intron","All_retained_intron",..: 1 1 1 1 1 1 1 1 1 1 ...

我已经根据这个数据框绘制了一个累积密度图:

p <- ggplot(mydata12, aes(x = intron_length, color=intron_type)) + geom_step(aes(y=..y..),stat="ecdf")

现在我想通过在 3 组中添加 p 值来进行比较:

> compare_means(intron_length~intron_type, data = mydata12)
> my_comparisons <- list(c("All_intron", "All_retained_intron"), c("All_intron", "dynamic_intron"), c("All_retained_intron", "dynamic_intron"))
> p + stat_compare_means(comparisons = my_comparisons)
Error in f(...) : 
  Can only handle data with groups that are plotted on the x-axis

我想我需要在x轴上设置一个值来进行比较,我的问题是如何设置x轴值并添加p值?

谢谢,

【问题讨论】:

    标签: r ggplot2 statistics statistical-test


    【解决方案1】:

    你不能在你拥有的东西之上叠加你想要的东西,它们是非常不同的比例和轴,但你可以做到这一点(我编造了数据,因为你没有提供......

      library(ggpubr)
    #> Loading required package: ggplot2
      library(ggplot2)
      # Pairwise comparisons: Specify the comparisons you want
      my_comparisons <- list(c("All_intron", "All_retained_intron"), c("All_intron", "dynamic_intron"), c("All_retained_intron", "dynamic_intron"))
      ggboxplot(mydata12, x = "intron_type", y = "intron_length",
                color = "intron_type", palette = "npg")+
        # Add pairwise comparisons p-value
        stat_compare_means(comparisons = my_comparisons, label.y = c(1.2, 1.3, 1.4))+
        stat_compare_means(label.y = 1.5)     # Add global Anova p-value  
    

    mydata12 <- data.frame(intron_length = runif(1000, min = 0, max = 1), 
                           intron_type = sample(c("All_intron", "All_retained_intron" , "dynamic_intron","All_retained_intron"), size = 1000, replace = TRUE))
    
    
    

    【讨论】:

    • 感谢您的回复。我有点知道这种方式。有什么方法可以得到曲线的斜率并进行比较?
    • 我建议你把你的问题带到 stats exchange 并寻找像这样的问题stats.stackexchange.com/questions/115132/…
    • 非常感谢您的回复。我已经看到了两组累积密度曲线之间的比较。喜欢:reader.elsevier.com/reader/sd/pii/…(图 1E)。他们使用的方法是:“为了比较脊柱间距离分布,使用了 Kolmogorov-Smirnov 两样本检验。在 GraphPad Prism 5 中进行了线性回归。假设数据分布是正常的,尽管没有经过正式测试”。所以我想知道我是否可以对我的数据做同样的事情
    猜你喜欢
    • 1970-01-01
    • 2019-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-13
    • 1970-01-01
    • 1970-01-01
    • 2013-07-29
    相关资源
    最近更新 更多