comparison RScript.r @ 5:bcf1469e8feb draft

Uploaded
author davidvanzessen
date Mon, 02 Oct 2017 09:24:25 -0400
parents 89d80f086328
children a9d2ed661541
comparison
equal deleted inserted replaced
4:89d80f086328 5:bcf1469e8feb
45 dat$J_Segment_Major_Gene = as.factor(as.character(lapply(strsplit(as.character(dat$J_Segment_Major_Gene), "; "), "[[", 1))) 45 dat$J_Segment_Major_Gene = as.factor(as.character(lapply(strsplit(as.character(dat$J_Segment_Major_Gene), "; "), "[[", 1)))
46 46
47 cat("<tr><td>Calculating Frequency</td></tr>", file=logfile, append=T) 47 cat("<tr><td>Calculating Frequency</td></tr>", file=logfile, append=T)
48 48
49 dat$Frequency = ((10^dat$Log10_Frequency)*100) 49 dat$Frequency = ((10^dat$Log10_Frequency)*100)
50 dat = dat[dat$Frequency <= 100,] #just in case 50 dat = dat[dat$Frequency <= 100,] #just in case?
51 51
52 dat = dat[dat$Frequency >= min_freq,] 52 dat = dat[dat$Frequency >= min_freq,]
53 53
54 patient.sample.counts = data.frame(data.table(dat)[, list(count=.N), by=c("Patient", "Sample")]) 54 patient.sample.counts = data.frame(data.table(dat)[, list(count=.N), by=c("Patient", "Sample")])
55 patient.sample.counts = data.frame(data.table(patient.sample.counts)[, list(count=.N), by=c("Patient")]) 55 patient.sample.counts = data.frame(data.table(patient.sample.counts)[, list(count=.N), by=c("Patient")])
167 patientMerge = patient.merge.list[[patient]] 167 patientMerge = patient.merge.list[[patient]]
168 merge.list[["second"]] = patient.merge.list.second[[patient]] 168 merge.list[["second"]] = patient.merge.list.second[[patient]]
169 scatterplot_data = scatter_locus_data_list[[patient]] 169 scatterplot_data = scatter_locus_data_list[[patient]]
170 cat(paste("<td>", nrow(patient1), " in ", oneSample, " and ", nrow(patient2), " in ", twoSample, ", ", nrow(patientMerge), " in both (fetched from cache)</td></tr>", sep=""), file=logfile, append=T) 170 cat(paste("<td>", nrow(patient1), " in ", oneSample, " and ", nrow(patient2), " in ", twoSample, ", ", nrow(patientMerge), " in both (fetched from cache)</td></tr>", sep=""), file=logfile, append=T)
171 171
172 print(names(patient.merge.list)) 172 #print(names(patient.merge.list))
173 } else { 173 } else {
174 #fuzzy matching here... 174 #fuzzy matching here...
175 175
176 patient1.fuzzy = patient1 176 patient1.fuzzy = patient1
177 patient2.fuzzy = patient2 177 patient2.fuzzy = patient2
771 hidden.clone.sequences = c(rows.1[-1,"Clone_Sequence"], rows.3[rows.3$Clone_Sequence != first.clone.sequence,"Clone_Sequence"]) 771 hidden.clone.sequences = c(rows.1[-1,"Clone_Sequence"], rows.3[rows.3$Clone_Sequence != first.clone.sequence,"Clone_Sequence"])
772 merge.list[["second"]] = append(merge.list[["second"]], hidden.clone.sequences) 772 merge.list[["second"]] = append(merge.list[["second"]], hidden.clone.sequences)
773 773
774 } else if(nrow(rows.1) > 1){ 774 } else if(nrow(rows.1) > 1){
775 patient1 = patient1[!(patient1$Clone_Sequence %in% rows.1$Clone_Sequence),] 775 patient1 = patient1[!(patient1$Clone_Sequence %in% rows.1$Clone_Sequence),]
776 print(names(patient1)[names(patient1) %in% sum.1]) 776 #print(names(patient1)[names(patient1) %in% sum.1])
777 print(names(patient1)[!(names(patient1) %in% sum.1)]) 777 #print(names(patient1)[!(names(patient1) %in% sum.1)])
778 print(names(patient1)) 778 #print(names(patient1))
779 print(names(sum.1)) 779 #print(names(sum.1))
780 print(summary(sum.1)) 780 #print(summary(sum.1))
781 print(summary(patient1)) 781 #print(summary(patient1))
782 print(dim(sum.1)) 782 #print(dim(sum.1))
783 print(dim(patient1)) 783 #print(dim(patient1))
784 print(head(sum.1[,names(patient1)])) 784 #print(head(sum.1[,names(patient1)]))
785 patient1 = rbind(patient1, sum.1[,names(patient1)]) 785 patient1 = rbind(patient1, sum.1[,names(patient1)])
786 patient.fuzzy = patient.fuzzy[-match.filter.1,] 786 patient.fuzzy = patient.fuzzy[-match.filter.1,]
787 } else { 787 } else {
788 patient.fuzzy = patient.fuzzy[-1,] 788 patient.fuzzy = patient.fuzzy[-1,]
789 } 789 }
1040 interval = intervalReads 1040 interval = intervalReads
1041 intervalOrder = data.frame("interval"=paste(">", interval, sep=""), "intervalOrder"=1:length(interval)) 1041 intervalOrder = data.frame("interval"=paste(">", interval, sep=""), "intervalOrder"=1:length(interval))
1042 product = data.frame("Titles"=rep(Titles, each=length(interval)), "interval"=rep(interval, times=10), "V_Segments"=rep(V_Segments, each=length(interval)), "J_Segments"=rep(J_Segments, each=length(interval))) 1042 product = data.frame("Titles"=rep(Titles, each=length(interval)), "interval"=rep(interval, times=10), "V_Segments"=rep(V_Segments, each=length(interval)), "J_Segments"=rep(J_Segments, each=length(interval)))
1043 1043
1044 triplets = split(triplets, triplets$Patient, drop=T) 1044 triplets = split(triplets, triplets$Patient, drop=T)
1045 print(nrow(triplets)) 1045 #print(nrow(triplets))
1046 for(triplet in triplets){ 1046 for(triplet in triplets){
1047 samples = unique(triplet$Sample) 1047 samples = unique(triplet$Sample)
1048 one = triplet[triplet$Sample == samples[1],] 1048 one = triplet[triplet$Sample == samples[1],]
1049 two = triplet[triplet$Sample == samples[2],] 1049 two = triplet[triplet$Sample == samples[2],]
1050 three = triplet[triplet$Sample == samples[3],] 1050 three = triplet[triplet$Sample == samples[3],]