0
|
1 args <- commandArgs(trailingOnly = TRUE)
|
|
2
|
|
3 input.1 = args[1]
|
|
4 input.2 = args[2]
|
|
5
|
|
6 fields.1 = args[3]
|
|
7 fields.2 = args[4]
|
|
8
|
|
9 field.1 = args[5]
|
|
10 field.2 = args[6]
|
|
11
|
|
12 output = args[7]
|
|
13
|
|
14 dat1 = read.table(input.1, header=T, sep="\t", quote="", stringsAsFactors=F, fill=T, row.names=NULL)
|
|
15 if(fields.1 != "all"){
|
|
16 fields.1 = unlist(strsplit(fields.1, ","))
|
|
17 dat1 = dat1[,fields.1]
|
|
18 }
|
|
19 dat2 = read.table(input.2, header=T, sep="\t", quote="", stringsAsFactors=F, fill=T, row.names=NULL)
|
|
20 if(fields.2 != "all"){
|
|
21 fields.2 = unlist(strsplit(fields.2, ","))
|
|
22 dat2 = dat2[,fields.2]
|
|
23 }
|
|
24
|
|
25 dat3 = merge(dat1, dat2, by.x=field.1, by.y=field.2)
|
|
26
|
|
27 write.table(dat3, output, sep="\t",quote=F,row.names=F,col.names=T)
|