comparison new_imgt.r @ 31:fe44a905aee9 draft

Uploaded
author davidvanzessen
date Tue, 13 Dec 2016 10:06:49 -0500
parents c33d93683a09
children 6cd12c71c3d3
comparison
equal deleted inserted replaced
30:33a7c49d48a7 31:fe44a905aee9
2 2
3 imgt.dir = args[1] 3 imgt.dir = args[1]
4 merged.file = args[2] 4 merged.file = args[2]
5 gene = args[3] 5 gene = args[3]
6 6
7 merged = read.table(merged.file, header=T, sep="\t", fill=T, stringsAsFactors=F) 7 merged = read.table(merged.file, header=T, sep="\t", fill=T, stringsAsFactors=F, comment.char="")
8 8
9 if(gene != "-"){ 9 if(gene != "-"){
10 merged = merged[grepl(paste("^", gene, sep=""), merged$best_match),] 10 merged = merged[grepl(paste("^", gene, sep=""), merged$best_match),]
11 } else { 11 } else {
12 merged = merged[!grepl("unmatched", merged$best_match),] 12 merged = merged[!grepl("unmatched", merged$best_match),]
15 merged = merged[!grepl("unmatched", merged$best_match),] 15 merged = merged[!grepl("unmatched", merged$best_match),]
16 16
17 for(f in list.files(imgt.dir, pattern="*.txt$")){ 17 for(f in list.files(imgt.dir, pattern="*.txt$")){
18 #print(paste("filtering", f)) 18 #print(paste("filtering", f))
19 path = paste(imgt.dir, f, sep="") 19 path = paste(imgt.dir, f, sep="")
20 dat = read.table(path, header=T, sep="\t", fill=T, quote="", stringsAsFactors=F, check.names=FALSE) 20 dat = read.table(path, header=T, sep="\t", fill=T, quote="", stringsAsFactors=F, check.names=FALSE, comment.char="")
21 21
22 dat = dat[dat[,"Sequence ID"] %in% merged$Sequence.ID,] 22 dat = dat[dat[,"Sequence ID"] %in% merged$Sequence.ID,]
23 23
24 if(nrow(dat) > 0 & grepl("^8_", f)){ #change the FR1 columns to 0 in the "8_..." file 24 if(nrow(dat) > 0 & grepl("^8_", f)){ #change the FR1 columns to 0 in the "8_..." file
25 dat[,grepl("^FR1", names(dat))] = 0 25 dat[,grepl("^FR1", names(dat))] = 0