comparison abims_hclustering.r @ 0:2f7381ee5235 draft

Uploaded
author lecorguille
date Tue, 30 Jun 2015 06:36:09 -0400
parents
children 36fc0a87d7fb
comparison
equal deleted inserted replaced
-1:000000000000 0:2f7381ee5235
1 #!/usr/local/public/bin/Rscript --verbose
2 # version="1.1"
3
4 # date: 04-06-2013
5 # **Authors** Gildas Le Corguille ABiMS - UPMC/CNRS - Station Biologique de Roscoff - gildas.lecorguille|at|sb-roscoff.fr
6
7 # abims_hclust.r version 20130604
8
9 library(batch)
10 library(ctc)
11
12 hclust_metabolomics = function(file, method = "pearson", link = "ward", normalization=TRUE, keep.hclust=FALSE, sep=";", dec="."){
13
14 if (sep=="tabulation") sep="\t"
15 if (sep=="semicolon") sep=";"
16 if (sep=="comma") sep=","
17
18 # -- loading --
19 data=read.table(file, header = TRUE, row.names=1, sep = sep, quote="\"", dec = dec,
20 fill = TRUE, comment.char="",na.strings = "NA")
21
22 # -- Normalization: logratio --
23 if (normalization) {
24 #meandata = apply(data,1,mean, na.rm=T)
25 #data = log2(data/meandata)
26 data=t(scale(t(data)))
27 }
28
29 # -- hclust / output files for TreeView --
30 file="hclust.cdt"
31 hclust2treeview(data,file=file, method = method, link = link, keep.hclust= keep.hclust)
32
33 # -- output / return --
34 system("zip -r hclust.zip hclust.*", ignore.stdout = TRUE)
35 }
36
37 listArguments = parseCommandArgs(evaluate=FALSE)
38 do.call(hclust_metabolomics, listArguments)