2016-07-21 12 views
2

Rのバイナリマトリックスでbyclusteringを適用したいのですが、 "biclust"と呼ばれる素敵なパッケージがありますが、必要なものすべてが表示されているわけではありません。Biclustering in R

私は次のようなバイナリ行列があります(着色されていてもよい)、次のよう

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 

そして、私の目標はbicluster(および表示)することで、これを:

セットアップ
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) 

Picture

と私は全体を表示することができますクラスター化されたマトリックス(左上隅の1つのクラスター):

これまでのところ
drawHeatmap2(x = testMatrix, bicResult = testCluster, number = 1) # shown in picture below 
drawHeatmap2(x = testMatrix, bicResult = testCluster, number = 2) 

Picture

とても良いが、私はしたい:ディスプレイの

  1. 色が切り替わります。今、1は赤、0は緑です。
  2. 元の行列の行と列を見たいと思います。特定のクラスターの行番号と列番号(drawHeatMap)が表示され、クラスター化されたマトリックス全体(drawHeatMap2)に行番号と列番号は表示されません。
  3. きれいに整列したクラスタ化された行列が必要です。 drawHeatmap2で指定されたクラスターだけが左上隅に表示されますが、残りのマトリックスについては、他のクラスターも、残りのマトリックスの左上隅から右下隅に順番に並べ替えたいと思っています。

これらの変更は可能ですか(「biclust」パッケージの場合)?それともRを使って別の方法でそれをするのが良いですか?

+0

は、 –

+0

@RobbertRaats biclusterパッケージの*ソース*を使用して、あなたはそれができる方法を見つけ出すんでした – Turcia

+1

@Turcia、私はbiclustソースpackagパッケージにdrawHeatmap()目的球を変えました?: 2.次のように変更します:(a)赤と緑の切り替え - rgct(gbct)の呼び出しをrgb()に切り替えます(b)newではなく元のrownamesを変更します - 'labels ='を変更します。 (bicRows、file = "FILENAME.txt"):ファイルにローナを保存する - ローの軸の前にローを書き込む:write(bicRows、file = "FILENAME.txt") –

答えて

1

変更biclustソースpackagパッケージにdrawHeatmap()目的球:

  1. トレース( "drawHeatmap"、編集= TRUE)次
  2. 変更:
    は (a)は赤と緑のスイッチ - (b)newではなくオリジナルのrownames - 'labels =' to '= bicCols'と '= bicRows'を変更してください。
  3. rownumbersを印刷する:軸の前に行:cat(bicRows)。
  4. ファイルにrownumbersを保存します。軸については、行の前に:write(bicRows、file = "FILENAME。!TXT ")