Rob*_*ats 5 r cluster-analysis binary-matrix
我想在R中的二进制矩阵上应用byclustering。有一个很好的包叫做“ biclust”,但它确实可以,并且不显示我想要的所有内容。
我有一个二进制矩阵,如下所示:
1 0 0 1 0 1 0
0 0 0 0 0 0 0
0 0 1 0 1 0 0
1 0 0 1 0 1 0
0 0 1 0 1 0 0
1 0 0 1 0 1 0
0 0 0 0 0 0 0
Run Code Online (Sandbox Code Playgroud)
我的目标是将其显示为(并显示)如下(可以是彩色的):
1 1 1 0 0 0 0
1 1 1 0 0 0 0
1 1 1 0 0 0 0
0 0 0 1 1 0 0
0 0 0 1 1 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Run Code Online (Sandbox Code Playgroud)
设置代码:
# install.packages("biclust") (if necessary)
library("biclust")
testMatrix <- matrix(c(1,0,0,1,0,1,0,
0,0,0,0,0,0,0,
0,0,1,0,1,0,0,
1,0,0,1,0,1,0,
0,0,1,0,1,0,0,
1,0,0,1,0,1,0,
0,0,0,0,0,0,0),
nrow = 7,
ncol = 7,
byrow = TRUE)
Run Code Online (Sandbox Code Playgroud)
我应用了“ biclust” R包的biclust函数:
testCluster <- biclust(x = testMatrix, method=BCBimax())
Run Code Online (Sandbox Code Playgroud)
实际上,我得到了预期的两个集群:
An object of class Biclust
call:
biclust(x = testMatrix, method = BCBimax())
Number of Clusters found: 2
First 2 Cluster sizes:
BC 1 BC 2
Number of Rows: 3 2
Number of Columns: 3 2
Run Code Online (Sandbox Code Playgroud)
我都可以通过以下方式分别显示集群:
drawHeatmap(x = testMatrix, bicResult = testCluster, number = 1) # shown in picture below
drawHeatmap(x = testMatrix, bicResult = testCluster, number = 2)
Run Code Online (Sandbox Code Playgroud)

我可以通过以下方式显示整个群集矩阵(左上角为一个群集):
drawHeatmap2(x = testMatrix, bicResult = testCluster, number = 1) # shown in picture below
drawHeatmap2(x = testMatrix, bicResult = testCluster, number = 2)
Run Code Online (Sandbox Code Playgroud)

到目前为止一切顺利,但我想要:
这些更改是否可能(使用“ biclust”软件包)?还是用R用另一种方式做更好?
更改biclust源码包中的drawHeatmap()函数: