comparison merge.r @ 0:c33d93683a09 draft

Uploaded
author davidvanzessen
date Thu, 13 Oct 2016 10:52:24 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c33d93683a09
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)