Search in sources :

Example 1 with GSEALeadingEdgeRankingOption

use of org.baderlab.csplugins.enrichmentmap.view.heatmap.GSEALeadingEdgeRankingOption in project EnrichmentMapApp by BaderLab.

the class HeatMapRanksTest method testLeadingEdge.

@Test
public void testLeadingEdge(EnrichmentMapManager emManager) throws Exception {
    final String geneSetName = "ENVELOPE%GO%GO:0031975";
    final int leadingEdgeSize = 170;
    // Sanity test
    EnrichmentMap map = emManager.getAllEnrichmentMaps().values().iterator().next();
    EMDataSet dataset = map.getDataSet(LegacySupport.DATASET1);
    GeneSet gs = dataset.getGeneSetsOfInterest().getGeneSets().get(geneSetName);
    assertNotNull(gs);
    // Run the ranking
    RankingOption rankingOption = new GSEALeadingEdgeRankingOption(dataset, geneSetName, Ranking.GSEARanking);
    Map<Integer, RankValue> ranks = rankingOption.computeRanking(gs.getGenes()).get().get();
    assertEquals(454, ranks.size());
    // Convert to useful collections
    Map<RankValue, Integer> rankToGeneId = HashBiMap.create(ranks).inverse();
    List<RankValue> sortedRanks = ranks.values().stream().sorted().collect(Collectors.toList());
    // Test leading edge
    for (int i = 0; i < sortedRanks.size(); i++) {
        RankValue v = sortedRanks.get(i);
        assertTrue(v.isSignificant() == i < leadingEdgeSize);
    }
    // Test genes are the same
    List<Integer> expectedGeneOrder = getGeneOrderFromFile(map, PATH + "gene_order_leading_edge.txt");
    List<Integer> actualGeneOrder = sortedRanks.stream().map(rankToGeneId::get).collect(Collectors.toList());
    assertEquals(expectedGeneOrder, actualGeneOrder);
}
Also used : RankingOption(org.baderlab.csplugins.enrichmentmap.view.heatmap.RankingOption) GSEALeadingEdgeRankingOption(org.baderlab.csplugins.enrichmentmap.view.heatmap.GSEALeadingEdgeRankingOption) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) RankValue(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue) GSEALeadingEdgeRankingOption(org.baderlab.csplugins.enrichmentmap.view.heatmap.GSEALeadingEdgeRankingOption) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) GeneSet(org.baderlab.csplugins.enrichmentmap.model.GeneSet) BaseNetworkTest(org.baderlab.csplugins.enrichmentmap.task.BaseNetworkTest) Test(org.junit.Test)

Aggregations

EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)1 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)1 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)1 BaseNetworkTest (org.baderlab.csplugins.enrichmentmap.task.BaseNetworkTest)1 GSEALeadingEdgeRankingOption (org.baderlab.csplugins.enrichmentmap.view.heatmap.GSEALeadingEdgeRankingOption)1 RankingOption (org.baderlab.csplugins.enrichmentmap.view.heatmap.RankingOption)1 RankValue (org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue)1 Test (org.junit.Test)1