title: Biclustering in R
body: <p>I want to apply byclustering on a binary matrix in R. There is a nice package called "biclust" available, but it does and displays not everything that I want.</p>
  
  <p>I have a binary matrix which looks like the following:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>And my goal is to bicluster (and display) this as following (may be colored):</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Set up code:</p>
  
  <pre><code># install.packages("biclust") (if necessary)
  library("biclust")
  
  testMatrix &lt;- 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)
  </code></pre>
  
  <p>I applied the biclust function of the "biclust" R package:</p>
  
  <pre><code>testCluster &lt;- biclust(x = testMatrix, method=BCBimax())
  </code></pre>
  
  <p>and indeed I get the two clusters expected:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I can both display the clusters separately by:</p>
  
  <pre><code>drawHeatmap(x = testMatrix, bicResult = testCluster, number = 1) # shown in picture below
  drawHeatmap(x = testMatrix, bicResult = testCluster, number = 2)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ES7QK.png" alt="Picture"></p>
  
  <p>and I can display the entire clustered matrix (one cluster at upper left corner) by:</p>
  
  <pre><code>drawHeatmap2(x = testMatrix, bicResult = testCluster, number = 1) # shown in picture below
  drawHeatmap2(x = testMatrix, bicResult = testCluster, number = 2)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/9T427.png" alt="Picture"></p>
  
  <p>So far so good, but I want:</p>
  
  <ol>
  <li>Colors of display switched. Now the 1 is red and the 0 is green.</li>
  <li>I want to see the rows and columns of the original matrix. Now there are shown just the row numbers and column numbers of the specific cluster (with drawHeatMap) and there are shown no row and column numbers at the entire clustered matrix (drawHeatMap2).</li>
  <li>I want a nicely ordered clustered matrix. Now only the cluster specified in drawHeatmap2 is shown in the upper left corner, but for the rest of the matrix I also want the other clusters nicely ordered from the upper left corner to the lower right corner for the rest of the matrix.</li>
  </ol>
  
  <p>Are these changes possible (with the "biclust" package)? Or is it better to do it in another way with R?</p>