我在单个拷贝区域中有 4 种基因型的观察计数样本。我想要做的是计算这些基因型的等位基因频率,然后使用 R 中的卡方检验这些频率与 25%:25%:25%:25% 的预期值显着偏离。
到目前为止,我得到了:
> a <- c(do.call(rbind, strsplit(as.character(gdr18[1,9]), ",")), as.character(gdr18[1,8]))
> a
[1] "27" "30" "19" "52"
接下来我得到总数:
> sum <- as.numeric(a[1]) + as.numeric(a[2]) + as.numeric(a[3]) + as.numeric(a[4])
> sum
[1] 128
现在频率:
> af1 <- as.numeric(a[1])/sum
> af2 <- as.numeric(a[2])/sum
> af3 <- as.numeric(a[3])/sum
> af4 <- as.numeric(a[4])/sum
> af1
[1] 0.2109375
> af2
[1] 0.234375
> af3
[1] 0.1484375
> af4
[1] 0.40625
我现在迷路了。我想知道 af1、af2、af3 和 af4 是否显着偏离 0.25、0.25、0.25 和 0.25
我如何在 R 中做到这一点?
谢谢你,阿德里安
编辑:
好吧,我正在按照建议尝试 chisq.test() :
> p <- c(0.25,0.25,0.25,0.25)
> chisq.test(af, p=p)
Chi-squared test for given probabilities
data: af
X-squared = 0.146, df = 3, p-value = 0.9858
Warning message:
In chisq.test(af, p = p) : Chi-squared approximation may be incorrect
试图告诉我的警告信息是什么?为什么近似值不正确?
为了测试这种方法,我选择了远离预期 0.25 的值:
> af=c(0.001,0.200,1.0,0.5)
> chisq.test(af, p=p)
Chi-squared test for given probabilities
data: af
X-squared = 1.3325, df = 3, p-value = 0.7214
Warning message:
In chisq.test(af, p = p) : Chi-squared approximation may be incorrect
在这种情况下,H0 仍然没有被拒绝,即使这些值与预期的 0.25 值相差甚远。