annotate experimental_design/experimental_design.r @ 31:3a76faa53c59 draft

Uploaded
author davidvanzessen
date Tue, 14 Mar 2017 06:51:38 -0400
parents afe85eb6572e
children 106275b54470
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
1 args <- commandArgs(trailingOnly = TRUE)
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
2
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
3 print(args)
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
4
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
5 inputs = args[1:(length(args) - 1)]
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
6 output = args[length(args)]
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
7
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
8 current.id = ""
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
9 counter = 1
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
10
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
11 result = NULL
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
12
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
13 for(current in inputs){
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
14 if(grepl("/", current)){ #its a path to a file
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
15 print(paste("Adding file", counter, "to", current.id))
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
16 dat = read.table(current, sep="\t", header=T, quote="", fill=T)
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
17
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
18 #IMGT check
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
19
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
20 dat$Sample = current.id
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
21 dat$Replicate = counter
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
22
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
23 if(is.null(result)){
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
24 result = dat[NULL,]
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
25 }
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
26
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
27 result = rbind(result, dat)
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
28
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
29 counter = counter + 1
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
30
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
31 } else { #its an ID of a patient
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
32 print(paste("New patient", current))
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
33 current.id = current
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
34 counter = 1
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
35 }
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
36 }
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
37
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
38 write.table(result, output, sep="\t", quote=F, row.names=F, col.names=T)