问题描述
我的目标是使用 ggpubr 制作包含不同组之间统计数据的箱线图。我使用以下代码来制作箱线图,但我不确定如何包含例如控制主要对压力主要或主要对受控制的次要之间的comapirsions 的统计数据。
intensity<-read.table("light_intensity.txt",header = TRUE)
ggBoxplot(intensity,x = "Treatment",y = "Intensity",color = "Allele",palette = "jco")
从这个previous question,我知道添加
stat_compare_means(comparisons = my_comparisons)
可以解决我的问题。但是如何为我的特定数据集设计 my_comparison?
我的数据集看起来像,
Allele Intensity Treatment
Minor 6723.05258 Control
Minor 7022.128191 Control
Minor 6617.97381 Control
.
.
.
Major 5743.119742 STRESS
Major 5379.326667 STRESS
Major 7256.877569 STRESS
Major 5588.727273 STRESS
解决方法
向您的数据集添加一个新列,其中 Control Major
为 1
,Stress Major
为 2
。
将相应的值分配给所有所需的组,然后创建感兴趣的比较。
my_comp <- list( c("1","2"),c("1","3"),c("2",c("3","1"))