annotate baseline/filter.r @ 0:8a5a2abbb870 draft default tip

Uploaded
author davidvanzessen
date Mon, 29 Aug 2016 05:36:10 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
1 arg = commandArgs(TRUE)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
2 summaryfile = arg[1]
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
3 gappedfile = arg[2]
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
4 selection = arg[3]
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
5 output = arg[4]
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
6 print(paste("selection = ", selection))
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
7
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
8
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
9 summarydat = read.table(summaryfile, header=T, sep="\t", fill=T, stringsAsFactors=F)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
10 gappeddat = read.table(gappedfile, header=T, sep="\t", fill=T, stringsAsFactors=F)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
11
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
12 #dat = data.frame(merge(gappeddat, summarydat, by="Sequence.ID", all.x=T))
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
13
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
14 dat = cbind(gappeddat, summarydat$AA.JUNCTION)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
15
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
16 colnames(dat)[length(dat)] = "AA.JUNCTION"
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
17
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
18 dat$VGene = gsub("^Homsap ", "", dat$V.GENE.and.allele)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
19 dat$VGene = gsub("[*].*", "", dat$VGene)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
20
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
21 dat$DGene = gsub("^Homsap ", "", dat$D.GENE.and.allele)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
22 dat$DGene = gsub("[*].*", "", dat$DGene)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
23
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
24 dat$JGene = gsub("^Homsap ", "", dat$J.GENE.and.allele)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
25 dat$JGene = gsub("[*].*", "", dat$JGene)
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
26
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
27 #print(str(dat))
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
28
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
29 dat$past = do.call(paste, c(dat[unlist(strsplit(selection, ","))], sep = ":"))
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
30
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
31 dat = dat[!duplicated(dat$past), ]
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
32
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
33 dat = dat[dat$Functionality != "No results" & dat$Functionality != "unproductive",]
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
34
8a5a2abbb870 Uploaded
davidvanzessen
parents:
diff changeset
35 write.table(x=dat, file=output, sep="\t",quote=F,row.names=F,col.names=T)