comparison naive_output.r @ 0:8a5a2abbb870 draft default tip

Uploaded
author davidvanzessen
date Mon, 29 Aug 2016 05:36:10 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8a5a2abbb870
1 args <- commandArgs(trailingOnly = TRUE)
2
3 naive.file = args[1]
4 shm.file = args[2]
5 output.file.ca = args[3]
6 output.file.cg = args[4]
7 output.file.cm = args[5]
8
9 naive = read.table(naive.file, sep="\t", header=T, quote="", fill=T)
10 shm.merge = read.table(shm.file, sep="\t", header=T, quote="", fill=T)
11
12
13 final = merge(naive, shm.merge[,c("Sequence.ID", "best_match")], by.x="ID", by.y="Sequence.ID")
14 print(paste("nrow final:", nrow(final)))
15 names(final)[names(final) == "best_match"] = "Sample"
16 final.numeric = final[,sapply(final, is.numeric)]
17 final.numeric[is.na(final.numeric)] = 0
18 final[,sapply(final, is.numeric)] = final.numeric
19
20 final.ca = final[grepl("^ca", final$Sample),]
21 final.cg = final[grepl("^cg", final$Sample),]
22 final.cm = final[grepl("^cm", final$Sample),]
23
24 if(nrow(final.ca) > 0){
25 final.ca$Replicate = 1
26 }
27
28 if(nrow(final.cg) > 0){
29 final.cg$Replicate = 1
30 }
31
32 if(nrow(final.cm) > 0){
33 final.cm$Replicate = 1
34 }
35
36 #print(paste("nrow final:", nrow(final)))
37 #final2 = final
38 #final2$Sample = gsub("[0-9]", "", final2$Sample)
39 #final = rbind(final, final2)
40 #final$Replicate = 1
41
42 write.table(final.ca, output.file.ca, quote=F, sep="\t", row.names=F, col.names=T)
43 write.table(final.cg, output.file.cg, quote=F, sep="\t", row.names=F, col.names=T)
44 write.table(final.cm, output.file.cm, quote=F, sep="\t", row.names=F, col.names=T)
45