annotate baseline/filter.r @ 7:ad9be244b104 draft

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