comparison RScript.r @ 56:c89d9e89423b draft

Uploaded
author davidvanzessen
date Wed, 14 Oct 2015 10:18:30 -0400
parents 43ce3ebfc9b5
children 3ed7878f75c3
comparison
equal deleted inserted replaced
55:43ce3ebfc9b5 56:c89d9e89423b
65 65
66 single_patients = data.frame("Patient" = character(0),"Sample" = character(0), "on" = character(0), "Clone_Sequence" = character(0), "Frequency" = numeric(0), "normalized_read_count" = numeric(0), "V_Segment_Major_Gene" = character(0), "J_Segment_Major_Gene" = character(0), "Rearrangement" = character(0)) 66 single_patients = data.frame("Patient" = character(0),"Sample" = character(0), "on" = character(0), "Clone_Sequence" = character(0), "Frequency" = numeric(0), "normalized_read_count" = numeric(0), "V_Segment_Major_Gene" = character(0), "J_Segment_Major_Gene" = character(0), "Rearrangement" = character(0))
67 67
68 patient.merge.list = list() #cache the 'both' table, 2x speedup for more memory... 68 patient.merge.list = list() #cache the 'both' table, 2x speedup for more memory...
69 patient.merge.list.second = list() 69 patient.merge.list.second = list()
70 cat(paste("<table border='0'>", sep=""), file="multiple_matches.html", append=T) 70 cat(paste("<table border='0' style='font-family:courier;'>", sep=""), file="multiple_matches.html", append=T)
71 cat(paste("<table border='0' style='font-family:courier;'>", sep=""), file="single_matches.html", append=T)
71 patientCountOnColumn <- function(x, product, interval, on, appendtxt=F){ 72 patientCountOnColumn <- function(x, product, interval, on, appendtxt=F){
72 if (!is.data.frame(x) & is.list(x)){ 73 if (!is.data.frame(x) & is.list(x)){
73 x = x[[1]] 74 x = x[[1]]
74 } 75 }
75 #x$Sample = factor(x$Sample, levels=unique(x$Sample)) 76 #x$Sample = factor(x$Sample, levels=unique(x$Sample))
259 patient.fuzzy = patient.fuzzy[!(first.match.filter | second.match.filter),] 260 patient.fuzzy = patient.fuzzy[!(first.match.filter | second.match.filter),]
260 261
261 hidden.clone.sequences = c(first.rows[-1,"Clone_Sequence"], second.rows[second.rows$Clone_Sequence != first.clone.sequence,"Clone_Sequence"]) 262 hidden.clone.sequences = c(first.rows[-1,"Clone_Sequence"], second.rows[second.rows$Clone_Sequence != first.clone.sequence,"Clone_Sequence"])
262 merge.list[["second"]] = append(merge.list[["second"]], hidden.clone.sequences) 263 merge.list[["second"]] = append(merge.list[["second"]], hidden.clone.sequences)
263 264
264 if(sum(first.match.filter) == 1 & sum(second.match.filter) == 1){ 265 tmp.rows = rbind(first.rows, second.rows)
265 second.clone.sequence = patient.fuzzy[second.match.filter, "Clone_Sequence"] 266 tmp.rows = tmp.rows[order(nchar(tmp.rows$Clone_Sequence)),]
266 if(first.clone.sequence != second.clone.sequence){ 267
267 #merge.list[["second"]] = append(merge.list[["second"]], second.clone.sequence) 268 if (nrow(first.rows) > 1 | nrow(second.rows) > 1) {
269 cat(paste("<tr><td>", patient, " row ", 1:nrow(tmp.rows), "</td><td>", tmp.rows$Sample, ":</td><td>", tmp.rows$Clone_Sequence, "</td><td>", tmp.rows$normalized_read_count, "</td></tr>", sep=""), file="multiple_matches.html", append=T)
270 } else {
271 second.clone.sequence = second.rows[1,"Clone_Sequence"]
272 if(nchar(first.clone.sequence) != nchar(second.clone.sequence)){
273 cat(paste("<tr bgcolor='#DDD'><td>", patient, " row ", 1:nrow(tmp.rows), "</td><td>", tmp.rows$Sample, ":</td><td>", tmp.rows$Clone_Sequence, "</td><td>", tmp.rows$normalized_read_count, "</td></tr>", sep=""), file="single_matches.html", append=T)
274 } else {
275 cat(paste("<tr><td>", patient, " row ", 1:nrow(tmp.rows), "</td><td>", tmp.rows$Sample, ":</td><td>", tmp.rows$Clone_Sequence, "</td><td>", tmp.rows$normalized_read_count, "</td></tr>", sep=""), file="single_matches.html", append=T)
268 } 276 }
269 }
270
271 if(nrow(first.rows) > 1 | nrow(second.rows) > 1){
272 cat(paste("<tr><td>", patient, ": ", nrow(first.rows), " ", nrow(second.rows), " ", first.clone.sequence, "</td></tr>", sep=""), file="multiple_matches.html", append=T)
273 } 277 }
274 278
275 } else { 279 } else {
276 patient.fuzzy = patient.fuzzy[-1,] 280 patient.fuzzy = patient.fuzzy[-1,]
277 } 281 }