# HG changeset patch # User davidvanzessen # Date 1444313248 14400 # Node ID 7dd7cefcf72d33724cee0a4134fafc766382eab3 # Parent 7658e9f3d416d35f7a1f13c72a389cfa2c6d8298 Uploaded diff -r 7658e9f3d416 -r 7dd7cefcf72d RScript.r --- a/RScript.r Thu Oct 08 05:46:16 2015 -0400 +++ b/RScript.r Thu Oct 08 10:07:28 2015 -0400 @@ -190,6 +190,11 @@ first.rows = patient.fuzzy[first.match.filter,] second.rows = patient.fuzzy[second.match.filter,] + first.rows.v = table(first.rows$V_Segment_Major_Gene) + first.rows.v = names(first.rows.v[which.max(first.rows.v)]) + first.rows.j = table(first.rows$J_Segment_Major_Gene) + first.rows.j = names(first.rows.j[which.max(first.rows.j)]) + first.sum = data.frame(merge = first.clone.sequence, Patient = patient, Receptor = first.rows[1,"Receptor"], @@ -199,8 +204,8 @@ Log10_Frequency = log10(sum(first.rows$Frequency)), Total_Read_Count = sum(first.rows$Total_Read_Count), dsPerM = sum(first.rows$dsPerM), - J_Segment_Major_Gene = sort(table(first.rows$J_Segment_Major_Gene),decreasing=TRUE)[1], - V_Segment_Major_Gene = sort(table(first.rows$V_Segment_Major_Gene),decreasing=TRUE)[1], + J_Segment_Major_Gene = first.rows.j, + V_Segment_Major_Gene = first.rows.v, Clone_Sequence = first.clone.sequence, CDR3_Sense_Sequence = first.rows[1,"CDR3_Sense_Sequence"], Related_to_leukemia_clone = F, @@ -213,6 +218,11 @@ min_cell_paste = first.rows[1,"min_cell_paste"]) if(nrow(second.rows) > 0){ + second.rows.v = table(second.rows$V_Segment_Major_Gene) + second.rows.v = names(second.rows.v[which.max(second.rows.v)]) + second.rows.j = table(second.rows$J_Segment_Major_Gene) + second.rows.j = names(second.rows.j[which.max(second.rows.j)]) + second.sum = data.frame(merge = first.clone.sequence, Patient = patient, Receptor = second.rows[1,"Receptor"], @@ -222,8 +232,8 @@ Log10_Frequency = log10(sum(second.rows$Frequency)), Total_Read_Count = sum(second.rows$Total_Read_Count), dsPerM = sum(second.rows$dsPerM), - J_Segment_Major_Gene = sort(table(second.rows$J_Segment_Major_Gene),decreasing=TRUE)[1], - V_Segment_Major_Gene = sort(table(second.rows$V_Segment_Major_Gene),decreasing=TRUE)[1], + J_Segment_Major_Gene = second.rows.j, + V_Segment_Major_Gene = second.rows.v, Clone_Sequence = first.clone.sequence, CDR3_Sense_Sequence = second.rows[1,"CDR3_Sense_Sequence"], Related_to_leukemia_clone = F, @@ -238,11 +248,13 @@ patientMerge = rbind(patientMerge, merge(first.sum, second.sum, by="merge")) patient.fuzzy = patient.fuzzy[!(first.match.filter | second.match.filter),] + hidden.clone.sequences = c(first.rows[-1,"Clone_Sequence"], second.rows[second.rows$Clone_Sequence != first.clone.sequence,"Clone_Sequence"]) + merge.list[["second"]] = append(merge.list[["second"]], hidden.clone.sequences) if(sum(first.match.filter) == 1 & sum(second.match.filter) == 1){ second.clone.sequence = patient.fuzzy[second.match.filter, "Clone_Sequence"] - if(nchar(first.clone.sequence) == nchar(second.clone.sequence)){ - merge.list[["second"]] = append(merge.list[["second"]], second.clone.sequence) + if(first.clone.sequence != second.clone.sequence){ + #merge.list[["second"]] = append(merge.list[["second"]], second.clone.sequence) } }