Mercurial > repos > davidvanzessen > clonal_sequences_in_paired_samples
comparison RScript.r @ 69:c532b3f8dc97 draft
Uploaded
| author | davidvanzessen |
|---|---|
| date | Wed, 06 Jan 2016 11:00:00 -0500 |
| parents | ef13f0a3f4d6 |
| children | 9643b1fd9c45 |
comparison
equal
deleted
inserted
replaced
| 68:ef13f0a3f4d6 | 69:c532b3f8dc97 |
|---|---|
| 339 } | 339 } |
| 340 link.count = link.count + 1 | 340 link.count = link.count + 1 |
| 341 } | 341 } |
| 342 patient.merge.list[[patient]] <<- patientMerge | 342 patient.merge.list[[patient]] <<- patientMerge |
| 343 patient.merge.list.second[[patient]] <<- merge.list[["second"]] | 343 patient.merge.list.second[[patient]] <<- merge.list[["second"]] |
| 344 | |
| 345 sample.order = data.frame(type = c(oneSample, twoSample, paste(c(oneSample, twoSample), "In Both")),type.order = 1:4) | |
| 346 scatterplot_data = merge(scatterplot_data, sample.order, by="type") | |
| 347 | |
| 344 scatter_locus_data_list[[patient]] <<- scatterplot_data | 348 scatter_locus_data_list[[patient]] <<- scatterplot_data |
| 345 cat(paste("<td>", nrow(patient1), " in ", oneSample, " and ", nrow(patient2), " in ", twoSample, ", ", nrow(patientMerge), " in both (finding both took ", (proc.time() - start.time)[[3]], "s)</td></tr>", sep=""), file=logfile, append=T) | 349 cat(paste("<td>", nrow(patient1), " in ", oneSample, " and ", nrow(patient2), " in ", twoSample, ", ", nrow(patientMerge), " in both (finding both took ", (proc.time() - start.time)[[3]], "s)</td></tr>", sep=""), file=logfile, append=T) |
| 346 } | 350 } |
| 347 | 351 |
| 348 patient1 = patient1[!(patient1$Clone_Sequence %in% patient.merge.list.second[[patient]]),] | 352 patient1 = patient1[!(patient1$Clone_Sequence %in% patient.merge.list.second[[patient]]),] |
| 389 filenameTwo = paste(twoSample, "_", product[iter, titleIndex], "_", threshhold, sep="") | 393 filenameTwo = paste(twoSample, "_", product[iter, titleIndex], "_", threshhold, sep="") |
| 390 write.table(dfTwo, file=paste(filenameTwo, ".txt", sep=""), quote=F, sep="\t", dec=",", row.names=F, col.names=T) | 394 write.table(dfTwo, file=paste(filenameTwo, ".txt", sep=""), quote=F, sep="\t", dec=",", row.names=F, col.names=T) |
| 391 } | 395 } |
| 392 } else { | 396 } else { |
| 393 scatterplot_locus_data = scatterplot_data[grepl(V_Segment, scatterplot_data$V_Segment_Major_Gene) & grepl(J_Segment, scatterplot_data$J_Segment_Major_Gene),] | 397 scatterplot_locus_data = scatterplot_data[grepl(V_Segment, scatterplot_data$V_Segment_Major_Gene) & grepl(J_Segment, scatterplot_data$J_Segment_Major_Gene),] |
| 394 #scatterplot_locus_data = scatterplot_locus_data[!(scatterplot_locus_data$merge %in% merge.list[[twoSample]]),] | |
| 395 #scatterplot_locus_data = scatterplot_locus_data[!(scatterplot_locus_data$merge %in% merge.list[["second"]]),] | |
| 396 if(nrow(scatterplot_locus_data) > 0){ | 398 if(nrow(scatterplot_locus_data) > 0){ |
| 397 scatterplot_locus_data$Rearrangement = product[iter, titleIndex] | 399 scatterplot_locus_data$Rearrangement = product[iter, titleIndex] |
| 398 } | 400 } |
| 399 | 401 |
| 400 | 402 |
| 401 | 403 |
| 402 #in_one = (scatterplot_locus_data$merge %in% patient1$merge) | |
| 403 #in_two = (scatterplot_locus_data$merge %in% patient2$merge) | |
| 404 #if(any(in_two)){ | |
| 405 # scatterplot_locus_data[in_two,]$type = twoSample | |
| 406 #} | |
| 407 #in_both = (scatterplot_locus_data$merge %in% patientMerge$merge) | |
| 408 ##merge.list.filter = (scatterplot_locus_data$merge %in% merge.list[[oneSample]]) | |
| 409 ##exact.matches.filter = (scatterplot_locus_data$merge %in% cs.exact.matches) | |
| 410 #if(any(in_both)){ | |
| 411 # scatterplot_locus_data[in_both,]$type = "In Both" | |
| 412 #} | |
| 413 #if(type == "single" & (nrow(scatterplot_locus_data) > 0 | !any(scatterplot_locus_data$Patient %in% single_patients$Patient))){ | |
| 414 # single_patients <<- rbind(single_patients, scatterplot_locus_data) | |
| 415 #} | |
| 416 | |
| 417 | |
| 418 p = NULL | 404 p = NULL |
| 419 print(paste("nrow scatterplot_locus_data", nrow(scatterplot_locus_data))) | 405 print(paste("nrow scatterplot_locus_data", nrow(scatterplot_locus_data))) |
| 420 if(nrow(scatterplot_locus_data) != 0){ | 406 if(nrow(scatterplot_locus_data) != 0){ |
| 421 if(on == "normalized_read_count"){ | 407 if(on == "normalized_read_count"){ |
| 422 scales = 10^(0:6) #(0:ceiling(log10(max(scatterplot_locus_data$normalized_read_count)))) | 408 scales = 10^(0:6) #(0:ceiling(log10(max(scatterplot_locus_data$normalized_read_count)))) |
| 423 #p = ggplot(scatterplot_locus_data, aes(type, normalized_read_count)) + scale_y_log10(breaks=scales,labels=scales) + expand_limits(y=10^6) + scale_x_discrete(breaks=levels(scatterplot_data$type), labels=levels(scatterplot_data$type), drop=FALSE) | 409 p = ggplot(scatterplot_locus_data, aes(factor(reorder(type, type.order)), normalized_read_count, group=link)) + geom_line() + scale_y_log10(breaks=scales,labels=scales) + expand_limits(y=c(0,10^6)) + scale_x_discrete(breaks=levels(scatterplot_data$type), labels=levels(scatterplot_data$type), drop=FALSE) |
| 424 p = ggplot(scatterplot_locus_data, aes(type, normalized_read_count, group=link)) + geom_line() + scale_y_log10(breaks=scales,labels=scales) + expand_limits(y=c(0,10^6)) + scale_x_discrete(breaks=levels(scatterplot_data$type), labels=levels(scatterplot_data$type), drop=FALSE) | |
| 425 } else { | 410 } else { |
| 426 #p = ggplot(scatterplot_locus_data, aes(type, Frequency)) + scale_y_continuous(limits = c(0, 100)) + expand_limits(y=c(0,100)) + scale_x_discrete(breaks=levels(scatterplot_data$type), labels=levels(scatterplot_data$type), drop=FALSE) | 411 p = ggplot(scatterplot_locus_data, aes(factor(reorder(type, type.order)), Frequency, group=link)) + geom_line() + scale_y_log10(limits=c(0.0001,100), breaks=c(0.0001, 0.001, 0.01, 0.1, 1, 10, 100), labels=c("0.0001", "0.001", "0.01", "0.1", "1", "10", "100")) + scale_x_discrete(breaks=levels(scatterplot_data$type), labels=levels(scatterplot_data$type), drop=FALSE) |
| 427 p = ggplot(scatterplot_locus_data, aes(type, Frequency, group=link)) + geom_line() + scale_y_log10(limits=c(0.0001,100), breaks=c(0.0001, 0.001, 0.01, 0.1, 1, 10, 100), labels=c("0.0001", "0.001", "0.01", "0.1", "1", "10", "100")) + scale_x_discrete(breaks=levels(scatterplot_data$type), labels=levels(scatterplot_data$type), drop=FALSE) | |
| 428 } | 412 } |
| 429 #p = p + geom_point(aes(colour=type), position="jitter") | |
| 430 p = p + geom_point(aes(colour=type), position="dodge") | 413 p = p + geom_point(aes(colour=type), position="dodge") |
| 431 p = p + xlab("In one or both samples") + ylab(onShort) + ggtitle(paste(patient1[1,patientIndex], patient1[1,sampleIndex], patient2[1,sampleIndex], onShort, product[iter, titleIndex])) | 414 p = p + xlab("In one or both samples") + ylab(onShort) + ggtitle(paste(patient1[1,patientIndex], patient1[1,sampleIndex], patient2[1,sampleIndex], onShort, product[iter, titleIndex])) |
| 432 } else { | 415 } else { |
| 433 p = ggplot(NULL, aes(x=c("In one", "In Both"),y=0)) + geom_blank(NULL) + xlab("In one or both of the samples") + ylab(onShort) + ggtitle(paste(patient1[1,patientIndex], patient1[1,sampleIndex], patient2[1,sampleIndex], onShort, product[iter, titleIndex])) | 416 p = ggplot(NULL, aes(x=c("In one", "In Both"),y=0)) + geom_blank(NULL) + xlab("In one or both of the samples") + ylab(onShort) + ggtitle(paste(patient1[1,patientIndex], patient1[1,sampleIndex], patient2[1,sampleIndex], onShort, product[iter, titleIndex])) |
| 434 } | 417 } |
