Search in sources :

Example 1 with PostAnalysisFilterParameters

use of org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters in project EnrichmentMapApp by BaderLab.

the class CreateDiseaseSignatureNetworkTask method passesCutoff.

/**
	 * Why not put this in CreateDiseaseSignatureTaskParallel... don't even create the GenesetSimilarity object if it fails!!!
	 * @param similarityKey
	 * @return
	 */
private boolean passesCutoff(SimilarityKey similarityKey, EMSignatureDataSet sigDataSet) {
    GenesetSimilarity similarity = geneSetSimilarities.get(similarityKey);
    PostAnalysisFilterParameters filterParams = params.getRankTestParameters();
    switch(filterParams.getType()) {
        case HYPERGEOM:
            return similarity.getHypergeomPValue() <= filterParams.getValue();
        case MANN_WHIT_TWO_SIDED:
            return !similarity.isMannWhitMissingRanks() && similarity.getMannWhitPValueTwoSided() <= filterParams.getValue();
        case MANN_WHIT_GREATER:
            return !similarity.isMannWhitMissingRanks() && similarity.getMannWhitPValueGreater() <= filterParams.getValue();
        case MANN_WHIT_LESS:
            return !similarity.isMannWhitMissingRanks() && similarity.getMannWhitPValueLess() <= filterParams.getValue();
        case NUMBER:
            return similarity.getSizeOfOverlap() >= filterParams.getValue();
        case PERCENT:
            EMDataSet dataSet = map.getDataSet(similarityKey.getName());
            String enrGeneSetName = similarity.getGeneset2Name();
            GeneSet enrGeneset = dataSet.getGeneSetsOfInterest().getGeneSetByName(enrGeneSetName);
            int enrGenesetSize = enrGeneset.getGenes().size();
            double relative_per = (double) similarity.getSizeOfOverlap() / (double) enrGenesetSize;
            return relative_per >= filterParams.getValue() / 100.0;
        case SPECIFIC:
            String hubName = similarity.getGeneset1Name();
            GeneSet sigGeneSet = sigDataSet.getGeneSetsOfInterest().getGeneSetByName(hubName);
            int sigGeneSetSize = sigGeneSet.getGenes().size();
            double relativePer2 = (double) similarity.getSizeOfOverlap() / (double) sigGeneSetSize;
            return relativePer2 >= filterParams.getValue() / 100.0;
        default:
            return false;
    }
}
Also used : PostAnalysisFilterParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) GenesetSimilarity(org.baderlab.csplugins.enrichmentmap.model.GenesetSimilarity) GeneSet(org.baderlab.csplugins.enrichmentmap.model.GeneSet)

Example 2 with PostAnalysisFilterParameters

use of org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters 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));
}
Also used : PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) PostAnalysisFilterParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters) CyNode(org.cytoscape.model.CyNode) EdgeSimilarities(org.baderlab.csplugins.enrichmentmap.EdgeSimilarities) CyEdge(org.cytoscape.model.CyEdge) Test(org.junit.Test)

Example 3 with PostAnalysisFilterParameters

use of org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters in project EnrichmentMapApp by BaderLab.

the class PostAnalysisCutoffTest method test_1_FilterType_Number.

@Test
public void test_1_FilterType_Number(@Continuous VisualMappingFunctionFactory cmFactory) throws Exception {
    mockContinuousMappingFactory(cmFactory);
    PostAnalysisParameters.Builder builder = getBuilder();
    PostAnalysisFilterParameters rankTest = new PostAnalysisFilterParameters(PostAnalysisFilterType.NUMBER, 5);
    builder.setRankTestParameters(rankTest);
    runPostAnalysis(emNetwork, builder, LegacySupport.DATASET1);
    Map<String, CyEdge> edges = TestUtils.getEdges(emNetwork);
    assertEquals(9, edges.size());
    CyEdge edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) MIDDLE8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.NUMBER.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) BOTTOM8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.NUMBER.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.NUMBER.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP1_PLUS100");
    assertNull(edge);
}
Also used : PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) PostAnalysisFilterParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters) CyEdge(org.cytoscape.model.CyEdge) Test(org.junit.Test)

Example 4 with PostAnalysisFilterParameters

use of org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters in project EnrichmentMapApp by BaderLab.

the class PostAnalysisCutoffTest method test_2_FilterType_Percent.

@Test
public void test_2_FilterType_Percent(@Continuous VisualMappingFunctionFactory cmFactory) throws Exception {
    mockContinuousMappingFactory(cmFactory);
    PostAnalysisParameters.Builder builder = getBuilder();
    PostAnalysisFilterParameters rankTest = new PostAnalysisFilterParameters(PostAnalysisFilterType.PERCENT, 7);
    builder.setRankTestParameters(rankTest);
    runPostAnalysis(emNetwork, builder, LegacySupport.DATASET1);
    assertEquals(12, emNetwork.getEdgeCount());
    Map<String, CyEdge> edges = TestUtils.getSignatureEdges(emNetwork, "EM1_", "PA_top8_middle8_bottom8(1)");
    assertEquals(3, edges.size());
    CyEdge edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) MIDDLE8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.PERCENT.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) BOTTOM8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.PERCENT.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.PERCENT.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP1_PLUS100");
    assertNull(edge);
}
Also used : PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) PostAnalysisFilterParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters) CyEdge(org.cytoscape.model.CyEdge) Test(org.junit.Test)

Example 5 with PostAnalysisFilterParameters

use of org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters in project EnrichmentMapApp by BaderLab.

the class PostAnalysisCutoffTest method test_3_FilterType_Specific.

@Test
public void test_3_FilterType_Specific(@Continuous VisualMappingFunctionFactory cmFactory) throws Exception {
    mockContinuousMappingFactory(cmFactory);
    PostAnalysisParameters.Builder builder = getBuilder();
    PostAnalysisFilterParameters rankTest = new PostAnalysisFilterParameters(PostAnalysisFilterType.SPECIFIC, 25);
    builder.setRankTestParameters(rankTest);
    runPostAnalysis(emNetwork, builder, LegacySupport.DATASET1);
    assertEquals(15, emNetwork.getEdgeCount());
    Map<String, CyEdge> edges = TestUtils.getSignatureEdges(emNetwork, "EM1_", "PA_top8_middle8_bottom8(2)");
    assertEquals(3, edges.size());
    CyEdge edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) MIDDLE8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.SPECIFIC.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) BOTTOM8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.SPECIFIC.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP8_PLUS100");
    assertNotNull(edge);
    assertEquals(8, emNetwork.getRow(edge).get("EM1_k_intersection", Integer.class).intValue());
    assertEquals(PostAnalysisFilterType.SPECIFIC.toString(), emNetwork.getRow(edge).get("EM1_Overlap_cutoff", String.class));
    edge = edges.get("PA_TOP8_MIDDLE8_BOTTOM8 (sig_Dataset 1) TOP1_PLUS100");
    assertNull(edge);
}
Also used : PostAnalysisParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters) PostAnalysisFilterParameters(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters) CyEdge(org.cytoscape.model.CyEdge) Test(org.junit.Test)

Aggregations

PostAnalysisFilterParameters (org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterParameters)8 PostAnalysisParameters (org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters)6 CyEdge (org.cytoscape.model.CyEdge)5 Test (org.junit.Test)5 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)2 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)2 CyNode (org.cytoscape.model.CyNode)2 Map (java.util.Map)1 JFrame (javax.swing.JFrame)1 EdgeSimilarities (org.baderlab.csplugins.enrichmentmap.EdgeSimilarities)1 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)1 GenesetSimilarity (org.baderlab.csplugins.enrichmentmap.model.GenesetSimilarity)1 PostAnalysisFilterType (org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterType)1 UniverseType (org.baderlab.csplugins.enrichmentmap.model.PostAnalysisParameters.UniverseType)1 CreateDiseaseSignatureTaskFactory (org.baderlab.csplugins.enrichmentmap.task.postanalysis.CreateDiseaseSignatureTaskFactory)1 CySwingApplication (org.cytoscape.application.swing.CySwingApplication)1 CyNetwork (org.cytoscape.model.CyNetwork)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1 AbstractTask (org.cytoscape.work.AbstractTask)1 Task (org.cytoscape.work.Task)1