Mercurial > repos > davidvanzessen > mutation_analysis
comparison sequence_overview.r @ 79:0513b46178c4 draft
Uploaded
| author | davidvanzessen |
|---|---|
| date | Thu, 12 May 2016 07:35:07 -0400 |
| parents | b523ce95d857 |
| children | a778156dad3d |
comparison
equal
deleted
inserted
replaced
| 78:b523ce95d857 | 79:0513b46178c4 |
|---|---|
| 19 IDs = dat[,c("Sequence.ID", "seq_conc", "best_match", "Functionality")] | 19 IDs = dat[,c("Sequence.ID", "seq_conc", "best_match", "Functionality")] |
| 20 IDs$best_match = as.character(IDs$best_match) | 20 IDs$best_match = as.character(IDs$best_match) |
| 21 | 21 |
| 22 #dat = data.frame(data.table(dat)[, list(freq=.N), by=c("best_match", "seq_conc")]) | 22 #dat = data.frame(data.table(dat)[, list(freq=.N), by=c("best_match", "seq_conc")]) |
| 23 | 23 |
| 24 dat = data.frame(table(dat$best_match, dat$seq_conc)) | 24 dat = data.frame(table(dat$best_match, dat$seq_conc, dat$Functionality)) |
| 25 | 25 |
| 26 dat = dat[dat$Freq > 1,] | 26 dat = dat[dat$Freq > 1,] |
| 27 | 27 |
| 28 names(dat) = c("best_match", "seq_conc", "Freq") | 28 names(dat) = c("best_match", "seq_conc", "Functionality", "Freq") |
| 29 | 29 |
| 30 dat$seq_conc = factor(dat$seq_conc) | 30 dat$seq_conc = factor(dat$seq_conc) |
| 31 | 31 |
| 32 dat = dat[order(nchar(as.character(dat$seq_conc))),] | 32 dat = dat[order(nchar(as.character(dat$seq_conc))),] |
| 33 | 33 |
| 37 make.link = function(id, clss, val) { paste("<a href='", clss, "_", id, ".html'>", val, "</a>", sep="") } | 37 make.link = function(id, clss, val) { paste("<a href='", clss, "_", id, ".html'>", val, "</a>", sep="") } |
| 38 tbl = function(df) { res = "<table border='1'>"; for(i in 1:nrow(df)){ res = paste(res, tr(df[i,]), sep=""); }; res = paste(res, "</table>"); } | 38 tbl = function(df) { res = "<table border='1'>"; for(i in 1:nrow(df)){ res = paste(res, tr(df[i,]), sep=""); }; res = paste(res, "</table>"); } |
| 39 | 39 |
| 40 cat("<table border='1'>", file=main.html, append=F) | 40 cat("<table border='1'>", file=main.html, append=F) |
| 41 cat("<caption>CDR1+CDR2+CDR3+FR2+FR3 sequences that show up more than once</caption>", file=main.html, append=T) | 41 cat("<caption>CDR1+CDR2+CDR3+FR2+FR3 sequences that show up more than once</caption>", file=main.html, append=T) |
| 42 cat("<tr><th>Sequence</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) | 42 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) |
| 43 | 43 |
| 44 for(i in 1:nrow(dat)){ | 44 for(i in 1:nrow(dat)){ |
| 45 ca1 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "ca1",] | 45 ca1 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "ca1",] |
| 46 ca2 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "ca2",] | 46 ca2 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "ca2",] |
| 47 | 47 |
| 51 cg4 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cg4",] | 51 cg4 = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cg4",] |
| 52 | 52 |
| 53 cm = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cm",] | 53 cm = IDs[IDs$seq_conc == dat[i,c("seq_conc")] & IDs$best_match == "cm",] |
| 54 | 54 |
| 55 id = as.numeric(dat[i,"seq_conc"]) | 55 id = as.numeric(dat[i,"seq_conc"]) |
| 56 | |
| 57 functionality = dat[i,"Functionality"] | |
| 56 | 58 |
| 57 if(nrow(ca1) > 0){ | 59 if(nrow(ca1) > 0){ |
| 58 cat(tbl(ca1), file=paste("ca1_", id, ".html", sep="")) | 60 cat(tbl(ca1), file=paste("ca1_", id, ".html", sep="")) |
| 59 } | 61 } |
| 60 | 62 |
| 90 cg3.html = make.link(id, "cg3", nrow(cg3)) | 92 cg3.html = make.link(id, "cg3", nrow(cg3)) |
| 91 cg4.html = make.link(id, "cg4", nrow(cg4)) | 93 cg4.html = make.link(id, "cg4", nrow(cg4)) |
| 92 | 94 |
| 93 cm.html = make.link(id, "cm", nrow(cm)) | 95 cm.html = make.link(id, "cm", nrow(cm)) |
| 94 | 96 |
| 95 rw = c(as.character(dat[i,"seq_conc"]), ca1.html, ca2.html, cg1.html, cg2.html, cg3.html, cg4.html, cm.html) | 97 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) |
| 96 | 98 |
| 97 cat(tr(rw), file=main.html, append=T) | 99 cat(tr(rw), file=main.html, append=T) |
| 98 } | 100 } |
| 99 | 101 |
| 100 cat("</table>", file=main.html, append=T) | 102 cat("</table>", file=main.html, append=T) |
