annotate cluster.tools/cluster.tab.2.rdata.R @ 9:a3c03541fe6f draft default tip

Uploaded
author peter-waltman
date Mon, 11 Mar 2013 17:30:48 -0400
parents a58527c632b7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
1 #!/usr/bin/env Rscript
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
2 argspec <- c("tab.2.cdt.R converts a data matrix to cdt format
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
3
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
4 Usage:
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
5 tab.2.cdt.R -d <data.file>
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
6 Optional:
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
7 -o <output_file>
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
8 \n\n")
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
9 args <- commandArgs(TRUE)
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
10 if ( length( args ) == 1 && args =="--help") {
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
11 write(argspec, stderr())
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
12 q();
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
13 }
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
14
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
15
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
16 lib.load.quiet <- function( package ) {
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
17 package <- as.character(substitute(package))
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
18 suppressPackageStartupMessages( do.call( "library", list( package=package ) ) )
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
19 }
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
20 lib.load.quiet(getopt)
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
21
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
22
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
23 spec <- matrix( c( "data.fname", "d", 1, "character",
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
24 "output.fname", "o", 2, "character"
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
25 ),
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
26 nc=4,
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
27 byrow=TRUE
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
28 )
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
29
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
30 opt <- getopt( spec=spec )
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
31 if ( is.null( opt$output.fname ) ) opt$output.fname <- sub( "tab$|csv$", "cdt", opt$data.fname )
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
32
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
33 cl <- as.matrix( read.delim( opt$data.fname, row.names=1, check.names=FALSE ) )
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
34 cl <- cl[,1]
a58527c632b7 Uploaded
peter-waltman
parents:
diff changeset
35 save( file=opt$output.fname, cl )