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);
}
Aggregations