小编Ale*_*ohn的帖子

从成对矩阵中,找到等于某个值的最大个体群体

我有一个 39x39 的成对相关性矩阵,其中包含 39 个个体的所有成对组合的相关性值。我想找到完全不相关的最大个体组,即该组中所有成对相关性值都等于 0。

在 R 中是否有一种简单的方法可以做到这一点?

一个更简单的例子:

set.seed(420)

#Create the matrix
relatedness.matrix <- matrix(data = sample(x = c(0.5, 1, 0,0), size = 25, replace = TRUE), nrow = 5, ncol = 5)

# Matrix has the same upper and lower triangles
relatedness.matrix[upper.tri(relatedness.matrix)] <- relatedness.matrix[lower.tri(relatedness.matrix)]

# Add names for simplicity of reference
colnames(relatedness.matrix) <- letters[1:5]
rownames(relatedness.matrix) <- letters[1:5]

# Relatedness between the same individual does not count
diag(relatedness.matrix) <- NA
Run Code Online (Sandbox Code Playgroud)

在这种情况下,存在三种可能的解决方案:仅包含 和 的 2x2 矩阵e、仅包含和 的 …

algorithm r matrix igraph submatrix

4
推荐指数
1
解决办法
121
查看次数

标签 统计

algorithm ×1

igraph ×1

matrix ×1

r ×1

submatrix ×1