Mercurial > repos > peter-waltman > ucsc_cluster_tools2
view cluster.tools/cutree.R @ 9:a3c03541fe6f draft default tip
Uploaded
author | peter-waltman |
---|---|
date | Mon, 11 Mar 2013 17:30:48 -0400 |
parents | 0decf3fd54bc |
children |
line wrap: on
line source
#!/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 ) lib.load.quiet( ctc ) if ( any( c( 'flashClust', 'fastcluster' ) %in% installed.packages() ) ) { if ( 'flashClust' %in% installed.packages() ) { lib.load.quiet( flashClust ) } else { if ( 'fastcluster' %in% installed.packages() ) { lib.load.quiet( fastcluster ) } } } spec <- matrix( c( "dataset", "d", 1, "character", "num.k", "k", 1, "integer", "output.fname", "o", 2, "character" ), nc=4, byrow=TRUE ) opt <- getopt( spec=spec ) if ( is.null( opt$output.fname ) ) { opt$output.fname <- file.path( opt$output.report.dir, paste( "data", opt$output.format, sep="." ) ) } load( opt$dataset ) ## should load the cl, treecl.res (or partcl.res) and data if ( exists( 'treecl.res' ) ) { cutree.res <- cutree( treecl.res, k=opt$num.k ) cl <- cutree.res save( file=opt$output.fname, treecl.res, cl, data ) } else { stop( "no hierarchical clustering result found!\n" ) }