diff cluster.tools/fix.and.merge.TCGA.sample.IDs.R @ 1:dddfeedb85af draft

Uploaded
author peter-waltman
date Fri, 01 Mar 2013 10:16:53 -0500
parents 0decf3fd54bc
children 563832f48c08
line wrap: on
line diff
--- a/cluster.tools/fix.and.merge.TCGA.sample.IDs.R	Thu Feb 28 01:45:39 2013 -0500
+++ b/cluster.tools/fix.and.merge.TCGA.sample.IDs.R	Fri Mar 01 10:16:53 2013 -0500
@@ -12,6 +12,15 @@
   q();
 }
 
+## some helper fn's
+write.2.tab <- function( mat,
+                         fname ) {
+  mat <- rbind( colnames( mat ), mat )
+  mat <- cbind( c( "ID", rownames( mat )[-1] ),
+                      mat )
+  write.table( mat, fname, sep="\t", row.names=FALSE, col.names=FALSE, quote=FALSE )
+}
+
 lib.load.quiet <- function( package ) {
    package <- as.character(substitute(package))
    suppressPackageStartupMessages( do.call( "library", list( package=package ) ) )
@@ -116,4 +125,4 @@
 
 if ( transpose.back ) data <- t( data )
 
-write.table( data, opt$output.fname, sep="\t", quote=FALSE, col.names=NA )
+write.2.tab( data, opt$output.fname )