comparison RScript.r @ 54:ef5ffc8a6e37 draft

Uploaded
author davidvanzessen
date Tue, 13 Oct 2015 09:13:24 -0400
parents 8ebe57feecd6
children 43ce3ebfc9b5
comparison
equal deleted inserted replaced
53:8ebe57feecd6 54:ef5ffc8a6e37
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 70 cat(paste("<table border='0'>", sep=""), file="multiple_matches.html", append=T)
71 patientCountOnColumn <- function(x, product, interval, on, appendtxt=F){ 71 patientCountOnColumn <- function(x, product, interval, on, appendtxt=F){
72 if (!is.data.frame(x) & is.list(x)){ 72 if (!is.data.frame(x) & is.list(x)){
73 x = x[[1]] 73 x = x[[1]]
74 } 74 }
75 #x$Sample = factor(x$Sample, levels=unique(x$Sample)) 75 #x$Sample = factor(x$Sample, levels=unique(x$Sample))
172 patient.fuzzy = patient.fuzzy[order(nchar(patient.fuzzy$Clone_Sequence)),] 172 patient.fuzzy = patient.fuzzy[order(nchar(patient.fuzzy$Clone_Sequence)),]
173 173
174 merge.list = list() 174 merge.list = list()
175 175
176 merge.list[["second"]] = vector() 176 merge.list[["second"]] = vector()
177
178 177
179 while(nrow(patient.fuzzy) > 1){ 178 while(nrow(patient.fuzzy) > 1){
180 first.merge = patient.fuzzy[1,"merge"] 179 first.merge = patient.fuzzy[1,"merge"]
181 first.clone.sequence = patient.fuzzy[1,"Clone_Sequence"] 180 first.clone.sequence = patient.fuzzy[1,"Clone_Sequence"]
182 first.sample = patient.fuzzy[1,"Sample"] 181 first.sample = patient.fuzzy[1,"Sample"]
232 second.rows.v = table(second.rows$V_Segment_Major_Gene) 231 second.rows.v = table(second.rows$V_Segment_Major_Gene)
233 second.rows.v = names(second.rows.v[which.max(second.rows.v)]) 232 second.rows.v = names(second.rows.v[which.max(second.rows.v)])
234 second.rows.j = table(second.rows$J_Segment_Major_Gene) 233 second.rows.j = table(second.rows$J_Segment_Major_Gene)
235 second.rows.j = names(second.rows.j[which.max(second.rows.j)]) 234 second.rows.j = names(second.rows.j[which.max(second.rows.j)])
236 235
237 second.sum = data.frame(merge = first.clone.sequence, 236 second.sum = data.frame(merge = paste(first.clone.sequence, "*", sep=""),
238 Patient = patient, 237 Patient = patient,
239 Receptor = second.rows[1,"Receptor"], 238 Receptor = second.rows[1,"Receptor"],
240 Sample = second.rows[1,"Sample"], 239 Sample = second.rows[1,"Sample"],
241 Cell_Count = second.rows[1,"Cell_Count"], 240 Cell_Count = second.rows[1,"Cell_Count"],
242 Clone_Molecule_Count_From_Spikes = sum(second.rows$Clone_Molecule_Count_From_Spikes), 241 Clone_Molecule_Count_From_Spikes = sum(second.rows$Clone_Molecule_Count_From_Spikes),
268 #merge.list[["second"]] = append(merge.list[["second"]], second.clone.sequence) 267 #merge.list[["second"]] = append(merge.list[["second"]], second.clone.sequence)
269 } 268 }
270 } 269 }
271 270
272 if(nrow(first.rows) > 1 | nrow(second.rows) > 1){ 271 if(nrow(first.rows) > 1 | nrow(second.rows) > 1){
273 272 cat(paste("<tr><td>", patient, ": ", nrow(first.rows), " ", nrow(second.rows), " ", first.clone.sequence, "</td></tr>", sep=""), file="multiple_matches.html", append=T)
274 } 273 }
275 274
276 } else { 275 } else {
277 patient.fuzzy = patient.fuzzy[-1,] 276 patient.fuzzy = patient.fuzzy[-1,]
278 } 277 }