# HG changeset patch # User davidvanzessen # Date 1452096000 18000 # Node ID c532b3f8dc972a9258289c1fc3a8db58efe76b8a # Parent ef13f0a3f4d6c238c4625a608a173eddd9322738 Uploaded diff -r ef13f0a3f4d6 -r c532b3f8dc97 RScript.r --- a/RScript.r Tue Jan 05 10:49:40 2016 -0500 +++ b/RScript.r Wed Jan 06 11:00:00 2016 -0500 @@ -341,6 +341,10 @@ } patient.merge.list[[patient]] <<- patientMerge patient.merge.list.second[[patient]] <<- merge.list[["second"]] + + sample.order = data.frame(type = c(oneSample, twoSample, paste(c(oneSample, twoSample), "In Both")),type.order = 1:4) + scatterplot_data = merge(scatterplot_data, sample.order, by="type") + scatter_locus_data_list[[patient]] <<- scatterplot_data cat(paste("", nrow(patient1), " in ", oneSample, " and ", nrow(patient2), " in ", twoSample, ", ", nrow(patientMerge), " in both (finding both took ", (proc.time() - start.time)[[3]], "s)", sep=""), file=logfile, append=T) } @@ -391,42 +395,21 @@ } } else { scatterplot_locus_data = scatterplot_data[grepl(V_Segment, scatterplot_data$V_Segment_Major_Gene) & grepl(J_Segment, scatterplot_data$J_Segment_Major_Gene),] - #scatterplot_locus_data = scatterplot_locus_data[!(scatterplot_locus_data$merge %in% merge.list[[twoSample]]),] - #scatterplot_locus_data = scatterplot_locus_data[!(scatterplot_locus_data$merge %in% merge.list[["second"]]),] if(nrow(scatterplot_locus_data) > 0){ scatterplot_locus_data$Rearrangement = product[iter, titleIndex] } - - #in_one = (scatterplot_locus_data$merge %in% patient1$merge) - #in_two = (scatterplot_locus_data$merge %in% patient2$merge) - #if(any(in_two)){ - # scatterplot_locus_data[in_two,]$type = twoSample - #} - #in_both = (scatterplot_locus_data$merge %in% patientMerge$merge) - ##merge.list.filter = (scatterplot_locus_data$merge %in% merge.list[[oneSample]]) - ##exact.matches.filter = (scatterplot_locus_data$merge %in% cs.exact.matches) - #if(any(in_both)){ - # scatterplot_locus_data[in_both,]$type = "In Both" - #} - #if(type == "single" & (nrow(scatterplot_locus_data) > 0 | !any(scatterplot_locus_data$Patient %in% single_patients$Patient))){ - # single_patients <<- rbind(single_patients, scatterplot_locus_data) - #} - - + p = NULL print(paste("nrow scatterplot_locus_data", nrow(scatterplot_locus_data))) if(nrow(scatterplot_locus_data) != 0){ if(on == "normalized_read_count"){ scales = 10^(0:6) #(0:ceiling(log10(max(scatterplot_locus_data$normalized_read_count)))) - #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) - 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) + 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) } else { - #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) - 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) + 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) } - #p = p + geom_point(aes(colour=type), position="jitter") p = p + geom_point(aes(colour=type), position="dodge") 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])) } else {