diff cluster.tools/extract.cons.cluster.from.result.R @ 7:2efa1a284546 draft

Uploaded
author peter-waltman
date Mon, 04 Mar 2013 04:11:28 -0500
parents 0decf3fd54bc
children
line wrap: on
line diff
--- a/cluster.tools/extract.cons.cluster.from.result.R	Fri Mar 01 19:54:08 2013 -0500
+++ b/cluster.tools/extract.cons.cluster.from.result.R	Mon Mar 04 04:11:28 2013 -0500
@@ -37,7 +37,7 @@
 cons.matrices <- lapply( results[ 2:length(results) ], '[[', 'consensusMatrix' )
 cls <- lapply( results[ 2:length(results) ], '[[', 'consensusClass' )
 names( cons.matrices ) <- names( cls ) <- 2:length( results )
-
+save.image( '~/tmp/extract.dbg.rda' )
 ch.k.select <- as.character( opt$k.select )
 if ( ch.k.select %in% names( cls ) ) {
   ## get the consensusClass file that's associated with the k.select
@@ -51,6 +51,15 @@
     ## re-order the samples to follow the cluster assignment
     treecl.res <- results[[ opt$k.select ]]$consensusTree
     select.result <- results[[ opt$k.select ]]
+    
+    if ( length(cl) == ncol(data) ) {
+      names( cl ) <- treecl.res$labels <- select.result$consensusTree$labels <- colnames(data)
+    } else if ( length(cl) == nrow(data) ) {
+      names( cl ) <- treecl.res$labels <- select.result$consensusTree$labels <- rownames(data)
+    } else {
+      stop( "Number of clustered elements not equal to either number of rows or columns of data matrix\n" )
+    }
+    
     save( file=opt$output.select.rdata, treecl.res, cl, select.result, data )
   } else {
     stop( 'no valid output format specified\n' )