简体   繁体   English

R 中的双向 ANOVA 后每组的多重比较(事后)

[英]Multiple comparison(Post hoc) for each group after two way ANOVA in R

I'm very new to R and need some help getting it to do the analysis I want.我对 R 很陌生,需要一些帮助才能完成我想要的分析。 I have a dataframe like this (simplified):我有一个 dataframe 像这样(简化):

   Gene time      Expression
1    Gene1       W1  18.780294
2    Gene2       W1  13.932397
3    Gene3       W1  20.877093
4    Gene1       W2   9.291295
5    Gene2       W2  10.939570
6    Gene3       W2  12.236713
7    Gene1       W3  13.810722
8    Gene2       W3  23.944473
9    Gene3       W3  17.355429

I want to know if there is a significant difference between the mean 'Expression' values for the Genes (Gene 1, 2, 3,) at each time point (Week1, W2, W3...).我想知道每个时间点(第 1 周、第 2 周、第 3 周...)的基因(基因 1、2、3)的平均“表达”值之间是否存在显着差异。 For example, I'm interested to know if at week 3( W3) the expression of Gene1 is significantly different than Gene2 I have performed an ANOVA and TukeyHSD例如,我很想知道在第 3 周(第 3 周)Gene1 的表达是否与 Gene2 显着不同我进行了 ANOVA 和 TukeyHSD

my_ANOVA = aov(Expression ~ Gene , data = my_Data)
summary(my_ANOVA)

my_posthoc =TukeyHSD(my_ANOVA, which = "Gene") 
my_posthoc

the results are结果是

  Tukey multiple comparisons of means
    95% family-wise confidence level

Fit: aov(formula = Expression ~ Gene, data = my_Data)

$Gene
                 diff       lwr      upr     p adj
Gene2-Gene1 2.3113763 -11.24096 15.86371 0.8631245
Gene3-Gene1 2.8623080 -10.69002 16.41464 0.8002795
Gene3-Gene2 0.5509317 -13.00140 14.10326 0.9914716

It gives me the total comparission of Gene1 to Gene2 for entire timeline.它为我提供了 Gene1 与 Gene2 在整个时间线上的总体比较。 But I want to know specifically if in time W1, Gene1 and 2 are diffrerent, or what about in time W3但我想具体了解 W1、Gene1 和 2 时间是否不同,或者 W3 时间如何

If you just want to split the data by time and run each analysis separately, that is pretty straightforward although the data set is too small to produce useable results:如果您只想按时间拆分数据并分别运行每个分析,尽管数据集太小而无法产生可用的结果,但这非常简单:

my_Data.W <- split(my_Data, my_Data$time)
lapply(1:3, function(x) summary(aov(Expression~Gene, data=my_Data.W[[x]])))
lapply(1:3, function(x) TukeyHSD(aov(Expression~Gene, data=my_Data.W[[x]])))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM