Mercurial > repos > davidvanzessen > argalaxy_tools
annotate experimental_design/experimental_design.r @ 56:7ae6b6b5d890 draft
"planemo upload commit 2d4cb6757e8eff095295550bbde6fd9e2ee0b73d"
author | rhpvorderman |
---|---|
date | Tue, 14 Dec 2021 12:45:47 +0000 |
parents | 81b3eb11ed2c |
children |
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) |