Mercurial > repos > davidvanzessen > mutation_analysis
comparison sequence_overview.r @ 91:5e237c243088 draft
Uploaded
author | davidvanzessen |
---|---|
date | Fri, 03 Jun 2016 10:35:52 -0400 |
parents | f0e8dac22c6e |
children | b869a126e2c4 |
comparison
equal
deleted
inserted
replaced
90:f0e8dac22c6e | 91:5e237c243088 |
---|---|
20 IDs = merged[,c("Sequence.ID", "seq_conc", "best_match", "Functionality")] | 20 IDs = merged[,c("Sequence.ID", "seq_conc", "best_match", "Functionality")] |
21 IDs$best_match = as.character(IDs$best_match) | 21 IDs$best_match = as.character(IDs$best_match) |
22 | 22 |
23 #dat = data.frame(data.table(dat)[, list(freq=.N), by=c("best_match", "seq_conc")]) | 23 #dat = data.frame(data.table(dat)[, list(freq=.N), by=c("best_match", "seq_conc")]) |
24 | 24 |
25 dat = data.frame(table(merged$seq_conc, merged$Functionality)) | 25 dat = data.frame(table(merged$seq_conc)) |
26 #dat = data.frame(table(merged$seq_conc, merged$Functionality)) | |
26 | 27 |
27 #dat = dat[dat$Freq > 1,] | 28 #dat = dat[dat$Freq > 1,] |
28 | 29 |
29 names(dat) = c("seq_conc", "Functionality", "Freq") | 30 #names(dat) = c("seq_conc", "Functionality", "Freq") |
31 names(dat) = c("seq_conc", "Freq") | |
30 | 32 |
31 dat$seq_conc = factor(dat$seq_conc) | 33 dat$seq_conc = factor(dat$seq_conc) |
32 | 34 |
33 dat = dat[order(as.character(dat$seq_conc)),] | 35 dat = dat[order(as.character(dat$seq_conc)),] |
34 | 36 |
41 cat("<table border='1'>", file=main.html, append=F) | 43 cat("<table border='1'>", file=main.html, append=F) |
42 cat("<caption>CDR1+FR2+CDR2+FR3+CDR3 sequences that show up more than once</caption>", file=main.html, append=T) | 44 cat("<caption>CDR1+FR2+CDR2+FR3+CDR3 sequences that show up more than once</caption>", file=main.html, append=T) |
43 cat("<tr><th>Sequence</th><th>Functionality</th><th>ca1</th><th>ca2</th><th>cg1</th><th>cg2</th><th>cg3</th><th>cg4</th><th>cm</th></tr>", file=main.html, append=T) | 45 cat("<tr><th>Sequence</th><th>Functionality</th><th>ca1</th><th>ca2</th><th>cg1</th><th>cg2</th><th>cg3</th><th>cg4</th><th>cm</th></tr>", file=main.html, append=T) |
44 | 46 |
45 for(i in 1:nrow(dat)){ | 47 for(i in 1:nrow(dat)){ |
46 ca1 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "ca1",] | 48 ca1 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & grepl("^ca1", IDs$best_match),] |
47 ca2 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "ca2",] | 49 ca2 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & grepl("^ca2", IDs$best_match),] |
48 | 50 |
49 cg1 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cg1",] | 51 cg1 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & grepl("^cg1", IDs$best_match),] |
50 cg2 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cg2",] | 52 cg2 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & grepl("^cg2", IDs$best_match),] |
51 cg3 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cg3",] | 53 cg3 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & grepl("^cg3", IDs$best_match),] |
52 cg4 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cg4",] | 54 cg4 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & grepl("^cg4", IDs$best_match),] |
53 | 55 |
54 cm = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cm",] | 56 cm = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & grepl("^cm", IDs$best_match),] |
57 allc = rbind(ca1, ca2, cg1, cg2, cg3, cg4, cm) | |
55 | 58 |
56 classes = c(nrow(ca1), nrow(ca2), nrow(cg1), nrow(cg2), nrow(cg3), nrow(cg4), nrow(cm)) | 59 classes = c(nrow(ca1), nrow(ca2), nrow(cg1), nrow(cg2), nrow(cg3), nrow(cg4), nrow(cm)) |
57 | 60 |
58 classes.sum = sum(classes) | 61 classes.sum = sum(classes) |
59 | 62 |
61 next | 64 next |
62 } | 65 } |
63 | 66 |
64 id = as.numeric(dat[i,"seq_conc"]) | 67 id = as.numeric(dat[i,"seq_conc"]) |
65 | 68 |
66 functionality = dat[i,"Functionality"] | 69 functionality = paste(unique(allc[,"Functionality"], sep=",")) |
67 | 70 |
68 if(nrow(ca1) > 0){ | 71 if(nrow(ca1) > 0){ |
69 cat(tbl(ca1), file=paste("ca1_", id, ".html", sep="")) | 72 cat(tbl(ca1), file=paste("ca1_", id, ".html", sep="")) |
70 } | 73 } |
71 | 74 |
102 cg4.html = make.link(id, "cg4", nrow(cg4)) | 105 cg4.html = make.link(id, "cg4", nrow(cg4)) |
103 | 106 |
104 cm.html = make.link(id, "cm", nrow(cm)) | 107 cm.html = make.link(id, "cm", nrow(cm)) |
105 | 108 |
106 rw = c(as.character(dat[i,"seq_conc"]), as.character(functionality), ca1.html, ca2.html, cg1.html, cg2.html, cg3.html, cg4.html, cm.html) | 109 rw = c(as.character(dat[i,"seq_conc"]), as.character(functionality), ca1.html, ca2.html, cg1.html, cg2.html, cg3.html, cg4.html, cm.html) |
110 #print(rw) | |
107 | 111 |
108 cat(tr(rw), file=main.html, append=T) | 112 cat(tr(rw), file=main.html, append=T) |
109 } | 113 } |
110 | 114 |
111 cat("</table>", file=main.html, append=T) | 115 cat("</table>", file=main.html, append=T) |
130 #NToverview = rbind(NToverview, NTsum) | 134 #NToverview = rbind(NToverview, NTsum) |
131 | 135 |
132 NTresult = data.frame(nt=c("A", "C", "T", "G")) | 136 NTresult = data.frame(nt=c("A", "C", "T", "G")) |
133 | 137 |
134 for(clazz in gene.classes){ | 138 for(clazz in gene.classes){ |
135 NToverview.sub = NToverview[grepl(clazz, paste("^", NToverview$best_match, sep="")),] | 139 NToverview.sub = NToverview[grepl(paste("^", clazz, sep=""), NToverview$best_match),] |
136 new.col.x = c(sum(NToverview.sub$A), sum(NToverview.sub$C), sum(NToverview.sub$T), sum(NToverview.sub$G)) | 140 new.col.x = c(sum(NToverview.sub$A), sum(NToverview.sub$C), sum(NToverview.sub$T), sum(NToverview.sub$G)) |
137 new.col.y = sum(new.col.x) | 141 new.col.y = sum(new.col.x) |
138 new.col.z = round(new.col.x / new.col.y * 100, 2) | 142 new.col.z = round(new.col.x / new.col.y * 100, 2) |
139 | 143 |
140 tmp = names(NTresult) | 144 tmp = names(NTresult) |
156 | 160 |
157 print(hotspot.analysis.sum) | 161 print(hotspot.analysis.sum) |
158 | 162 |
159 write.table(hotspot.analysis.sum, hotspot.analysis.sum.file, quote=F, sep=",", row.names=F, col.names=F, na="0") | 163 write.table(hotspot.analysis.sum, hotspot.analysis.sum.file, quote=F, sep=",", row.names=F, col.names=F, na="0") |
160 | 164 |
161 | 165 write.table(NToverview[,c("Sequence.ID", "best_match", "seq", "A", "C", "G", "T")], NToverview.file, quote=F, sep="\t", row.names=F, col.names=T) |
162 write.table(NToverview, NToverview.file, quote=F, sep="\t", row.names=F, col.names=T) | |
163 | 166 |
164 | 167 |
165 | 168 |
166 | 169 |
167 | 170 |