comparison cluster.tools/rdata.2.out.R @ 8:a58527c632b7 draft

Uploaded
author peter-waltman
date Mon, 11 Mar 2013 16:31:29 -0400
parents 0decf3fd54bc
children
comparison
equal deleted inserted replaced
7:2efa1a284546 8:a58527c632b7
10 if ( length( args ) == 1 && args =="--help") { 10 if ( length( args ) == 1 && args =="--help") {
11 write(argspec, stderr()) 11 write(argspec, stderr())
12 q(); 12 q();
13 } 13 }
14 14
15 ## some helper fn's
16 write.2.tab <- function( mat,
17 fname ) {
18 mat <- rbind( colnames( mat ), mat )
19 mat <- cbind( c( "ID", rownames( mat )[-1] ),
20 mat )
21 write.table( mat, fname, sep="\t", row.names=FALSE, col.names=FALSE, quote=FALSE )
22 }
23
15 lib.load.quiet <- function( package ) { 24 lib.load.quiet <- function( package ) {
16 package <- as.character(substitute(package)) 25 package <- as.character(substitute(package))
17 suppressPackageStartupMessages( do.call( "library", list( package=package ) ) ) 26 suppressPackageStartupMessages( do.call( "library", list( package=package ) ) )
18 } 27 }
19 28
49 load( opt$dataset ) ## should load the cl, treecl.res (or partcl.res) and data 58 load( opt$dataset ) ## should load the cl, treecl.res (or partcl.res) and data
50 59
51 if ( opt$output.format %in% c( "cls-only", "newick" ) ) { 60 if ( opt$output.format %in% c( "cls-only", "newick" ) ) {
52 if ( opt$output.format == "cls-only" ) { 61 if ( opt$output.format == "cls-only" ) {
53 62
54 cl <- cbind( names( cl ), as.numeric( cl ) ) 63 cl <- matrix( as.numeric( cl ), nc=1, dimnames=list( names(cl), "Class" ) )
55 colnames( cl ) <- c( "ID", "Class" )
56
57 opt$output.fname <- gsub( "cls-only$", "tab", opt$output.fname ) 64 opt$output.fname <- gsub( "cls-only$", "tab", opt$output.fname )
58 write.table( cl, opt$output.fname, sep="\t", quote=FALSE, row.names=FALSE, col.names=FALSE ) 65
66 write.2.tab( cl, opt$output.fname )
59 } else { 67 } else {
60 ##if ( opt$output.format == "newick" ) { 68 ##if ( opt$output.format == "newick" ) {
61 69
62 if ( ! exists( "treecl.res" ) ) stop( "no HAC result found in results file proved - necessary to generate a Newick formated file.\n" ) 70 if ( ! exists( "treecl.res" ) ) stop( "no HAC result found in results file proved - necessary to generate a Newick formated file.\n" )
63 write( hc2Newick( treecl.res ), opt$output.fname ) 71 write( hc2Newick( treecl.res ), opt$output.fname )