use of org.baderlab.csplugins.enrichmentmap.EdgeSimilarities in project EnrichmentMapApp by BaderLab.
the class PostAnalysisTaskTest method test_2_PostAnalysisMannWhitney.
/**
* Run post-analysis with the default mann-whitney test.
* Uses the network that was created by the previous test method.
*/
@Test
public void test_2_PostAnalysisMannWhitney(@Continuous VisualMappingFunctionFactory cmFactory) throws Exception {
mockContinuousMappingFactory(cmFactory);
PostAnalysisParameters.Builder builder = new PostAnalysisParameters.Builder();
builder.setAnalysisType(AnalysisType.KNOWN_SIGNATURE);
builder.setUniverseType(UniverseType.USER_DEFINED);
builder.setUserDefinedUniverseSize(11445);
builder.setSignatureGMTFileName(PATH + "PA_top8_middle8_bottom8.gmt");
builder.setAttributePrefix("EM1_");
builder.addDataSetToRankFile(LegacySupport.DATASET1, LegacySupport.DATASET1);
PostAnalysisFilterParameters rankTest = new PostAnalysisFilterParameters(PostAnalysisFilterType.MANN_WHIT_TWO_SIDED);
builder.setRankTestParameters(rankTest);
runPostAnalysis(emNetwork, builder, LegacySupport.DATASET1);
// Assert that post-analysis created the new nodes correctly
Map<String, CyNode> nodes = TestUtils.getNodes(emNetwork);
assertEquals(5, nodes.size());
assertTrue(nodes.containsKey("PA_TOP8_MIDDLE8_BOTTOM8"));
EdgeSimilarities edges = TestUtils.getEdgeSimilarities(emNetwork);
assertEquals(8, edges.size());
CyEdge edge1 = edges.getEdge("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP8_PLUS100");
assertNotNull(edge1);
assertEquals(1.40E-6, emNetwork.getRow(edge1).get("EM1_Overlap_Mann_Whit_pVal", Double.class), 0.001);
assertEquals(PostAnalysisFilterType.MANN_WHIT_TWO_SIDED.toString(), emNetwork.getRow(edge1).get("EM1_Overlap_cutoff", String.class));
CyEdge edge2 = edges.getEdge("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) BOTTOM8_PLUS100");
assertNotNull(edge2);
assertEquals(1.40E-6, emNetwork.getRow(edge2).get("EM1_Overlap_Mann_Whit_pVal", Double.class), 0.001);
assertEquals(PostAnalysisFilterType.MANN_WHIT_TWO_SIDED.toString(), emNetwork.getRow(edge2).get("EM1_Overlap_cutoff", String.class));
}
use of org.baderlab.csplugins.enrichmentmap.EdgeSimilarities in project EnrichmentMapApp by BaderLab.
the class PostAnalysisTaskTest method test_4_WidthFunction.
@Test
public void test_4_WidthFunction(@Continuous VisualMappingFunctionFactory cmFactory, EnrichmentMapManager emManager, Provider<WidthFunction> widthFunctionProvider) {
CyNetworkManager networkManager = mock(CyNetworkManager.class);
when(networkManager.getNetworkSet()).thenReturn(Collections.singleton(emNetwork));
mockContinuousMappingFactory(cmFactory);
EdgeSimilarities edges = TestUtils.getEdgeSimilarities(emNetwork);
CyEdge sigEdge1 = edges.getEdge("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP8_PLUS100");
CyEdge sigEdge2 = edges.getEdge("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP1_PLUS100");
EnrichmentMap map = emManager.getEnrichmentMap(emNetwork.getSUID());
assertNotNull(map);
WidthFunction widthFunction = widthFunctionProvider.get();
widthFunction.setEdgeWidths(emNetwork, "EM1_", null);
String widthCol = Columns.EDGE_WIDTH_FORMULA_COLUMN.with("EM1_", null);
double sigWidth1 = emNetwork.getRow(sigEdge1).get(widthCol, Double.class);
assertEquals(8.0, sigWidth1, 0.0);
double sigWidth2 = emNetwork.getRow(sigEdge2).get(widthCol, Double.class);
assertEquals(1.0, sigWidth2, 0.0);
}
use of org.baderlab.csplugins.enrichmentmap.EdgeSimilarities in project EnrichmentMapApp by BaderLab.
the class PostAnalysisTaskTest method test_1_EnrichmentMapBuildMapTask.
@Test
public void test_1_EnrichmentMapBuildMapTask(CyApplicationManager applicationManager, CyNetworkManager networkManager, EnrichmentMapManager emManager) {
DataSetFiles dataset1files = new DataSetFiles();
dataset1files.setGMTFileName(PATH + "gene_sets.gmt");
dataset1files.setExpressionFileName(PATH + "FakeExpression.txt");
dataset1files.setEnrichmentFileName1(PATH + "fakeEnrichments.txt");
dataset1files.setRankedFile(PATH + "FakeRank.rnk");
EMCreationParameters params = new EMCreationParameters("EM1_", 0.1, 0.1, NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, 0.1, 0.1);
buildEnrichmentMap(params, dataset1files, Method.Generic, LegacySupport.DATASET1);
// Assert the network is as expected
Set<CyNetwork> networks = networkManager.getNetworkSet();
assertEquals(1, networks.size());
CyNetwork network = networks.iterator().next();
Map<String, CyNode> nodes = TestUtils.getNodes(network);
assertEquals(4, nodes.size());
assertTrue(nodes.containsKey("BOTTOM8_PLUS100"));
assertTrue(nodes.containsKey("MIDDLE8_PLUS100"));
assertTrue(nodes.containsKey("TOP8_PLUS100"));
assertTrue(nodes.containsKey("TOP1_PLUS100"));
EdgeSimilarities edges = TestUtils.getEdgeSimilarities(network);
assertEquals(6, edges.size());
assertTrue(edges.containsEdge("MIDDLE8_PLUS100", "Geneset_Overlap", "BOTTOM8_PLUS100"));
assertTrue(edges.containsEdge("TOP8_PLUS100", "Geneset_Overlap", "MIDDLE8_PLUS100"));
assertTrue(edges.containsEdge("TOP8_PLUS100", "Geneset_Overlap", "BOTTOM8_PLUS100"));
assertTrue(edges.containsEdge("TOP1_PLUS100", "Geneset_Overlap", "TOP8_PLUS100"));
assertTrue(edges.containsEdge("TOP1_PLUS100", "Geneset_Overlap", "MIDDLE8_PLUS100"));
assertTrue(edges.containsEdge("TOP1_PLUS100", "Geneset_Overlap", "BOTTOM8_PLUS100"));
// Make the network available to the subsequent test methods (requires test methods are run in order)
emNetwork = network;
}
Aggregations