3
3
import java .util .HashMap ;
4
4
import java .util .List ;
5
5
import java .util .Map ;
6
- import java .util .logging .Logger ;
7
6
8
7
import org .danvk .dygraphs .client .DygraphOptions ;
9
8
import org .danvk .dygraphs .client .DygraphOptions .HighlightSeriesOptions ;
@@ -113,6 +112,7 @@ public void execute() {
113
112
protected LDDataPoint highlightedLDDataPoint = null ;
114
113
protected double threshold = 0.3 ;
115
114
protected int maxColor = 255 ;
115
+ protected boolean isNotPairWise =false ;
116
116
117
117
//General settings
118
118
protected String chromosome ;
@@ -122,8 +122,6 @@ public void execute() {
122
122
protected int viewStart = 0 ;
123
123
protected int viewEnd = 0 ;
124
124
protected HashMap <Gene , DivElement > displayGenes = new HashMap <Gene , DivElement >();
125
-
126
- private static Logger logger = Logger .getLogger ("at.gmi.nordborglab.widgets.gwasgeneviewer" );
127
125
128
126
public GWASGeneViewer () {
129
127
initWidget ();
@@ -343,7 +341,8 @@ public void setZoom(int start, int end) {
343
341
344
342
public void loadLDPlot (JsArrayInteger snps ,
345
343
JsArray <JsArrayNumber > r2Values ,int startRegion ,int endRegion ) {
346
- toggleGenomeViewVisible (false );
344
+ setZoom (startRegion , endRegion );
345
+ isNotPairWise = false ;
347
346
ldviewer .setVisible (true );
348
347
ldviewer .onResize ();
349
348
ldviewer .showLDValues (snps , r2Values , startRegion , endRegion );
@@ -378,8 +377,10 @@ public void onZoom(ZoomEvent event) {
378
377
ldviewer .setHighlightPosition (null );
379
378
ldviewer .setVisible (false );
380
379
DygraphOptions options = DygraphOptions .create ();
381
- highlightedLDDataPoint = null ;
382
- highlightedLDDataPoints = null ;
380
+ if (!isNotPairWise ) {
381
+ highlightedLDDataPoint = null ;
382
+ highlightedLDDataPoints = null ;
383
+ }
383
384
options .setColors (color );
384
385
scatterChart .getDygraphsJS ().updateOptions (options );
385
386
}
@@ -418,10 +419,10 @@ else if (event.maxX > viewEnd)
418
419
@ Override
419
420
public void onHighlight (HighlightEvent event ) {
420
421
geneViewer .setSelectionLine (event .xVal );
421
- ldviewer .setHighlightPosition (event .xVal );
422
- highlightedLDDataPoints = getHighlightedDataPointMap ();
423
- highlightedLDDataPoint = null ;
424
422
if (ldviewer .isVisible ()) {
423
+ ldviewer .setHighlightPosition (event .xVal );
424
+ highlightedLDDataPoints = getHighlightedDataPointMap ();
425
+ highlightedLDDataPoint = null ;
425
426
int row = scatterChart .getDygraphsJS ().getSelection ();
426
427
scatterChart .redraw ();
427
428
scatterChart .getDygraphsJS ().setSelection (row , null );
@@ -434,10 +435,10 @@ public void onHighlight(HighlightEvent event) {
434
435
@ Override
435
436
public void onUnhighlight (UnhighlightEvent event ) {
436
437
geneViewer .hideSelectionLine ();
437
- ldviewer .setHighlightPosition (null );
438
- highlightedLDDataPoints = null ;
439
- highlightedLDDataPoint = null ;
440
438
if (ldviewer .isVisible ()) {
439
+ ldviewer .setHighlightPosition (null );
440
+ highlightedLDDataPoints = null ;
441
+ highlightedLDDataPoint = null ;
441
442
scatterChart .getDygraphsJS ().clearSelection ();
442
443
scatterChart .redraw ();
443
444
}
@@ -458,27 +459,26 @@ protected void drawScatterChart()
458
459
public void onDrawPoint (DrawPointEvent event ) {
459
460
event .canvas .setLineWidth (1 );
460
461
String color = event .color ;
461
- if (ldviewer .isVisible ()) {
462
- if (highlightedLDDataPoints != null ) {
463
- int x = (int )scatterChart .getDygraphsJS ().toDataXCoord (event .cx );
464
- LDDataPoint point = highlightedLDDataPoints .get (x );
465
- if (point != null ) {
466
- int hue = point .getR2Color (threshold , maxColor );
467
- color = "rgb(255," +hue +",0)" ;
468
- }
469
- else
470
- color = "blue" ;
462
+ if (highlightedLDDataPoints != null ) {
463
+ int x = (int )scatterChart .getDygraphsJS ().toDataXCoord (event .cx );
464
+ LDDataPoint point = highlightedLDDataPoints .get (x );
465
+ if (point != null ) {
466
+ int hue = point .getR2Color (threshold , maxColor );
467
+ color = "rgb(255," +hue +",0)" ;
471
468
}
472
- else if (highlightedLDDataPoint != null ){
473
- int x = (int )scatterChart .getDygraphsJS ().toDataXCoord (event .cx );
474
- if (x == highlightedLDDataPoint .getPosX () || x == highlightedLDDataPoint .getPosY ()) {
475
- int hue = highlightedLDDataPoint .getR2Color (threshold , maxColor );
476
- color = "rgb(255," +hue +",0)" ;
477
- scatterChart .getDygraphsJS ().drawDEFAULT (event .dygraph , event .seriesName , event .canvas , event .cx , event .cy , color , event .radius +2 );
478
- return ;
479
- }
469
+ else
470
+ color = "blue" ;
471
+ }
472
+ else if (highlightedLDDataPoint != null ){
473
+ int x = (int )scatterChart .getDygraphsJS ().toDataXCoord (event .cx );
474
+ if (x == highlightedLDDataPoint .getPosX () || x == highlightedLDDataPoint .getPosY ()) {
475
+ int hue = highlightedLDDataPoint .getR2Color (threshold , maxColor );
476
+ color = "rgb(255," +hue +",0)" ;
477
+ scatterChart .getDygraphsJS ().drawDEFAULT (event .dygraph , event .seriesName , event .canvas , event .cx , event .cy , color , event .radius +2 );
478
+ return ;
480
479
}
481
480
}
481
+
482
482
scatterChart .getDygraphsJS ().drawDEFAULT (event .dygraph , event .seriesName , event .canvas , event .cx , event .cy , color , event .radius );
483
483
//scatterChart.getDygraphsJS().drawPLUS(event.dygraph, event.seriesName, event.canvas, event.cx, event.cy, event.color, event.radius);
484
484
}
@@ -488,11 +488,19 @@ else if (highlightedLDDataPoint != null){
488
488
@ Override
489
489
public void onDrawHighlightPoint (DrawHighlightPointEvent event ) {
490
490
String color = event .color ;
491
- if (ldviewer . isVisible () && highlightedLDDataPoints != null ) {
491
+ if (highlightedLDDataPoints != null ) {
492
492
int x = (int )scatterChart .getDygraphsJS ().toDataXCoord (event .cx );
493
493
LDDataPoint point = highlightedLDDataPoints .get (x );
494
494
if (point != null ) {
495
- color = "rgb(255,0,0)" ;
495
+ if (isNotPairWise ) {
496
+ int hue = point .getR2Color (threshold , maxColor );
497
+ color = "rgb(255," +hue +",0)" ;
498
+ }
499
+ else
500
+ color = "rgb(255,0,0)" ;
501
+ }
502
+ else if (isNotPairWise ) {
503
+ color = "blue" ;
496
504
}
497
505
}
498
506
scatterChart .getDygraphsJS ().drawDEFAULT (event .dygraph , event .seriesName , event .canvas , event .cx , event .cy , color , event .radius );
@@ -592,14 +600,41 @@ private HashMap<Integer, LDDataPoint> getHighlightedDataPointMap() {
592
600
HashMap <Integer , LDDataPoint > map = new HashMap <Integer , LDDataPoint >();
593
601
for (int i = 0 ;i <dataPoints .length ;i ++) {
594
602
LDDataPoint point = dataPoints [i ];
595
- map .put (point .getPosX (), point );
603
+ map .put (point .getPosX (),point );
596
604
map .put (point .getPosY (),point );
597
605
}
598
606
return map ;
599
607
}
600
608
return null ;
601
609
}
602
610
611
+ protected void setHighlightedDataPoints (int position ,JsArrayInteger snps ,JsArrayNumber r2Values ) {
612
+ highlightedLDDataPoints = new HashMap <Integer , LDDataPoint >();
613
+ for (int i = 0 ; i <r2Values .length () ; i ++) {
614
+ LDDataPoint dataPoint = LDDataPoint .createObject ().cast ();
615
+ dataPoint .setR2 (r2Values .get (i ));
616
+ dataPoint .setPosX (snps .get (i ));
617
+ if (dataPoint .getR2 () > threshold )
618
+ highlightedLDDataPoints .put (dataPoint .getPosX (), dataPoint );
619
+ }
620
+
621
+ }
622
+
623
+ public void showColoredLDValues (int position ,JsArrayInteger snps ,JsArrayNumber r2Values ) {
624
+ isNotPairWise = true ;
625
+ setHighlightedDataPoints (position , snps , r2Values );
626
+ ldviewer .setVisible (false );
627
+ }
628
+
629
+ public void hideColoredLDValues () {
630
+ highlightedLDDataPoints = null ;
631
+ highlightedLDDataPoint = null ;
632
+ if (isNotPairWise ) {
633
+ isNotPairWise = false ;
634
+ refresh ();
635
+ }
636
+ }
637
+
603
638
protected DygraphOptions setOptions (DygraphOptions options ){
604
639
double maxValue = max_value ;
605
640
if (maxValue < bonferroniThreshold )
0 commit comments