如何从 mixOmics CIM 中提取相关分数?

How to extract the correlation score from mixOmics CIM?

我想提取我所谓的 "correlation score" 用于填充 CIM 图中的颜色键图例(R 中的 mixOmics 包)以将其放入向量中。我所说的相关分数是指 "Color key" 图例中使用的不同颜色的相应数量,也就是说,例如“-7”对应深蓝色,“+7”对应红色。必须有一个我要提取的相应数字的矩阵。 Here is an example of CIM plot to illustrate. The example plot is from the mixOmics CIM tutorial here.

我为几个时间点绘制了多个 CIM,并想绘制此分数随时间的演变(在特定 X 与特定 Y 之间)。

我查看了 cim 函数(在我的例子中是 spls)使用的函数的结果,但没有找到这些数字。我还检查了 cim 函数本身 (cim function code),但找不到用于填充此图的内容。

它不是作为 cim 生成的对象的组件提供给您的。您可以自己计算相关系数,使用与 cim 来源相同的方法,即 cor(as.matrix(<the object you passed to cim>), method = "pearson")

如果你想在源代码中找到他们计算的地方,只需在the source code you linked to中搜索"pearson"。

如果您保存 cim 函数的输出,您将得到一个列表,其中还包括相关分数。请参阅下面的示例:

suppressMessages(library(mixOmics))
data(nutrimouse)
X <- nutrimouse$lipid
Y <- nutrimouse$gene
## create the model
nutri.rcc <- rcc(X, Y, ncomp = 3, lambda1 = 0.064, lambda2 = 0.008)
## run CIM
cim.res <- cim(nutri.rcc, xlab = "genes", ylab = "lipids", margins = c(5, 6))
## the estimated correlation scores
cim.res$mat[1:5,1:5]
#>                CYP24         UCP3         RARb2           MS        RXRg1
#> C22.4n.6 -0.01999813 -0.021422216 -0.0008888194 -0.057980829 -0.074168260
#> C20.2n.6  0.01671939  0.019221066  0.0071498086  0.005241631 -0.005110272
#> C18.2n.6 -0.03887285 -0.029912475 -0.0629494996 -0.019159813 -0.028949622
#> C20.1n.9  0.11292746  0.111650764  0.0896226940  0.107370773  0.110154733
#> C18.3n.3 -0.01226061 -0.007427514 -0.0293529129  0.006002495  0.004682637

reprex package (v0.3.0)

于 2020-01-07 创建