r - 我没有得到方差分析 lsmeans 的显着差异,但有一些非常显着的数据。我的脚本有什么问题?
问题描述
我没有得到方差分析 lsmeans 的显着差异,但有一些非常显着的数据。我的脚本有什么问题?
df <- structure(list(value = c(1.693086732, 0.25167691, 1.100272527, 1.60428654, 0.908237338, 1.449864567, 1.06604818, 0.596785144, 0.652925021, 0.453697295, 0.544252785, 1.464221767, 1.043720641, 0.735035158, 0.938875327, 0.712832947, 1.701854524, 1.021094251, 0.564349482, 2.326316679, 1.10170484, 1.075217638, 1.397442796, 0.501086703, 0.675502908, 0.846651623, 1.578086856, 1.857360967, 1.194232629, 1.875837087, 1.106882408, 1.112407609, 1.30479321, 0.637491754, 1.281566883, 1.103115742, 1.895286629, 1.623933836, 0.941989812, 1.30636425, 0.69977606, 1.937055334, 0.666069131, 0.829396619, 0.892844633, 0.573255443, 1.27370148, 0.531593222, 2.782899244, 0.972928201, 0.729463812, 1.121965821, 2.55117084, 0.999302442, 1.138902544, 1.656807007, 0.545349299, 0.550315908, 2.346074577, 0.637551271), gene = c("WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "WT", "aox2", "aox2", "aox2", "aox2", "aox2", "aox2", "aox2", "aox2", "aox2", "aox2", "aox2", "aox2", "aox5", "aox5", "aox5", "aox5", "aox5", "aox5", "aox5", "aox5", "aox5", "aox5", "aox5", "aox5", "aox7", "aox7", "aox7", "aox7", "aox7", "aox7", "aox7", "aox7", "aox7", "aox7", "aox7", "aox7", "aox9", "aox9", "aox9", "aox9", "aox9", "aox9", "aox9", "aox9", "aox9", "aox9", "aox9", "aox9"), time = c("0t", "0t", "0t", "1t", "1t", "1t", "3t", "3t", "3t", "5t", "5t", "5t", "0t", "0t", "0t", "1t", "1t", "1t", "3t", "3t", "3t", "5t", "5t", "5t", "0t", "0t", "0t", "1t", "1t", "1t", "3t", "3t", "3t", "5t", "5t", "5t", "0t", "0t", "0t", "1t", "1t", "1t", "3t", "3t", "3t", "5t", "5t", "5t", "0t", "0t", "0t", "1t", "1t", "1t", "3t", "3t", "3t", "5t", "5t", "5t")), row.names = c(NA, -60L), class = c("data.table", "data.frame"))
我用过的脚本:
library(emmeans)
fit <- aov(value ~ gene*time, df)
summary(fit)
em <- emmeans(fit, ~ gene | time)
pairs(em)
pairs(em, adjust=NULL)
当我使用 Std Err 在条形图中绘制数据时,我发现某些样本确实很重要,尤其是在第 3 天。我已经在成对 t 检验中对此进行了测试,并且这些样本在 p 0.05 时存在显着差异。
这是成对测试,即使 excel 在时间点 3 给出 sig 结果。
您能否尝试修复我的 ANOVA 和 ls 方法。
解决方案
不知道为什么您期望 Tukey HSD 成对比较很重要;Anova 中没有任何主要效果,情节中也没有任何明显的东西。
为了完整起见,即使主效应不是,您也可以让 Tukey HSD 显着,但这种情况很少见,重要的是提前决定哪个测试与您的问题更相关,而不是选择能提供“更好”结果的测试。
summary(fit)
## Df Sum Sq Mean Sq F value Pr(>F)
## gene 4 0.873 0.2184 0.625 0.648
## time 3 1.670 0.5568 1.593 0.206
## gene:time 12 1.577 0.1314 0.376 0.965
## Residuals 40 13.984 0.3496
library(ggplot2)
sem <- summary(em)
sem$gene <- relevel(factor(sem$gene), 'WT')
ggplot(sem) + aes(gene, emmean, ymin=lower.CL, ymax=upper.CL) + geom_pointrange() +
facet_wrap(~time, nrow=1) + ggtitle("emmeans with 95% CIs")
该图以红色显示原始数据(这很重要)。
顺便说一句,成对 t 检验在 0.05 水平上也不显着,即使没有对多重比较进行校正也不行。与您的代码一样,我每次都对基因进行成对测试。
library(broom)
library(tidyr)
library(dplyr)
options(digits=2)
lapply(split(df, df$time), function(x) {
data.frame(time=x$time[1], tidy(pairwise.t.test(x$value, x$gene, p.adjust.method="none")))
}) %>% bind_rows() %>% spread(time, p.value)
## group1 group2 0t 1t 3t 5t
## 1 aox5 aox2 0.82 0.32 0.71 0.97
## 2 aox7 aox2 0.32 0.73 0.21 0.70
## 3 aox7 aox5 0.43 0.50 0.37 0.67
## 4 aox9 aox2 0.31 0.40 0.60 0.71
## 5 aox9 aox5 0.42 0.86 0.88 0.74
## 6 aox9 aox7 0.99 0.62 0.45 0.45
## 7 WT aox2 0.85 0.72 0.20 0.74
## 8 WT aox5 0.97 0.51 0.34 0.71
## 9 WT aox7 0.41 0.99 0.95 0.96
## 10 WT aox9 0.40 0.63 0.42 0.49
但是,如果您在没有合并方差的情况下运行此程序(或者再次,没有校正多重比较),您确实会得到预期的结果,aox5 和 aox7 的 p 值为 3t = 0.016。
但是,由于这两个原因,这样做是错误的;首先,您确实应该纠正多重比较,其次,您没有足够的数据来充分估计方差,因此汇集很重要。您可以在原始数据中看到这一点;这两个碰巧比其他的拥有更严格的数据,但这几乎可以肯定是随机的。
## group1 group2 0t 1t 3t 5t
## 1 aox5 aox2 0.70 0.25 0.794 0.96
## 2 aox7 aox2 0.17 0.73 0.413 0.61
## 3 aox7 aox5 0.32 0.49 0.016 0.53
## 4 aox9 aox2 0.46 0.52 0.744 0.79
## 5 aox9 aox5 0.56 0.89 0.868 0.80
## 6 aox9 aox7 0.99 0.71 0.428 0.59
## 7 WT aox2 0.82 0.65 0.398 0.70
## 8 WT aox5 0.97 0.36 0.096 0.65
## 9 WT aox7 0.41 0.99 0.892 0.95
## 10 WT aox9 0.57 0.69 0.409 0.63
因此,简短的答案主要是具有成对检验的 ANOVA 与您的成对 t 检验不匹配,因为 ANOVA 汇集了 SD 但您的 t 检验没有,但更大的答案是您应该汇集并纠正多重比较,所以你一开始的代码,即:
pairs(em)
是正确的做法。
推荐阅读
- python - 在熊猫中创建列的编码列
- typescript - 接口类型推断
- asp.net - Web Api [授权] 在 IIS 8.5 中不起作用
- php - 获取图像的 mime 类型
- laravel-5 - 同时使用 have 和 paginate 方法时查询生成器错误
- r - networkDynamic R 可视化在协调的时间段上错误地调用顶点属性
- mysql - mysql 中的 DEFAULT CURRENT_TIMESTAMP 错误,同时更改表
- java - 从资产复制数据库时出错
- wordpress - 最初没有加载图像。当我们手动点击图片网址然后显示图片
- django - 具有两个过滤的单独列表的基于 Django 类的列表视图