[英]How to merge the corr.test result ( correlaiton only or P value only) to a table
最近我想把 output 我所有的 corr.test 結果(corrlation)放到一個表中。
因為我有一個包含 3 萬個基因的龐大數據。
計算基因之間的相關性花了我很多時間。
如果我在 R 環境中使用 lapply 和 output 作為列表,它將占用大量 memory。
所以我想要 output 它們但只在一個表中,就像在 lapply 循環結束時將它們合並在一起一樣。 雖然會花費很多時間,但會節省很多 memory。
但是我不熟悉申請 function。 我不知道如何合並(相關或 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<-merge(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 輸入也更改為總數據。
這意味着完全計算與自身的相關性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.