Search in sources :

Example 6 with EMCreationParameters

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

the class LoadEdbDatasetTest method testEdbLoad.

@Test
public void testEdbLoad() throws Exception {
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testEdbResultsFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_example_results/edb/results.edb";
    String testgmtFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_example_results/edb/gene_sets.gmt";
    String testrnkFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_example_results/edb/Expressionfile.rnk";
    DataSetFiles files = new DataSetFiles();
    files.setEnrichmentFileName1(testEdbResultsFileName);
    files.setGMTFileName(testgmtFileName);
    files.setRankedFile(testrnkFileName);
    //set the method to gsea
    double similarityCutoff = 0.5;
    double pvalue = 1.0;
    double qvalue = 1.0;
    EMCreationParameters params = new EMCreationParameters("EM1_", pvalue, qvalue, NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, similarityCutoff, 0.5);
    //create an new enrichment Map
    EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
    //Load data set
    //create a dataset
    EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.GSEA, files);
    //create a DatasetTask
    //create a DatasetTask
    //load Data
    GMTFileReaderTask task = new GMTFileReaderTask(dataset);
    task.run(taskMonitor);
    ParseEDBEnrichmentResults enrichmentResultsFilesTask = new ParseEDBEnrichmentResults(dataset);
    enrichmentResultsFilesTask.run(taskMonitor);
    //create dummy expression
    CreateDummyExpressionTask dummyExpressionTask = new CreateDummyExpressionTask(dataset);
    dummyExpressionTask.run(taskMonitor);
    em.filterGenesets();
    InitializeGenesetsOfInterestTask genesets_init = new InitializeGenesetsOfInterestTask(em);
    genesets_init.run(taskMonitor);
    //check to see if the dataset loaded
    //although the original analysis had 193 genesets because this is loaded from
    //edb version it only stores the genesets that overlapped with the dataset analyzed.
    assertEquals(14, dataset.getSetOfGeneSets().getGeneSets().size());
    assertEquals(14, dataset.getEnrichments().getEnrichments().size());
    assertEquals(41, dataset.getDataSetGenes().size());
    assertEquals(41, dataset.getExpressionSets().getNumGenes());
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) ParseEDBEnrichmentResults(org.baderlab.csplugins.enrichmentmap.parsers.ParseEDBEnrichmentResults) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) GMTFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) Test(org.junit.Test)

Example 7 with EMCreationParameters

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

the class LegacySessionLoadTest method test_1_LoadedLegacyData.

@Test
@SessionFile("em_session_2.2.cys")
public void test_1_LoadedLegacyData() throws Exception {
    EnrichmentMap map = getEnrichmentMap();
    assertEquals("EM1_Enrichment Map", map.getName());
    CyNetwork network = networkManager.getNetwork(map.getNetworkID());
    assertNotNull(network);
    assertEquals(1, map.getDataSetCount());
    assertEquals(14067, map.getNumberOfGenes());
    assertEquals(14067, map.getAllGenes().size());
    // Number of edges: 3339 - that's how many geneset similarity objects there should be!!!
    CyTable edgeTable = network.getDefaultEdgeTable();
    assertEquals(3339, edgeTable.getRowCount());
    EMCreationParameters params = map.getParams();
    String prefix = params.getAttributePrefix();
    assertEquals("EM1_", prefix);
    assertEquals(0.5, params.getCombinedConstant(), 0.0);
    assertFalse(params.isEMgmt());
    assertEquals("Geneset_Overlap", params.getEnrichmentEdgeType());
    assertTrue(params.isFDR());
    assertEquals(GreatFilter.HYPER, params.getGreatFilter());
    assertEquals(0.005, params.getPvalue(), 0.0);
    assertEquals(1.0, params.getPvalueMin(), 0.0);
    assertEquals(0.1, params.getQvalue(), 0.0);
    assertEquals(1.0, params.getQvalueMin(), 0.0);
    assertEquals(0.5, params.getSimilarityCutoff(), 0.0);
    assertEquals(SimilarityMetric.OVERLAP, params.getSimilarityMetric());
    //		assertFalse(params.isDistinctExpressionSets());
    String geneset1 = "RESOLUTION OF SISTER CHROMATID COHESION%REACTOME%REACT_150425.2";
    String geneset2 = "CHROMOSOME, CENTROMERIC REGION%GO%GO:0000775";
    Collection<CyRow> rows = edgeTable.getMatchingRows(CyNetwork.NAME, geneset1 + " (Geneset_Overlap) " + geneset2);
    assertEquals(1, rows.size());
    CyRow row = rows.iterator().next();
    assertEquals("Geneset_Overlap", row.get(CyEdge.INTERACTION, String.class));
    assertEquals(0.6097560975609756, EMStyleBuilder.Columns.EDGE_SIMILARITY_COEFF.get(row, prefix), 0.0);
    EMDataSet dataset = map.getDataSet("Dataset 1");
    assertNotNull(dataset);
    assertSame(map, dataset.getMap());
    assertEquals(Method.GSEA, dataset.getMethod());
    assertEquals(12653, dataset.getDataSetGenes().size());
    assertEquals(389, dataset.getGeneSetsOfInterest().getGeneSets().size());
    //		assertEquals(17259, dataset.getSetofgenesets().getGenesets().size()); // MKTODO why? what is this used for
    assertEndsWith(dataset.getSetOfGeneSets().getFilename(), "Human_GO_AllPathways_no_GO_iea_April_15_2013_symbol.gmt");
    for (long suid : dataset.getNodeSuids()) {
        assertNotNull(network.getNode(suid));
    }
    GeneSet geneset = dataset.getGeneSetsOfInterest().getGeneSets().get("NCRNA PROCESSING%GO%GO:0034470");
    assertEquals(88, geneset.getGenes().size());
    assertEquals("NCRNA PROCESSING%GO%GO:0034470", geneset.getName());
    assertEquals("ncRNA processing", geneset.getDescription());
    assertEquals(Optional.of("GO"), geneset.getSource());
    SetOfEnrichmentResults enrichments = dataset.getEnrichments();
    assertEquals(4756, enrichments.getEnrichments().size());
    assertEndsWith(enrichments.getFilename1(), "gsea_report_for_ES12_1473194913081.xls");
    assertEndsWith(enrichments.getFilename2(), "gsea_report_for_NT12_1473194913081.xls");
    assertEquals("ES12", enrichments.getPhenotype1());
    assertEquals("NT12", enrichments.getPhenotype2());
    EnrichmentResult result = enrichments.getEnrichments().get("RIBONUCLEOSIDE TRIPHOSPHATE BIOSYNTHETIC PROCESS%GO%GO:0009201");
    assertTrue(result instanceof GSEAResult);
    GSEAResult gseaResult = (GSEAResult) result;
    assertEquals("RIBONUCLEOSIDE TRIPHOSPHATE BIOSYNTHETIC PROCESS%GO%GO:0009201", gseaResult.getName());
    assertEquals(0.42844063, gseaResult.getES(), 0.0);
    assertEquals(0.45225498, gseaResult.getFdrqvalue(), 0.0);
    assertEquals(1.0, gseaResult.getFwerqvalue(), 0.0);
    assertEquals(23, gseaResult.getGsSize());
    assertEquals(1.1938541, gseaResult.getNES(), 0.0);
    assertEquals(0.2457786, gseaResult.getPvalue(), 0.0);
    assertEquals(4689, gseaResult.getRankAtMax());
    assertEquals(Optional.of("GO"), gseaResult.getSource());
    GeneExpressionMatrix expressions = dataset.getExpressionSets();
    assertEquals(20326, expressions.getExpressionUniverse());
    assertEquals(3.686190609, expressions.getClosesttoZero(), 0.0);
    //		assertEndsWith(expressions.getFilename(), "MCF7_ExprMx_v2_names.gct");
    assertEquals(15380.42388, expressions.getMaxExpression(), 0.0);
    assertEquals(3.686190609, expressions.getMinExpression(), 0.0);
    assertEquals(20, expressions.getNumConditions());
    assertEquals(12653, expressions.getExpressionMatrix().size());
    assertEquals(12653, expressions.getExpressionMatrix_rowNormalized().size());
    GeneExpression expression = expressions.getExpressionMatrix().get(0);
    assertEquals("MOCOS", expression.getName());
    assertEquals("MOCOS (molybdenum cofactor sulfurase)", expression.getDescription());
    assertEquals(18, expression.getExpression().length);
    Ranking ranking = expressions.getRanks().get("GSEARanking");
    assertEquals(12653, ranking.getAllRanks().size());
    assertEquals(12653, ranking.getRanking().size());
    Rank rank = ranking.getRanking().get(0);
    assertEquals("MOCOS", rank.getName());
    assertEquals(1238, rank.getRank().intValue());
    assertEquals(0.54488367, rank.getScore(), 0.0);
    DataSetFiles files = dataset.getDataSetFiles();
    assertEndsWith(files.getClassFile(), "ES_NT.cls");
    assertEndsWith(files.getEnrichmentFileName1(), "gsea_report_for_ES12_1473194913081.xls");
    assertEndsWith(files.getEnrichmentFileName2(), "gsea_report_for_NT12_1473194913081.xls");
    //		assertEndsWith(files.getExpressionFileName(), "MCF7_ExprMx_v2_names.gct");
    assertEndsWith(files.getGMTFileName(), "Human_GO_AllPathways_no_GO_iea_April_15_2013_symbol.gmt");
    assertEndsWith(files.getGseaHtmlReportFile(), "estrogen_treatment_12hr_gsea_enrichment_results.Gsea.1473194913081/index.html");
    assertEndsWith(files.getRankedFile(), "ranked_gene_list_ES12_versus_NT12_1473194913081.xls");
    assertEquals("ES12", files.getPhenotype1());
    assertEquals("NT12", files.getPhenotype2());
}
Also used : EnrichmentResult(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) GSEAResult(org.baderlab.csplugins.enrichmentmap.model.GSEAResult) CyNetwork(org.cytoscape.model.CyNetwork) Rank(org.baderlab.csplugins.enrichmentmap.model.Rank) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CyRow(org.cytoscape.model.CyRow) GeneExpressionMatrix(org.baderlab.csplugins.enrichmentmap.model.GeneExpressionMatrix) CyTable(org.cytoscape.model.CyTable) Ranking(org.baderlab.csplugins.enrichmentmap.model.Ranking) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) GeneSet(org.baderlab.csplugins.enrichmentmap.model.GeneSet) GeneExpression(org.baderlab.csplugins.enrichmentmap.model.GeneExpression) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) SetOfEnrichmentResults(org.baderlab.csplugins.enrichmentmap.model.SetOfEnrichmentResults) BaseIntegrationTest(org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest) Test(org.junit.Test) SessionFile(org.baderlab.csplugins.enrichmentmap.integration.SessionFile)

Example 8 with EMCreationParameters

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

the class CreateEnrichmentMapTaskTest method testEnrichmentMapBuildMapTask.

@Test
public void testEnrichmentMapBuildMapTask() throws Exception {
    String geneSetsFile = TestUtils.createTempFile(PATH, "gene_sets.gmt").getAbsolutePath();
    String expressionFile = TestUtils.createTempFile(PATH, "FakeExpression.txt").getAbsolutePath();
    String enrichmentFile = TestUtils.createTempFile(PATH, "fakeEnrichments.txt").getAbsolutePath();
    String rankFile = TestUtils.createTempFile(PATH, "FakeRank.rnk").getAbsolutePath();
    PropertyManager pm = new PropertyManager();
    EMCreationParameters params = new EMCreationParameters("EM1_", pm.getDefaultPvalue(), pm.getDefaultQvalue(), NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, pm.getDefaultJaccardCutOff(), pm.getDefaultCombinedConstant());
    DataSetFiles dataset1files = new DataSetFiles();
    dataset1files.setGMTFileName(geneSetsFile);
    dataset1files.setExpressionFileName(expressionFile);
    dataset1files.setEnrichmentFileName1(enrichmentFile);
    dataset1files.setRankedFile(rankFile);
    buildEnrichmentMap(params, dataset1files, 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"));
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) PropertyManager(org.baderlab.csplugins.enrichmentmap.PropertyManager) CyNetwork(org.cytoscape.model.CyNetwork) CyNode(org.cytoscape.model.CyNode) EdgeSimilarities(org.baderlab.csplugins.enrichmentmap.integration.EdgeSimilarities) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) BaseIntegrationTest(org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest) Test(org.junit.Test)

Example 9 with EMCreationParameters

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

the class CreateEMNetworkTask method setGSEAResultNodeAttributes.

private void setGSEAResultNodeAttributes(CyRow row, String datasetName, GSEAResult result) {
    Columns.NODE_PVALUE.set(row, prefix, datasetName, result.getPvalue());
    Columns.NODE_FDR_QVALUE.set(row, prefix, datasetName, result.getFdrqvalue());
    Columns.NODE_FWER_QVALUE.set(row, prefix, datasetName, result.getFwerqvalue());
    Columns.NODE_ES.set(row, prefix, datasetName, result.getES());
    Columns.NODE_NES.set(row, prefix, datasetName, result.getNES());
    Columns.NODE_COLOURING.set(row, prefix, datasetName, getColorScore(result));
    EMCreationParameters params = map.getParams();
    params.addPValueColumnName(Columns.NODE_PVALUE.with(prefix, datasetName));
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)

Example 10 with EMCreationParameters

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

the class LoadBingoResultsTest method testLoadBingoResult_withoutexpression.

@Test
public void testLoadBingoResult_withoutexpression() throws Exception {
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testBingoResultsFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/bingo_output/12Hr_topgenes.bgo";
    DataSetFiles files = new DataSetFiles();
    files.setEnrichmentFileName1(testBingoResultsFileName);
    //set the method to Bingo
    double pvalue = 0.00005;
    // 5.0 X 10-8
    double qvaule = 0.00000005;
    double similarityCutoff = 0.25;
    EMCreationParameters params = new EMCreationParameters("EM1_", pvalue, qvaule, NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, similarityCutoff, 0.5);
    //create an new enrichment Map
    EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
    EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.Specialized, files);
    ParseBingoEnrichmentResults enrichmentResultsFilesTask = new ParseBingoEnrichmentResults(dataset);
    enrichmentResultsFilesTask.run(taskMonitor);
    CreateDummyExpressionTask dummyExpressionTask = new CreateDummyExpressionTask(dataset);
    dummyExpressionTask.run(taskMonitor);
    em.filterGenesets();
    InitializeGenesetsOfInterestTask genesets_init = new InitializeGenesetsOfInterestTask(em);
    genesets_init.run(taskMonitor);
    Baton<Map<SimilarityKey, GenesetSimilarity>> baton = new Baton<>();
    ComputeSimilarityTaskParallel similarities = new ComputeSimilarityTaskParallel(em, baton.consumer());
    similarities.run(taskMonitor);
    //check to see if the dataset loaded - there should be 74 genesets
    assertEquals(74, dataset.getSetOfGeneSets().getGeneSets().size());
    //there should also be 74 enrichments (the genesets are built from the bgo file)
    assertEquals(74, dataset.getEnrichments().getEnrichments().size());
    //there should be 11 genesets in the enrichments of interest
    assertEquals(5, dataset.getGeneSetsOfInterest().getGeneSets().size());
    //there should be 6 edges
    assertEquals(6, baton.supplier().get().size());
    //there should be a total of 366 genes
    assertEquals(446, em.getNumberOfGenes());
    //there should be 43 genes in the geneset "nucleolus"
    assertEquals(43, em.getAllGeneSets().get("NUCLEOLUS").getGenes().size());
    //make sure the dummy expression has values for all the genes
    assertEquals(446, dataset.getExpressionSets().getNumGenes());
    assertEquals(446, dataset.getDataSetGenes().size());
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) Baton(org.baderlab.csplugins.enrichmentmap.util.Baton) ParseBingoEnrichmentResults(org.baderlab.csplugins.enrichmentmap.parsers.ParseBingoEnrichmentResults) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Map(java.util.Map) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) Test(org.junit.Test)

Aggregations

EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)21 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)15 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)11 Test (org.junit.Test)11 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)9 Map (java.util.Map)4 SimilarityMetric (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric)4 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)4 CreateEnrichmentMapTaskFactory (org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory)4 CyNetwork (org.cytoscape.model.CyNetwork)4 ArrayList (java.util.ArrayList)3 Baton (org.baderlab.csplugins.enrichmentmap.util.Baton)3 GroupLayout (javax.swing.GroupLayout)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 BaseIntegrationTest (org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest)2 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)2 NESFilter (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter)2 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)2