annotate merge.r @ 95:d63eff357515 draft

planemo upload commit d96a736dcd6da34137f79861fbc6369716c332f1
author rhpvorderman
date Mon, 27 Mar 2023 13:11:53 +0000
parents c33d93683a09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
1 args <- commandArgs(trailingOnly = TRUE)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
2
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
3 input.1 = args[1]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
4 input.2 = args[2]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
5
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
6 fields.1 = args[3]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
7 fields.2 = args[4]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
8
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
9 field.1 = args[5]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
10 field.2 = args[6]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
11
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
12 output = args[7]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
13
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
14 dat1 = read.table(input.1, header=T, sep="\t", quote="", stringsAsFactors=F, fill=T, row.names=NULL)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
15 if(fields.1 != "all"){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
16 fields.1 = unlist(strsplit(fields.1, ","))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
17 dat1 = dat1[,fields.1]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
18 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
19 dat2 = read.table(input.2, header=T, sep="\t", quote="", stringsAsFactors=F, fill=T, row.names=NULL)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
20 if(fields.2 != "all"){
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
21 fields.2 = unlist(strsplit(fields.2, ","))
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
22 dat2 = dat2[,fields.2]
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
23 }
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
24
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
25 dat3 = merge(dat1, dat2, by.x=field.1, by.y=field.2)
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
26
c33d93683a09 Uploaded
davidvanzessen
parents:
diff changeset
27 write.table(dat3, output, sep="\t",quote=F,row.names=F,col.names=T)