annotate experimental_design/experimental_design.r @ 40:106275b54470 draft

Uploaded
author davidvanzessen
date Tue, 30 May 2017 07:26:33 -0400
parents afe85eb6572e
children 124b7fd92a3e
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
40
106275b54470 Uploaded
davidvanzessen
parents: 0
diff changeset
18 if(nrow(dat) == 0){
106275b54470 Uploaded
davidvanzessen
parents: 0
diff changeset
19 print(paste(counter, "of", current.id, "has no sequences, skipping"))
106275b54470 Uploaded
davidvanzessen
parents: 0
diff changeset
20 next
106275b54470 Uploaded
davidvanzessen
parents: 0
diff changeset
21 }
106275b54470 Uploaded
davidvanzessen
parents: 0
diff changeset
22
0
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
23 #IMGT check
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
24
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
25 dat$Sample = current.id
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
26 dat$Replicate = counter
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
27
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
28 if(is.null(result)){
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
29 result = dat[NULL,]
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
30 }
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
31
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
32 result = rbind(result, dat)
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
33
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
34 counter = counter + 1
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
35
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
36 } else { #its an ID of a patient
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
37 print(paste("New patient", current))
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
38 current.id = current
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
39 counter = 1
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
40 }
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
41 }
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
42
afe85eb6572e Uploaded
davidvanzessen
parents:
diff changeset
43 write.table(result, output, sep="\t", quote=F, row.names=F, col.names=T)