如何为大型数据集计算偏相关?

时间:2019-01-04 20:31:19

标签: r correlation large-data partial

我在转置的Excel中有一个93x16973数据集,因此有16973列是对93个主题的观察。 以前,我一直在使用WGCNA cor()将前三列(行为输出)与16969个基因输出中的每一个相关联。 现在,我想在控制sex时进行相同的关联(第4列)。

不幸的是,WGCNA中似乎没有偏相关函数。我的数据中缺少一些值,因此pcor.test()包中的ppcor函数也不起作用:

  

(if(det(cvx)<.Machine $ double.eps)中的错误{:缺少值   需要TRUE / FALSE的地方)

我也尝试过:

library(psych)  
par <- partial.r(data=t, x=c(1:5), y="Sex", use="pairwise.complete.obs",method="pearson")  
p <- corr.p(par,100,adjust="fdr",alpha=.05,minlength=5) 

partial.r的规模很小(例如100x100矩阵),但是partial.rppcor都很慢。如何最好地计算大型数据集的偏相关性?

library(WGCNA)
Behavior1 <- cor(t, t$behavior1,"pairwise.complete.obs")

摘录自数据(提供了16969个基因中的4个):

t <- data.frame(
     behavior1 = c(3.87, 3.45, 3.35, 3.84, 4.04, 3.24, 4, 3.37, 3.01, 3.33,
                3.78, 3.55, 4.02, 3.42, 3.76, 3.78, 3.63, 3.64, 3.78, 3.96,
                3.93, 3.74, 3.69, 3.82, 3.85, 4.11, 3.66, 3.98, 3.65, 3.51,
                3.81, 3.91, 3.56, 3.44, 3.59, 3.79, 3.96, 3.78, 3.23, 3.78,
                3.9, 3.73, 3.53, 3.65, 3.41, 3.85, 3.03, 3.69, 4, 3.76, 3.57,
                3.5, 3.08, 3.73, 3.94, 3.66, 3.69, 3.66, 3.8, 3.62, 3.43,
                3.73, 3.76, 3.51, 3.71, 3.86, 2.99, 3.67, 3.89, 3.76, 3.86, 4,
                3.59, 3.8, 3.47, 3.93, 3.75, 3.7, 3.83, 3.63, NA, 3.9, 4.07,
                3.95, 3.7, 3.97, 3.89, 3.36, 3.77, NA, 3.76, 2.91, 3.58),
     ILMN_3241953 = c(1.86562, 8.459514, 7.880089, 10.61735, 5.196902, 2.033149,
                12.38572, 0.8647639, 12.75295, 15.21354, 2.24112, 5.552258,
                5.195628, 16.04504, 6.876413, 4.02035, 13.12731, 8.028225,
                1.856901, 11.46528, 4.725763, 9.445942, 6.283611, 13.83586,
                12.47788, 29.26694, 10.64108, 9.789977, 13.23701, 9.609072,
                11.79091, 15.10062, 7.352033, 7.959264, 1.905873, 8.083849,
                10.33348, 14.6799, 11.80977, 6.864649, 6.916383, 10.81873,
                13.2028, 21.50828, 5.890249, 15.03128, 10.56613, 19.94481,
                10.17936, 12.66575, 7.586308, 7.806575, 8.704549, 5.335357, 7.699616,
                34.76136, 11.13113, 17.35604, 11.6327, 5.200667, 14.90452,
                8.03412, 8.582583, 13.34801, 12.30844, 11.24979, 18.74463,
                10.23545, 13.91181, 6.814572, 4.410583, 3.89191, 16.44888,
                0.5478389, 14.05083, 0.9818344, 5.46088, 6.464934, 8.383039,
                4.352509, 17.0204, 4.908329, 5.367795, 18.50093, 9.895, 8.319394,
                4.361558, 15.50142, 14.14206, 3.52875, 7.236896, 4.783107,
                6.072879),
     ILMN_1698554 = c(11.24305, 15.19111, 8.724502, 13.73847, 5.636255, 15.08227,
                11.1462, 2.676554, 5.814453, 11.55302, 15.13605, 11.97654,
                11.12255, 8.100506, 9.62424, 3.153203, 8.070821, 10.72084,
                11.64883, 6.096145, 3.395771, 9.980273, 8.589151, 7.984482,
                7.76228, 11.83416, 18.79749, 6.545389, 9.754912, 5.228722,
                10.60549, 11.3064, 18.19926, 8.496173, 13.66563, 8.428167,
                6.259226, 11.43009, 15.69174, 7.841702, 10.62688, 5.629808,
                15.94741, 11.85425, 9.432907, 13.39982, 10.70535, 10.36375, 7.610818,
                14.64722, 9.31569, 6.044395, 7.163122, 12.84912, 11.32881,
                9.923503, 4.947405, 8.339462, 6.700985, 8.228653, 9.476689,
                5.653269, 10.54204, 4.829041, 9.697079, 7.237853, 10.42587,
                7.138208, 6.952907, 6.839823, 23.58036, 12.54927, 7.584239,
                9.184765, 14.49764, 4.610593, 8.251626, 5.766502, 7.705222,
                3.427453, 9.99439, 12.7553, 7.809082, 9.926963, 10.21132,
                6.822929, 8.419024, 11.29933, 7.144596, 10.53823, 2.701903, 1.273676,
                8.903035),
     ILMN_1814092 = c(14.09655, 3.236484, 0.4790741, 3.460028, 10.93244,
                -1.47103, 5.318704, 6.9707, 5.090292, 9.597718, 10.58223,
                1.417916, 2.791571, 4.825671, 7.887783, 6.190029, 0.09576139,
                12.06866, 5.125803, 5.048226, 7.09727, 5.130733, 5.398769,
                12.28184, 10.61735, 4.627721, 4.705222, 6.784023, 7.078596,
                5.21104, 2.343659, 5.668594, 12.61893, 7.481292, -0.08037195,
                5.617205, 4.316943, 5.871408, 8.724502, 8.6778, 8.725549,
                9.336863, 2.43883, 5.681762, 3.649841, 5.287123, 5.402188,
                1.514916, 13.14, 7.889078, 3.938475, 14.9457, 9.657222, 6.940049,
                6.042594, 10.22972, 6.784023, 11.62131, 12.44483, 12.15097,
                9.421704, 9.673363, 5.816054, 2.561229, 6.603389, 2.94555,
                6.319597, 5.632519, 7.68044, 5.504625, 4.228701, 11.81533,
                4.260988, 0.3443053, 7.934604, 6.025481, 7.592155, 10.37565,
                3.439587, 13.43459, 9.474955, 7.511785, 6.022338, 12.81814,
                4.695076, 5.07826, 0.1312141, 8.222358, 5.930322, 6.786084, 1.157282,
                3.465827, 5.265224),
     ILMN_2061446 = c(66.01967, 84.0225, 60.52418, 57.40842, 75.26898, 93.16347,
                44.12444, 73.85092, 82.40653, 58.21495, 65.85165, 90.94025,
                69.86243, 70.99273, 62.4541, 80.23679, 59.26899, 62.8159,
                87.66326, 61.188, 69.01614, 69.84354, 56.88053, 60.05682,
                58.35177, 48.1433, 75.00115, 48.09494, 101.5513, 71.03518,
                74.01564, 55.49668, 70.10391, 61.07185, 84.32491, 73.87627,
                66.29174, 61.68656, 55.88357, 57.99071, 61.3139, 70.00616, 68.9985,
                57.9141, 84.86591, 71.55486, 55.40856, 64.27545, 56.8367,
                49.21011, 53.49639, 85.65903, 97.66381, 84.89189, 57.61093,
                58.03226, 48.58107, 70.42307, 62.98471, 66.23519, 56.94366,
                72.28062, 80.04424, 59.04964, 71.1521, 57.86969, 68.465, 56.6186,
                71.45598, 80.64761, 97.45979, 72.53777, 56.25861, 67.05247,
                66.66214, 74.81381, 63.18349, 52.87654, 53.56787, 83.78439,
                64.25476, 75.47073, 54.77478, 102.6252, 58.0191, 75.38378,
                60.45977, 53.09535, 65.06853, 63.20076, 82.01757, 62.16152,
                69.50527),
     Sex = c(1L, 0L, 1L, 1L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L,
                1L, 1L, 1L, 0L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L,
                1L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 1L,
                1L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L,
                1L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 1L, 1L,
                1L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 0L,
                1L, 1L))

在这种情况下,我想将behavior1与4个基因中的每一个相关联,同时控制sex,这些CreateTimerQueue被赋值为0和1。

0 个答案:

没有答案