Mercurial > repos > lecorguille > hca
diff abims_hclustering.r @ 0:2f7381ee5235 draft
Uploaded
author | lecorguille |
---|---|
date | Tue, 30 Jun 2015 06:36:09 -0400 |
parents | |
children | 36fc0a87d7fb |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/abims_hclustering.r Tue Jun 30 06:36:09 2015 -0400 @@ -0,0 +1,38 @@ +#!/usr/local/public/bin/Rscript --verbose +# version="1.1" + +# date: 04-06-2013 +# **Authors** Gildas Le Corguille ABiMS - UPMC/CNRS - Station Biologique de Roscoff - gildas.lecorguille|at|sb-roscoff.fr + +# abims_hclust.r version 20130604 + +library(batch) +library(ctc) + +hclust_metabolomics = function(file, method = "pearson", link = "ward", normalization=TRUE, keep.hclust=FALSE, sep=";", dec="."){ + + if (sep=="tabulation") sep="\t" + if (sep=="semicolon") sep=";" + if (sep=="comma") sep="," + + # -- loading -- + data=read.table(file, header = TRUE, row.names=1, sep = sep, quote="\"", dec = dec, + fill = TRUE, comment.char="",na.strings = "NA") + + # -- Normalization: logratio -- + if (normalization) { + #meandata = apply(data,1,mean, na.rm=T) + #data = log2(data/meandata) + data=t(scale(t(data))) + } + + # -- hclust / output files for TreeView -- + file="hclust.cdt" + hclust2treeview(data,file=file, method = method, link = link, keep.hclust= keep.hclust) + + # -- output / return -- + system("zip -r hclust.zip hclust.*", ignore.stdout = TRUE) +} + +listArguments = parseCommandArgs(evaluate=FALSE) +do.call(hclust_metabolomics, listArguments)