53
53
import java .util .Map ;
54
54
import java .util .Set ;
55
55
56
- import org .apache .commons .math3 .stat .inference .MannWhitneyUTest ;
57
56
import org .baderlab .csplugins .enrichmentmap .EnrichmentMapManager ;
58
57
import org .baderlab .csplugins .enrichmentmap .EnrichmentMapVisualStyle ;
59
58
import org .baderlab .csplugins .enrichmentmap .FilterParameters ;
65
64
import org .baderlab .csplugins .enrichmentmap .model .GenesetSimilarity ;
66
65
import org .baderlab .csplugins .enrichmentmap .model .Ranking ;
67
66
import org .baderlab .csplugins .enrichmentmap .util .NetworkUtil ;
67
+ import org .baderlab .csplugins .mannwhit .MannWhitneyUTestSided ;
68
68
import org .cytoscape .application .CyApplicationManager ;
69
69
import org .cytoscape .application .swing .CySwingApplication ;
70
70
import org .cytoscape .event .CyEventHelper ;
@@ -291,12 +291,15 @@ else if (cyNodeAttrs.getRow(nodesMap.get(geneset_name).getSUID()).get(prefix + E
291
291
double coeffecient = ComputeSimilarityTask .computeSimilarityCoeffecient (map .getParams (), intersection , union , sigGenes , enrGenes );
292
292
GenesetSimilarity comparison = new GenesetSimilarity (hub_name , geneset_name , coeffecient , interaction , intersection );
293
293
294
- switch (paParams .getRankTestParameters ().getType ()) {
294
+ FilterType filterType = paParams .getRankTestParameters ().getType ();
295
+ switch (filterType ) {
295
296
case HYPERGEOM :
296
297
int universeSize1 = paParams .getUniverseSize ();
297
298
hypergeometric (universeSize1 , sigGenesInUniverse , enrGenes , intersection , comparison );
298
299
break ;
299
- case MANN_WHIT :
300
+ case MANN_WHIT_TWO_SIDED :
301
+ case MANN_WHIT_GREATER :
302
+ case MANN_WHIT_LESS :
300
303
mannWhitney (intersection , comparison );
301
304
default : // want mann-whit to fall through
302
305
int universeSize2 = map .getNumberOfGenes (); // #70 calculate hypergeometric also
@@ -364,8 +367,12 @@ private boolean passesCutoff(String edge_name) {
364
367
switch (filterParams .getType ()) {
365
368
case HYPERGEOM :
366
369
return similarity .getHypergeom_pvalue () <= filterParams .getValue (FilterType .HYPERGEOM );
367
- case MANN_WHIT :
368
- return !similarity .isMannWhitMissingRanks () && similarity .getMann_Whit_pValue () <= filterParams .getValue (FilterType .MANN_WHIT );
370
+ case MANN_WHIT_TWO_SIDED :
371
+ return !similarity .isMannWhitMissingRanks () && similarity .getMann_Whit_pValue_twoSided () <= filterParams .getValue (FilterType .MANN_WHIT_TWO_SIDED );
372
+ case MANN_WHIT_GREATER :
373
+ return !similarity .isMannWhitMissingRanks () && similarity .getMann_Whit_pValue_greater () <= filterParams .getValue (FilterType .MANN_WHIT_GREATER );
374
+ case MANN_WHIT_LESS :
375
+ return !similarity .isMannWhitMissingRanks () && similarity .getMann_Whit_pValue_less () <= filterParams .getValue (FilterType .MANN_WHIT_LESS );
369
376
case NUMBER :
370
377
return similarity .getSizeOfOverlap () >= filterParams .getValue (FilterType .NUMBER );
371
378
case PERCENT :
@@ -518,21 +525,22 @@ private void createEdge(String edge_name, CyNetwork current_network, CyNetworkVi
518
525
if (passed_cutoff )
519
526
current_edgerow .set (prefix + EnrichmentMapVisualStyle .CUTOFF_TYPE , paParams .getRankTestParameters ().getType ().display );
520
527
521
- // Attributes related to the Hypergeometric Test
522
- switch (paParams .getRankTestParameters ().getType ()) {
523
- case MANN_WHIT :
524
- current_edgerow .set (prefix + EnrichmentMapVisualStyle .MANN_WHIT_PVALUE , genesetSimilarity .getMann_Whit_pValue ());
525
- current_edgerow .set (prefix + EnrichmentMapVisualStyle .MANN_WHIT_CUTOFF , paParams .getRankTestParameters ().getValue (FilterType .MANN_WHIT ));
526
- // want to fall through to the HYERGEOM case
527
- default :
528
- case HYPERGEOM :
529
- current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_PVALUE , genesetSimilarity .getHypergeom_pvalue ());
530
- current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_N , genesetSimilarity .getHypergeom_N ());
531
- current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_n , genesetSimilarity .getHypergeom_n ());
532
- current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_m , genesetSimilarity .getHypergeom_m ());
533
- current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_k , genesetSimilarity .getHypergeom_k ());
534
- current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_CUTOFF , paParams .getRankTestParameters ().getValue (FilterType .HYPERGEOM ));
528
+ FilterType filterType = paParams .getRankTestParameters ().getType ();
529
+
530
+ if (filterType .isMannWhitney ()) {
531
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .MANN_WHIT_TWOSIDED_PVALUE , genesetSimilarity .getMann_Whit_pValue_twoSided ());
532
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .MANN_WHIT_GREATER_PVALUE , genesetSimilarity .getMann_Whit_pValue_greater ());
533
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .MANN_WHIT_LESS_PVALUE , genesetSimilarity .getMann_Whit_pValue_less ());
534
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .MANN_WHIT_CUTOFF , paParams .getRankTestParameters ().getValue (filterType ));
535
535
}
536
+
537
+ // always calculate hypergeometric
538
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_PVALUE , genesetSimilarity .getHypergeom_pvalue ());
539
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_N , genesetSimilarity .getHypergeom_N ());
540
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_n , genesetSimilarity .getHypergeom_n ());
541
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_m , genesetSimilarity .getHypergeom_m ());
542
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_k , genesetSimilarity .getHypergeom_k ());
543
+ current_edgerow .set (prefix + EnrichmentMapVisualStyle .HYPERGEOM_CUTOFF , paParams .getRankTestParameters ().getValue (FilterType .HYPERGEOM ));
536
544
}
537
545
538
546
@@ -563,7 +571,9 @@ private void hypergeometric(int universeSize,
563
571
private void mannWhitney (Set <Integer > intersection , GenesetSimilarity comparison ) {
564
572
Map <Integer , Double > gene2score = ranks .getGene2Score ();
565
573
if (gene2score == null || gene2score .isEmpty ()) {
566
- comparison .setMann_Whit_pValue (1.5 );
574
+ comparison .setMann_Whit_pValue_twoSided (1.5 );
575
+ comparison .setMann_Whit_pValue_greater (1.5 );
576
+ comparison .setMann_Whit_pValue_less (1.5 );
567
577
comparison .setMannWhitMissingRanks (true );
568
578
} else {
569
579
// Calculate Mann-Whitney U pValue for Overlap
@@ -582,13 +592,20 @@ private void mannWhitney(Set<Integer> intersection, GenesetSimilarity comparison
582
592
double [] scores = ranks .getScores ();
583
593
584
594
if (scores .length == 0 || overlap_gene_scores .length == 0 ) {
585
- comparison .setMann_Whit_pValue (1.5 ); // avoid NoDataException
595
+ comparison .setMann_Whit_pValue_twoSided (1.5 ); // avoid NoDataException
596
+ comparison .setMann_Whit_pValue_greater (1.5 );
597
+ comparison .setMann_Whit_pValue_less (1.5 );
586
598
comparison .setMannWhitMissingRanks (true );
587
599
}
588
600
else {
589
- MannWhitneyUTest mann_whit = new MannWhitneyUTest ();
590
- double mannPval = mann_whit .mannWhitneyUTest (overlap_gene_scores , scores );
591
- comparison .setMann_Whit_pValue (mannPval );
601
+ // MKTODO could modify MannWHitneyUTestSided to return all three values from one call
602
+ MannWhitneyUTestSided mann_whit = new MannWhitneyUTestSided ();
603
+ double mannPvalTwoSided = mann_whit .mannWhitneyUTest (overlap_gene_scores , scores , MannWhitneyUTestSided .Type .TWO_SIDED );
604
+ comparison .setMann_Whit_pValue_twoSided (mannPvalTwoSided );
605
+ double mannPvalGreater = mann_whit .mannWhitneyUTest (overlap_gene_scores , scores , MannWhitneyUTestSided .Type .GREATER );
606
+ comparison .setMann_Whit_pValue_greater (mannPvalGreater );
607
+ double mannPvalLess = mann_whit .mannWhitneyUTest (overlap_gene_scores , scores , MannWhitneyUTestSided .Type .LESS );
608
+ comparison .setMann_Whit_pValue_less (mannPvalLess );
592
609
}
593
610
}
594
611
}
@@ -643,8 +660,13 @@ private CyTable createEdgeAttributes(CyNetwork network, String name, String pref
643
660
if (edgeTable .getColumn (prefix + EnrichmentMapVisualStyle .HYPERGEOM_CUTOFF ) == null )
644
661
edgeTable .createColumn (prefix + EnrichmentMapVisualStyle .HYPERGEOM_CUTOFF , Double .class , false );
645
662
646
- if (edgeTable .getColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_PVALUE ) == null )
647
- edgeTable .createColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_PVALUE , Double .class , false );
663
+ if (edgeTable .getColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_TWOSIDED_PVALUE ) == null )
664
+ edgeTable .createColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_TWOSIDED_PVALUE , Double .class , false );
665
+ if (edgeTable .getColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_GREATER_PVALUE ) == null )
666
+ edgeTable .createColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_GREATER_PVALUE , Double .class , false );
667
+ if (edgeTable .getColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_LESS_PVALUE ) == null )
668
+ edgeTable .createColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_LESS_PVALUE , Double .class , false );
669
+
648
670
if (edgeTable .getColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_CUTOFF ) == null )
649
671
edgeTable .createColumn (prefix + EnrichmentMapVisualStyle .MANN_WHIT_CUTOFF , Double .class , false );
650
672
0 commit comments