【发布时间】:2019-03-04 14:11:40
【问题描述】:
我是 r 的新手
我正在 R 中执行置换测试以确定某些 SNP 的出现百分比是否是偶然的 我的数据设置了一个包含 52K 值的向量 我按原样通过 Loop 进行测试:
R1_H <- R1[,12] #extract the vector from a dataframe
niter=100000 #set the number of iterations
out <- rep(0,length(R1_H))
for (i in 1:niter){
out = out + (R1_H <= sample(R1_H)) #compare my ocurrence against a
#sample of the entire population
}
pvalue=out/niter #determine the pvalue
R1$pvalueF = pvalue #print the pvalue
问题是这种方式极其缓慢且耗费资源。 有人认为更有效的方法吗? 非常感谢
【问题讨论】:
标签: r loops permutation