最近我想把我所有的corr.test结果(correlation(输出到一个表中。
因为我有3万个基因的庞大数据。
计算基因之间的相关性花了我很多时间。
如果我使用lapply并在R环境中将它们作为列表输出,这将占用大量内存。
所以我想输出它们,但只在一个表中,就像在lapply循环的末尾将它们合并在一起一样。虽然这会花费很多时间,但会节省很多内存。
但是我不熟悉应用函数。我不知道如何将(相关性或p值(结果全部合并。
我需要你的帮助。
这是我的样本数据和代码:
data_logg<-structure(c(6.05572382866802, 11.1380021588504, 9.3044407551291,
7.87123980178745, 10.1452025129037, 8.93954331139168, 7.72897302870656,
8.31753461010792, 6.91902649139208, 8.81063297295094, 22.5569750353369,
31.520979452157, 28.3261317078564, 25.402957920785, 35.8148569235307,
27.8723220522029, 41.0335341398849, 28.5846501726903, 21.398001509988,
33.063696558847, 15.182913110301, 14.6438943008441, 16.1624032499377,
13.1264245066984, 13.4072656803608, 14.7364553246895, 13.1211732101273,
14.3003714459557, 14.918175412959, 15.7912093225492, 0.0931714621767618,
0.0303852980725358, 0.0114778232990823, 0.0260809645231031, 0,
0.0310539968593767, 0.019047166325137, 0.0105050244811974, 0.0264828042698263,
0.0346757324524723, 3.46286706915552, 4.99156437489882, 5.70180521646014,
4.0868441874337, 4.51377652615602, 5.35554484236395, 5.44397291505049,
6.57811217176637, 5.10097757787774, 5.18489532380933, 1.12546006270081,
1.91823256736007, 1.8500381393557, 1.4401998592, 1.14712309386819,
1.63756861783462, 1.63809356500207, 1.99896249233356, 1.3388769544766,
2.07437306868356, 1.5068638533804, 2.63183788279904, 3.12822707867838,
2.44752756389731, 2.37001697139819, 2.51118444838866, 3.48267851492631,
3.26267014874084, 1.75288566197561, 2.80059464803222, 21.3209507790769,
22.6744418461091, 16.9622647095367, 22.2902884855603, 25.7854403101755,
20.6976499521803, 24.1019869113154, 24.764924561036, 22.8547950562338,
15.9953039663019), .Dim = c(10L, 8L), .Dimnames = list(NULL,
c("Zzef1", "Zyx", "Zyg11b", "Zyg11a", "Zxdc", "Zxdb", "Zxda",
"Zwint")))
Correlation_list<-lapply(colnames(data),function(ii){
i<-match(ii,colnames(data))
# i<-ii %in% colnames(data_logg)
tm <- corr.test(data[,i,drop=FALSE],
y = data[,-i], use = "pairwise", "spearman", adjust="none",
alpha=0.05, ci=F, minlength=5)
res<-t(tm["r"])
colnames(res)<-paste0(ii,"_Correlaiton")
na.omit(res)
data_merege<-merge(res,) ## ? Here I don't know how to do it.
})
下一步如何处理:data_merege<-合并(res,(
编辑:2021-03-26 09:20:55。
对不起,我一个人答对了。我太愚蠢了,可以用corr.test.来完成
这让我日夜担忧。
我的答案:
tm <- corr.test(data_cor,
y = data_cor, use = "pairwise", "spearman", adjust="none",
alpha=0.05, ci=F, minlength=5)
tm$r
tm$p
只需将x输入更改为总数据即可。
它意味着完全计算与自身的相关性。