Search in sources :

Example 1 with MannWhitneyTestResult

use of org.baderlab.csplugins.mannwhit.MannWhitneyTestResult in project EnrichmentMapApp by BaderLab.

the class CreateDiseaseSignatureTaskParallel method mannWhitney.

private void mannWhitney(Set<Integer> intersection, GenesetSimilarity comparison, EMDataSet dataSet) {
    String rankFile = params.getDataSetToRankFile().get(dataSet.getName());
    Ranking ranks = dataSet.getExpressionSets().getRanks().get(rankFile);
    // Calculate Mann-Whitney U pValue for Overlap
    Integer[] overlapGeneIds = intersection.toArray(new Integer[intersection.size()]);
    double[] overlapGeneScores = new double[overlapGeneIds.length];
    int j = 0;
    for (Integer geneId : overlapGeneIds) {
        Double score = ranks.getScore(geneId);
        if (score != null) {
            // unbox
            overlapGeneScores[j++] = score;
        }
    }
    overlapGeneScores = Arrays.copyOf(overlapGeneScores, j);
    if (ranks.isEmpty()) {
        // avoid NoDataException
        comparison.setMannWhitPValueTwoSided(1.5);
        comparison.setMannWhitPValueGreater(1.5);
        comparison.setMannWhitPValueLess(1.5);
        comparison.setMannWhitMissingRanks(true);
    } else {
        double[] scores = ranks.getScores();
        MannWhitneyTestResult result = mannWhitneyCache.mannWhitneyUTestBatch(overlapGeneScores, scores);
        comparison.setMannWhitPValueTwoSided(result.twoSided);
        comparison.setMannWhitPValueGreater(result.greater);
        comparison.setMannWhitPValueLess(result.less);
    }
}
Also used : Ranking(org.baderlab.csplugins.enrichmentmap.model.Ranking) MannWhitneyTestResult(org.baderlab.csplugins.mannwhit.MannWhitneyTestResult)

Aggregations

Ranking (org.baderlab.csplugins.enrichmentmap.model.Ranking)1 MannWhitneyTestResult (org.baderlab.csplugins.mannwhit.MannWhitneyTestResult)1