Mercurial > repos > davidvanzessen > argalaxy_tools
diff experimental_design/experimental_design.r @ 0:afe85eb6572e draft
Uploaded
author | davidvanzessen |
---|---|
date | Mon, 29 Aug 2016 05:41:20 -0400 |
parents | |
children | 106275b54470 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/experimental_design/experimental_design.r Mon Aug 29 05:41:20 2016 -0400 @@ -0,0 +1,38 @@ +args <- commandArgs(trailingOnly = TRUE) + +print(args) + +inputs = args[1:(length(args) - 1)] +output = args[length(args)] + +current.id = "" +counter = 1 + +result = NULL + +for(current in inputs){ + if(grepl("/", current)){ #its a path to a file + print(paste("Adding file", counter, "to", current.id)) + dat = read.table(current, sep="\t", header=T, quote="", fill=T) + + #IMGT check + + dat$Sample = current.id + dat$Replicate = counter + + if(is.null(result)){ + result = dat[NULL,] + } + + result = rbind(result, dat) + + counter = counter + 1 + + } else { #its an ID of a patient + print(paste("New patient", current)) + current.id = current + counter = 1 + } +} + +write.table(result, output, sep="\t", quote=F, row.names=F, col.names=T)