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
そして、私の目標は、これを次のように二重クラスター化 (および表示) することです (色付けされている場合があります)。
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
設定コード:
# 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)
「biclust」R パッケージの biclust 関数を適用しました。
testCluster <- biclust(x = testMatrix, method=BCBimax())
実際、期待される2つのクラスターを取得します。
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
次の方法で、両方のクラスターを別々に表示できます。
drawHeatmap(x = testMatrix, bicResult = testCluster, number = 1) # shown in picture below
drawHeatmap(x = testMatrix, bicResult = testCluster, number = 2)
クラスター化されたマトリックス全体 (左上隅にある 1 つのクラスター) を次のように表示できます。
drawHeatmap2(x = testMatrix, bicResult = testCluster, number = 1) # shown in picture below
drawHeatmap2(x = testMatrix, bicResult = testCluster, number = 2)
ここまでは良いですが、私が欲しいのは:
- ディスプレイの色が切り替わりました。1 が赤、0 が緑になりました。
- 元の行列の行と列を見たいです。現在、特定のクラスターの行番号と列番号のみが表示され (drawHeatMap を使用)、クラスター化されたマトリックス全体 (drawHeatMap2) の行番号と列番号は表示されていません。
- 整然としたクラスター化されたマトリックスが必要です。これで、drawHeatmap2 で指定されたクラスターのみが左上隅に表示されますが、マトリックスの残りの部分については、残りのマトリックスの左上隅から右下隅まで他のクラスターも適切に並べたいと思います。
これらの変更は可能ですか (「biclust」パッケージを使用)? それとも、Rで別の方法で行う方が良いですか?