Mercurial > repos > peter-waltman > ucsc_cluster_tools2
diff cluster.tools/cluster.tab.2.rdata.R @ 8:a58527c632b7 draft
Uploaded
author | peter-waltman |
---|---|
date | Mon, 11 Mar 2013 16:31:29 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cluster.tools/cluster.tab.2.rdata.R Mon Mar 11 16:31:29 2013 -0400 @@ -0,0 +1,35 @@ +#!/usr/bin/env Rscript +argspec <- c("tab.2.cdt.R converts a data matrix to cdt format + + Usage: + tab.2.cdt.R -d <data.file> + Optional: + -o <output_file> + \n\n") +args <- commandArgs(TRUE) +if ( length( args ) == 1 && args =="--help") { + write(argspec, stderr()) + q(); +} + + +lib.load.quiet <- function( package ) { + package <- as.character(substitute(package)) + suppressPackageStartupMessages( do.call( "library", list( package=package ) ) ) +} +lib.load.quiet(getopt) + + +spec <- matrix( c( "data.fname", "d", 1, "character", + "output.fname", "o", 2, "character" + ), + nc=4, + byrow=TRUE + ) + +opt <- getopt( spec=spec ) +if ( is.null( opt$output.fname ) ) opt$output.fname <- sub( "tab$|csv$", "cdt", opt$data.fname ) + +cl <- as.matrix( read.delim( opt$data.fname, row.names=1, check.names=FALSE ) ) +cl <- cl[,1] +save( file=opt$output.fname, cl )