如何计算样本中两个矩阵的相关性?

时间:2016-04-13 14:42:26

标签: r matrix statistics bioinformatics

我在以下两个矩阵中有甲基化计数数据。

cov <- matrix(sample(0:7, 100,replace=TRUE), nrow=10, ncol=10)
colnames(cov) <- c("group1_1", "group1_2", "group1_3", "group1_4", "group1_5", "group2_1", "group2_2", "group2_3", "group2_4", "group2_5")
meth <- matrix(sample(7:10, 100,replace=TRUE), nrow=10, ncol=10)
colnames(meth) <- c("group1_1", "group1_2", "group1_3", "group1_4", "group1_5", "group2_1", "group2_2", "group2_3", "group2_4", "group2_5")

每个矩阵中的前五个样本属于group1,后五个样本属于group2。

我被要求查看样本间跨矩阵的相关性,目的是识别异常值。我该如何进行此测试以及我应该寻找什么?

1 个答案:

答案 0 :(得分:0)

> cor(cov,meth)
            group1_1    group1_2     group1_3    group1_4    group1_5    group2_1    group2_2    group2_3    group2_4    group2_5
group1_1  0.21638563  0.26179603 -0.172564260  0.14098148 -0.11261065 -0.86945839 -0.16405826 -0.32978834  0.26342717 -0.38467159
group1_2 -0.26060328  0.03941164 -0.071940171 -0.21223818 -0.34874292 -0.03197341 -0.10639084 -0.28093179 -0.05287626  0.20590128
group1_3  0.33691014  0.32423812 -0.151250339 -0.06984303  0.06375767 -0.38141390  0.07502345 -0.46224312 -0.08700222 -0.50818268
group1_4 -0.23652496  0.16692770  0.067711562  0.40451992 -0.49236596  0.23699047 -0.33796318 -0.32824398 -0.07465233  0.05450583
group1_5 -0.73285503 -0.50264369  0.527453045  0.40013848 -0.18263739  0.35015790 -0.65736821  0.12892051 -0.55708601  0.08563044
group2_1 -0.08770580  0.33425161  0.150648715  0.12000000 -0.18257419 -0.33895961 -0.07161149 -0.04564355  0.41522740  0.09701425
group2_2 -0.34352146 -0.22627786 -0.163903595  0.24370872  0.19863804 -0.06556144  0.40514370 -0.07945522 -0.72281812  0.04222003
group2_3 -0.08047913 -0.24612562  0.003839882  0.30586777  0.06515082 -0.26495187 -0.23363889 -0.71665901  0.14393864 -0.51928682
group2_4 -0.57395577 -0.58228781  0.344024289  0.35447222  0.54760943  0.13863665  0.20502690 -0.23646771 -0.57742427 -0.23146346
group2_5  0.00000000  0.14099041 -0.020425184 -0.28200960  0.39605902 -0.14297629  0.73789886  0.44556639 -0.40533961  0.28937350