Mercurial > repos > peter-waltman > ucsc_cluster_tools2
comparison cluster.tools/hclust.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 |
---|---|
37 byrow=TRUE | 37 byrow=TRUE |
38 ) | 38 ) |
39 | 39 |
40 opt <- getopt( spec=spec ) | 40 opt <- getopt( spec=spec ) |
41 | 41 |
42 data <- as.matrix( read.delim( opt$data.fname, header=T, row.names=1 , check.names=FALSE ) ) | |
42 if ( is.null( opt$distance.metric ) ) { opt$distance.metric <- "euclidean" } | 43 if ( is.null( opt$distance.metric ) ) { opt$distance.metric <- "euclidean" } |
43 if ( is.null( opt$dist.obj ) ) { opt$dist.obj <- FALSE } | 44 if ( is.null( opt$dist.obj ) ) { opt$dist.obj <- FALSE } |
44 if ( is.null( opt$direction ) ) { opt$direction <- "cols" } | 45 if ( is.null( opt$direction ) ) { opt$direction <- "cols" } |
45 if ( is.null( opt$linkage ) ) { opt$linkage <- "average" } | 46 if ( is.null( opt$linkage ) ) { opt$linkage <- "average" } |
46 if ( is.null( opt$num.k ) ) { opt$num.k <- 10 } | |
47 if ( is.null( opt$output.name ) ) { opt$output.name <- "hclust.result.rda" } | 47 if ( is.null( opt$output.name ) ) { opt$output.name <- "hclust.result.rda" } |
48 if ( is.null( opt$num.k ) || ( opt$num.k == -1 )) { | |
49 if ( opt$direction == 'cols' ) { | |
50 opt$num.k <- 5 | |
51 } else if ( opt$direction == 'rows' ) { | |
52 opt$num.k <- nrow( data ) / 30 ## we use an estimated average size of gene clusters to be 30 | |
53 if ( opt$num.k > 1000 ) { | |
54 opt$num.k <- ( opt$num.k %/% 10 ) * 10 | |
55 } else { | |
56 opt$num.k <- ( opt$num.k %/% 5 ) * 5 | |
57 } | |
58 } | |
59 } | |
48 | 60 |
49 data <- as.matrix( read.delim( opt$data.fname, header=T, row.names=1 , check.names=FALSE ) ) | |
50 if ( opt$direction == "cols" ) { | 61 if ( opt$direction == "cols" ) { |
51 ## need to transpose b/c both kmeans & pam cluster the rows | 62 ## need to transpose b/c both kmeans & pam cluster the rows |
52 ## this shouldn't have an effect upon a distance matrix | 63 ## this shouldn't have an effect upon a distance matrix |
53 data <- t( data ) | 64 data <- t( data ) |
54 } | 65 } |