Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixes to mutation sort

  • Loading branch information...
commit be6c76b46f23a2ffe9ca6cc62185a1ef57c3c66f 1 parent d135856
authored November 05, 2012
2  app/lib/router.js
@@ -42,7 +42,7 @@ module.exports = Backbone.Router.extend({
42 42
         Controller.oncovis.view();
43 43
     },
44 44
 
45  
-    seqpeek: function() {
  45
+    seqpeek: function(gene_label) {
46 46
         Controller.seqpeek.view();
47 47
     },
48 48
 
62  vendor/js/seqpeek.js
... ...
@@ -1,24 +1,49 @@
1 1
 !function ($) {
2 2
     var SeqPeekPrototype = {
3 3
         mutationSortFn: function(a, b) {
4  
-            var order = [
5  
-                "Silent",
6  
-                "Nonsense_Mutation",
7  
-                "Frame_Shift_Del",
8  
-                "Frame_Shift_Ins",
9  
-                "Missense_Mutation"
10  
-            ];
  4
+            var subtype_order = _
  5
+                .chain(this.data.cancer_subtypes)
  6
+                .pluck('label')
  7
+                .reduce(function(memo, label, index) {
  8
+                    memo[label] = index;
  9
+                    return memo;
  10
+                }, {})
  11
+                .value();
11 12
 
12  
-            var order_map = {};
13  
-            _.each(order, function(label, index) {
14  
-                order_map[label] = index;
15  
-            });
  13
+            var mutation_order = _
  14
+                .chain([
  15
+                    "Silent",
  16
+                    "Nonsense_Mutation",
  17
+                    "Frame_Shift_Del",
  18
+                    "Frame_Shift_Ins",
  19
+                    "Missense_Mutation"
  20
+                ])
  21
+                .reduce(function(memo, label, index) {
  22
+                    memo[label] = index;
  23
+                    return memo;
  24
+                }, {})
  25
+                .value();
  26
+
  27
+            if (!_.has(mutation_order, a.mutation_type) || !_.has(mutation_order, b.mutation_type)) {
  28
+                return 0;
  29
+            }
16 30
 
17  
-            if (_.has(order_map, a.mutation_type) && _.has(order_map, b.mutation_type)) {
18  
-                return order_map[a.mutation_type] > order_map[b.mutation_type];
  31
+            if( mutation_order[a.mutation_type] < mutation_order[b.mutation_type]) {
  32
+                return -1;
  33
+            }
  34
+            else if( mutation_order[a.mutation_type] > mutation_order[b.mutation_type]) {
  35
+                return 1;
19 36
             }
20 37
             else {
21  
-                return 0;
  38
+                if (subtype_order[a.cancer_subtype] < subtype_order[b.cancer_subtype]) {
  39
+                    return -1;
  40
+                }
  41
+                else if (subtype_order[a.cancer_subtype] > subtype_order[b.cancer_subtype]) {
  42
+                    return 1;
  43
+                }
  44
+                else {
  45
+                    return 0
  46
+                }
22 47
             }
23 48
         },
24 49
 
@@ -584,7 +609,7 @@
584 609
                     var group,
585 610
                         scale = d3.scale.ordinal();
586 611
 
587  
-                    mutations.sort(that.mutationSortFn);
  612
+                    mutations.sort(_.bind(that.mutationSortFn, that));
588 613
 
589 614
                     var mutation_ids_sorted = _
590 615
                         .chain(mutations)
@@ -1062,12 +1087,9 @@
1062 1087
         setStems: function(stems_enabled) {
1063 1088
             this.config.enable_mutation_stems = stems_enabled;
1064 1089
 
1065  
-            this.updateStems();
1066  
-            this.updateMutationLayout();
1067 1090
             this.updateVerticalScaleRanges();
1068  
-            this.updateVerticalGroups();
1069  
-            this.updateSubtypePositions();
1070  
-            this.updateMutationMarkers();
  1091
+            this.updateStems();
  1092
+            this.render();
1071 1093
         },
1072 1094
 
1073 1095
         setProteinScales: function(param_subtypes) {

0 notes on commit be6c76b

Please sign in to comment.
Something went wrong with that request. Please try again.