annotate experimental_design/experimental_design.r @ 54:81b3eb11ed2c draft

"planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
author rhpvorderman
date Tue, 16 Nov 2021 15:42:32 +0000
parents 124b7fd92a3e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
54
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
1 args <- commandArgs(trailingOnly = TRUE)
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
2
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
3 print(args)
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
4
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
5 inputs = args[1:(length(args) - 1)]
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
6 output = args[length(args)]
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
7
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
8 current.id = ""
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
9 counter = 1
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
10
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
11 result = NULL
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
12
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
13 for(current in inputs){
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
14 if(grepl("/", current)){ #its a path to a file
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
15 print(paste("Adding file", counter, "to", current.id))
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
16 dat = read.table(current, sep="\t", header=T, quote="", fill=T)
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
17
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
18 if(nrow(dat) == 0){
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
19 print(paste(counter, "of", current.id, "has no sequences, skipping"))
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
20 next
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
21 }
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
22
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
23 #IMGT check
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
24
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
25 dat$Sample = current.id
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
26 dat$Replicate = counter
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
27
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
28 if(is.null(result)){
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
29 result = dat[NULL,]
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
30 }
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
31
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
32 result = rbind(result, dat)
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
33
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
34 counter = counter + 1
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
35
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
36 } else { #its an ID of a patient
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
37 print(paste("New patient", current))
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
38 current.id = current
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
39 counter = 1
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
40 }
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
41 }
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
42
81b3eb11ed2c "planemo upload commit 6c0195cc4de6a34e2c46d875be4fc2157a21cdf6"
rhpvorderman
parents: 52
diff changeset
43 write.table(result, output, sep="\t", quote=F, row.names=F, col.names=T)