comparison RScript.r @ 27:dd8518ea23dd draft

Uploaded
author davidvanzessen
date Wed, 25 Feb 2015 09:18:14 -0500
parents f35c127b29b1
children a63ccc36f5a4
comparison
equal deleted inserted replaced
26:f35c127b29b1 27:dd8518ea23dd
266 patientMerge23$thresholdValue = pmax(patientMerge23[,onx], patientMerge23[,ony]) 266 patientMerge23$thresholdValue = pmax(patientMerge23[,onx], patientMerge23[,ony])
267 267
268 scatterplot_data_columns = c("Clone_Sequence", "Frequency", "normalized_read_count", "V_Segment_Major_Gene", "J_Segment_Major_Gene") 268 scatterplot_data_columns = c("Clone_Sequence", "Frequency", "normalized_read_count", "V_Segment_Major_Gene", "J_Segment_Major_Gene")
269 scatterplot_data = rbind(patient1[,scatterplot_data_columns], patient2[,scatterplot_data_columns], patient3[,scatterplot_data_columns]) 269 scatterplot_data = rbind(patient1[,scatterplot_data_columns], patient2[,scatterplot_data_columns], patient3[,scatterplot_data_columns])
270 scatterplot_data = scatterplot_data[!duplicated(scatterplot_data$Clone_Sequence),] 270 scatterplot_data = scatterplot_data[!duplicated(scatterplot_data$Clone_Sequence),]
271 scatterplot_data$type = factor(x="single", levels=c("In one", "In two", "In three")) 271 scatterplot_data$type = factor(x="In one", levels=c("In one", "In two", "In three", "In multiple"))
272 272
273 res1 = vector() 273 res1 = vector()
274 res2 = vector() 274 res2 = vector()
275 res3 = vector() 275 res3 = vector()
276 res12 = vector() 276 res12 = vector()
347 filenameTwo_three = paste(label2, "_", label3, "_", product[iter, titleIndex], "_", threshhold, onShort, sep="") 347 filenameTwo_three = paste(label2, "_", label3, "_", product[iter, titleIndex], "_", threshhold, onShort, sep="")
348 write.table(dfTwo_three, file=paste(filenameTwo_three, ".txt", sep=""), quote=F, sep="\t", dec=",", row.names=F, col.names=T) 348 write.table(dfTwo_three, file=paste(filenameTwo_three, ".txt", sep=""), quote=F, sep="\t", dec=",", row.names=F, col.names=T)
349 } 349 }
350 } else { #scatterplot data 350 } else { #scatterplot data
351 scatterplot_locus_data = scatterplot_data[grepl(V_Segment, scatterplot_data$V_Segment_Major_Gene) & grepl(J_Segment, scatterplot_data$J_Segment_Major_Gene),] 351 scatterplot_locus_data = scatterplot_data[grepl(V_Segment, scatterplot_data$V_Segment_Major_Gene) & grepl(J_Segment, scatterplot_data$J_Segment_Major_Gene),]
352 scatterplot_locus_data$type = ifelse((scatterplot_locus_data$Clone_Sequence %in% patientMerge12[one_two,]$Clone_Sequence.x) | (scatterplot_locus_data$Clone_Sequence %in% patientMerge13[one_three,]$Clone_Sequence.x) | (scatterplot_locus_data$Clone_Sequence %in% patientMerge23[two_three,]$Clone_Sequence.x), "In two", "In one") 352 in_two = (scatterplot_locus_data$Clone_Sequence %in% patientMerge12[one_two,]$Clone_Sequence.x) | (scatterplot_locus_data$Clone_Sequence %in% patientMerge13[one_three,]$Clone_Sequence.x) | (scatterplot_locus_data$Clone_Sequence %in% patientMerge23[two_three,]$Clone_Sequence.x)
353 #scatterplot_locus_data$type = ifelse(scatterplot_locus_data$type == "In two", ifelse(scatterplot_locus_data$Clone_Sequence %in% patientMerge[all,]$Clone_Sequence.x, "In three", "In two"), "In one") 353 if(sum(in_two) > 0){
354 scatterplot_locus_data[(scatterplot_locus_data$Clone_Sequence %in% patientMerge[all,]$Clone_Sequence.x),]$type = "In three" 354 scatterplot_locus_data[in_two,]$type = "In two"
355 scatterplot_locus_data$type = ifelse(scatterplot_locus_data$type == "In one", "In one", "In multiple") 355 }
356 356 in_three = (scatterplot_locus_data$Clone_Sequence %in% patientMerge[all,]$Clone_Sequence.x)
357 if(sum(in_three)> 0){
358 scatterplot_locus_data[in_three,]$type = "In three"
359 }
360 not_in_one = scatterplot_locus_data$type != "In one"
361 print(not_in_one)
362 if(sum(not_in_one) > 0){
363 scatterplot_locus_data[not_in_one,]$type = "In multiple"
364 }
357 p = NULL 365 p = NULL
358 if(nrow(scatterplot_locus_data) != 0){ 366 if(nrow(scatterplot_locus_data) != 0){
359 if(on == "normalized_read_count"){ 367 if(on == "normalized_read_count"){
360 scales = 10^(0:ceiling(log10(max(scatterplot_locus_data$normalized_read_count)))) 368 scales = 10^(0:ceiling(log10(max(scatterplot_locus_data$normalized_read_count))))
361 p = ggplot(scatterplot_locus_data, aes(type, normalized_read_count)) + scale_y_log10(breaks=scales,labels=scales) 369 p = ggplot(scatterplot_locus_data, aes(type, normalized_read_count)) + scale_y_log10(breaks=scales,labels=scales)