Mercurial > repos > davidvanzessen > mutation_analysis
comparison imgt_loader.r @ 50:8ba6afa1247a draft
Uploaded
author | davidvanzessen |
---|---|
date | Thu, 28 Jan 2016 09:21:25 -0500 |
parents | |
children | d4e72eeea640 |
comparison
equal
deleted
inserted
replaced
49:5c6b9e99d576 | 50:8ba6afa1247a |
---|---|
1 args <- commandArgs(trailingOnly = TRUE) | |
2 | |
3 summ.file = args[1] | |
4 aa.file = args[2] | |
5 junction.file = args[3] | |
6 out.file = args[4] | |
7 | |
8 summ = read.table(summ.file, sep="\t", header=T, quote="", fill=T) | |
9 aa = read.table(aa.file, sep="\t", header=T, quote="", fill=T) | |
10 junction = read.table(junction.file, sep="\t", header=T, quote="", fill=T) | |
11 | |
12 old_summary_columns=c('Sequence.ID','JUNCTION.frame','V.GENE.and.allele','D.GENE.and.allele','J.GENE.and.allele','CDR1.IMGT.length','CDR2.IMGT.length','CDR3.IMGT.length','Orientation') | |
13 old_sequence_columns=c('CDR1.IMGT','CDR2.IMGT','CDR3.IMGT') | |
14 old_junction_columns=c('JUNCTION') | |
15 | |
16 added_summary_columns=c('Functionality','V.REGION.identity..','V.REGION.identity.nt','D.REGION.reading.frame','AA.JUNCTION','Functionality.comment','Sequence') | |
17 added_sequence_columns=c('FR1.IMGT','FR2.IMGT','FR3.IMGT','CDR3.IMGT','JUNCTION','J.REGION','FR4.IMGT') | |
18 added_junction_columns=c("P3.V.nt.nb",'N.REGION.nt.nb','N1.REGION.nt.nb',"P5.D.nt.nb","P3.D.nt.nb",'N2.REGION.nt.nb',"P5.J.nt.nb","X3.V.REGION.trimmed.nt.nb","X5.D.REGION.trimmed.nt.nb","X3.D.REGION.trimmed.nt.nb","X5.J.REGION.trimmed.nt.nb","N.REGION","N1.REGION","N2.REGION") | |
19 | |
20 out=summ[,c("Sequence.ID","JUNCTION.frame","V.GENE.and.allele","D.GENE.and.allele","J.GENE.and.allele")] | |
21 | |
22 out[,"CDR1.Seq"] = aa[,"CDR1.IMGT"] | |
23 out[,"CDR1.Length"] = summ[,"CDR1.IMGT.length"] | |
24 | |
25 out[,"CDR2.Seq"] = aa[,"CDR2.IMGT"] | |
26 out[,"CDR2.Length"] = summ[,"CDR2.IMGT.length"] | |
27 | |
28 out[,"CDR3.Seq"] = aa[,"CDR3.IMGT"] | |
29 out[,"CDR3.Length"] = summ[,"CDR3.IMGT.length"] | |
30 | |
31 out[,"CDR3.Seq.DNA"] = junction[,"JUNCTION"] | |
32 out[,"CDR3.Length.DNA"] = nchar(as.character(junction[,"JUNCTION"])) | |
33 out[,"Strand"] = summ[,"Orientation"] | |
34 out[,"CDR3.Found.How"] = "a" | |
35 | |
36 out[,added_summary_columns] = summ[,added_summary_columns] | |
37 | |
38 out[,added_sequence_columns] = aa[,added_sequence_columns] | |
39 | |
40 out[,added_junction_columns] = junction[,added_junction_columns] | |
41 | |
42 out[,"Top V Gene"] = gsub(".* ", "", gsub("\\*.*", "", summ[,"V.GENE.and.allele"])) | |
43 out[,"Top D Gene"] = gsub(".* ", "", gsub("\\*.*", "", summ[,"D.GENE.and.allele"])) | |
44 out[,"Top J Gene"] = gsub(".* ", "", gsub("\\*.*", "", summ[,"J.GENE.and.allele"])) | |
45 | |
46 out = out[,c('Sequence.ID','JUNCTION.frame','Top V Gene','Top D Gene','Top J Gene','CDR1.Seq','CDR1.Length','CDR2.Seq','CDR2.Length','CDR3.Seq','CDR3.Length','CDR3.Seq.DNA','CDR3.Length.DNA','Strand','CDR3.Found.How','Functionality','V.REGION.identity..','V.REGION.identity.nt','D.REGION.reading.frame','AA.JUNCTION','Functionality.comment','Sequence','FR1.IMGT','FR2.IMGT','FR3.IMGT','CDR3.IMGT','JUNCTION','J.REGION','FR4.IMGT','P3.V.nt.nb','N.REGION.nt.nb','N1.REGION.nt.nb','P5.D.nt.nb','P3.D.nt.nb','N2.REGION.nt.nb','P5.J.nt.nb','X3.V.REGION.trimmed.nt.nb','X5.D.REGION.trimmed.nt.nb','X3.D.REGION.trimmed.nt.nb','X5.J.REGION.trimmed.nt.nb','N.REGION','N1.REGION','N2.REGION')] | |
47 | |
48 names(out) = c('ID','VDJ Frame','Top V Gene','Top D Gene','Top J Gene','CDR1 Seq','CDR1 Length','CDR2 Seq','CDR2 Length','CDR3 Seq','CDR3 Length','CDR3 Seq DNA','CDR3 Length DNA','Strand','CDR3 Found How','Functionality','V-REGION identity %','V-REGION identity nt','D-REGION reading frame','AA JUNCTION','Functionality comment','Sequence','FR1-IMGT','FR2-IMGT','FR3-IMGT','CDR3-IMGT','JUNCTION','J-REGION','FR4-IMGT','P3V-nt nb','N-REGION-nt nb','N1-REGION-nt nb','P5D-nt nb','P3D-nt nb','N2-REGION-nt nb','P5J-nt nb','3V-REGION trimmed-nt nb','5D-REGION trimmed-nt nb','3D-REGION trimmed-nt nb','5J-REGION trimmed-nt nb','N-REGION','N1-REGION','N2-REGION') | |
49 | |
50 out[,"VDJ Frame"] = as.character(out[,"VDJ Frame"]) | |
51 | |
52 fltr = out[,"VDJ Frame"] == "in-frame" | |
53 if(any(fltr)){ | |
54 out[fltr, "VDJ Frame"] = "In-frame" | |
55 } | |
56 | |
57 fltr = out[,"VDJ Frame"] == "null" | |
58 if(any(fltr)){ | |
59 out[fltr, "VDJ Frame"] = "Out-of-frame" | |
60 } | |
61 | |
62 fltr = out[,"VDJ Frame"] == "out-of-frame" | |
63 if(any(fltr)){ | |
64 out[fltr, "VDJ Frame"] = "Out-of-frame" | |
65 } | |
66 | |
67 fltr = out[,"VDJ Frame"] == "" | |
68 if(any(fltr)){ | |
69 out[fltr, "VDJ Frame"] = "Out-of-frame" | |
70 } | |
71 | |
72 for(col in c('Top V Gene','Top D Gene','Top J Gene')){ | |
73 out[,col] = as.character(out[,col]) | |
74 fltr = out[,col] == "" | |
75 if(any(fltr)){ | |
76 out[fltr,col] = "NA" | |
77 } | |
78 } | |
79 | |
80 write.table(out, out.file, sep="\t", quote=F, row.names=F, col.names=T) |