我使用以下代码列出了100个排列中的100个数字:
for(i in 3:length(GeneData)) {
# Grab the 37 observations in the gene
for(j in 1:37) {
genePerm[j] <- GeneData[j, i]
}
# 100 permutations
for(k in 1:100) {
genePerm <- sample(genePerm)
newA <- vector()
newB <- vector()
# 23 GeneA, 14 GeneB
for(l in 1:37) {
if(l < 24) {
newA[l] <- genePerm[l]
} else {
newB[l - 23] <- genePerm[l]
}
}
testChair[k] <- t.test(newA, newB)$p.value
}
permPValues[i - 2] <- mean(testChair)
}
数据集是1144个基因,每个基因有37个观察值。因此,目标是对每个基因进行一个for循环(3:1147),然后抓取所有1:37的观察值,并将其放入上述各个大小的A / B的随机样本中。从每个t.test中获取P值,然后将该排列运行100x。然后,我想在运行下一个基因之前在最后一条语句中保存这些P值的平均值。
运行此命令时,我收到50多个warnings():“ mean.default(testChair):参数不是数字或逻辑:返回NA”
class(testChair)
[1] "list"
str(testChair)
List of 100 num
数据的一个小例子:
Patient Class 1405_i_at 200030_s_at 200062_s_at
1 A 7.492258127 12.45140014 13.48393678
2 A 7.899176081 12.5622002 13.5087836
3 A 8.668834124 11.84527253 13.04315946
4 A 9.91313519 12.04905336 13.42893925
5 A 6.047972634 12.77472603 13.63448007
6 A 8.368976147 12.24842422 13.41529093
7 A 7.20836421 12.93198614 13.13948227
8 A 7.919268023 12.28964756 13.2397595
9 A 9.003944903 11.68261433 13.08924549
10 A 8.084666646 12.18271975 13.41492561
11 A 9.840143746 12.34283432 12.96360228
12 A 6.99033759 12.57560342 13.2587594
13 A 7.978610388 12.54610449 13.1813085
14 A 8.747926877 11.8624978 13.24270026
15 A 9.486237216 12.01866821 13.33474933
16 A 8.760956899 12.49961585 13.65201122
17 A 8.382102061 12.04592178 13.39857364
18 A 8.073885916 12.3062644 13.76705502
19 A 9.412851349 12.39448144 13.16896019
20 A 8.364735507 12.42232335 13.33859203
21 A 9.157396203 12.09875546 13.27433327
22 A 5.913420688 12.2529661 13.62515813
23 A 7.162806841 11.99874653 13.36516341
24 B 8.734138362 12.17417605 13.43827062
25 B 6.785358473 11.98805352 13.44471807
26 B 7.252916328 12.57831463 13.29748783
27 B 8.988631789 11.9242628 13.88455123
28 B 8.36856432 11.84448206 13.22715915
29 B 6.430597552 12.26866611 13.35831894
30 B 7.092622736 11.86263629 13.22220515
31 B 6.708408743 11.77572547 13.4647575
32 B 6.700810798 11.80986457 13.52356174
33 B 7.032134704 12.25581888 13.34332883
34 B 7.731854575 12.13688324 13.3219734
35 B 7.71243075 11.92484732 13.13499252
36 B 6.293368361 12.07172977 13.39202083
37 B 7.992184287 12.2412432 13.33908972