Search in sources :

Example 31 with EnrichmentMap

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

the class LoadDavidResultTest method testLoad2DavidResult_withoutexpression.

@Test
public void testLoad2DavidResult_withoutexpression() throws Exception {
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testDavidResultsFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/david_output/12hr_David_Output.txt";
    DataSetFiles files = new DataSetFiles();
    files.setEnrichmentFileName1(testDavidResultsFileName);
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testDavidResultsFileName2 = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/david_output/24hr_David_Output.txt";
    DataSetFiles files2 = new DataSetFiles();
    files2.setEnrichmentFileName1(testDavidResultsFileName2);
    //set the method to David
    double similarityCutoff = 0.25;
    double pvalue = 0.005;
    // 5.0 X 10-3
    double qvalue = 0.005;
    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 first dataset
    //create a dataset
    EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.Specialized, files);
    //create a DatasetTask
    ParseDavidEnrichmentResults enrichmentResultsFilesTask = new ParseDavidEnrichmentResults(dataset);
    enrichmentResultsFilesTask.run(taskMonitor);
    //Load second dataset
    //create a dataset
    EMDataSet dataset2 = em.createDataSet(LegacySupport.DATASET2, Method.Specialized, files2);
    //create a DatasetTask
    ParseDavidEnrichmentResults enrichmentResultsFiles2Task = new ParseDavidEnrichmentResults(dataset2);
    enrichmentResultsFiles2Task.run(taskMonitor);
    // check to see if the two datasets are distinct
    if (!((dataset.getDataSetGenes().containsAll(dataset2.getDataSetGenes())) && (dataset2.getDataSetGenes().containsAll(dataset.getDataSetGenes()))))
        em.setDistinctExpressionSets(true);
    CreateDummyExpressionTask dummyExpressionTask = new CreateDummyExpressionTask(dataset);
    dummyExpressionTask.run(taskMonitor);
    CreateDummyExpressionTask dummyExpressionTask2 = new CreateDummyExpressionTask(dataset2);
    dummyExpressionTask2.run(taskMonitor);
    em.filterGenesets();
    InitializeGenesetsOfInterestTask genesets_init = new InitializeGenesetsOfInterestTask(em);
    genesets_init.run(taskMonitor);
    // check to see if the dataset loaded - there should be 215 genesets
    assertEquals(215, dataset.getSetOfGeneSets().getGeneSets().size());
    // there should also be 215 enrichments (the genesets are built from the txt file)
    assertEquals(215, dataset.getEnrichments().getEnrichments().size());
    // there should be 7 genesets in the enrichments of interest
    assertEquals(7, dataset.getGeneSetsOfInterest().getGeneSets().size());
    // there should be 114 genes in the geneset "acetylation"
    assertEquals(114, em.getDataSet(LegacySupport.DATASET1).getSetOfGeneSets().getGeneSets().get("ACETYLATION").getGenes().size());
    //		assertEquals(114, em.getAllGenesets().get("ACETYLATION").getGenes().size());
    dataset2 = em.getDataSet(LegacySupport.DATASET2);
    // check the stats for dataset2
    // check to see if the dataset loaded - there should be 263 genesets
    assertEquals(263, dataset2.getSetOfGeneSets().getGeneSets().size());
    // there should also be 263 enrichments (the genesets are built from the bgo file)
    assertEquals(263, dataset2.getEnrichments().getEnrichments().size());
    // there should be 0 genesets in the enrichments of interest
    assertEquals(0, dataset2.getGeneSetsOfInterest().getGeneSets().size());
    // make sure the dummy expression has values for all the genes
    assertEquals(367, dataset2.getExpressionSets().getNumGenes());
    assertEquals(367, dataset2.getDataSetGenes().size());
    // there should be 20 edges (2 edges for every node because of the distinct expresison sets)
    // assertEquals((7*6),em.getGenesetSimilarity().size()); there should be a total of 366 genes
    assertEquals(661, em.getNumberOfGenes());
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) ParseDavidEnrichmentResults(org.baderlab.csplugins.enrichmentmap.parsers.ParseDavidEnrichmentResults) Test(org.junit.Test)

Example 32 with EnrichmentMap

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

the class LoadDavidResultTest method testLoadDavidResult_withoutexpression.

@Test
public void testLoadDavidResult_withoutexpression() throws Exception {
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testDavidResultsFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/david_output/12hr_David_Output.txt";
    DataSetFiles files = new DataSetFiles();
    files.setEnrichmentFileName1(testDavidResultsFileName);
    //set the method to David
    double similarityCutoff = 0.25;
    double pvalue = 0.005;
    // 5.0 X 10-3
    double qvalue = 0.005;
    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.Specialized, files);
    //create a DatasetTask
    ParseDavidEnrichmentResults enrichmentResultsFilesTask = new ParseDavidEnrichmentResults(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 215 genesets
    assertEquals(215, dataset.getSetOfGeneSets().getGeneSets().size());
    //there should also be 215 enrichments (the genesets are built from the txt file)
    assertEquals(215, dataset.getEnrichments().getEnrichments().size());
    //there should be 7 genesets in the enrichments of interest
    assertEquals(7, dataset.getGeneSetsOfInterest().getGeneSets().size());
    //there should be 7 * 6 edges
    assertEquals(11, baton.supplier().get().size());
    //there should be a total of 366 genes
    assertEquals(414, em.getNumberOfGenes());
    //there should be 43 genes in the geneset "nucleolus"
    assertEquals(114, em.getAllGeneSets().get("ACETYLATION").getGenes().size());
    //make sure the dummy expression has values for all the genes
    assertEquals(414, dataset.getExpressionSets().getNumGenes());
    assertEquals(414, 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) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Map(java.util.Map) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) ParseDavidEnrichmentResults(org.baderlab.csplugins.enrichmentmap.parsers.ParseDavidEnrichmentResults) Test(org.junit.Test)

Example 33 with EnrichmentMap

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

the class FileReaderTest method testExpression1ReaderNormal.

@Test
public void testExpression1ReaderNormal(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load the test expression file
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/Expressiontestfile.gct";
    //create a new instance of the parameters
    EnrichmentMapParameters params = empFactory.get();
    //set expression file name 
    params.getFiles().get(LegacySupport.DATASET1).setExpressionFileName(testDataFileName);
    //Create a new Enrichment map
    EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
    //get the default dataset
    Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
    DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
    EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
    //in order to load expression data the genes have to be registered with the application
    //make sure that the genes are empty
    assertEquals(0, map.getNumberOfGenes());
    //add the gene to the master list of genes
    map.addGene("GLS");
    map.addGene("PSMA1");
    map.addGene("ZP1");
    map.addGene("ZYX");
    //make sure all four genes have been associated
    assertEquals(4, map.getNumberOfGenes());
    //load expression file
    ExpressionFileReaderTask task = new ExpressionFileReaderTask(dataset);
    task.run(taskMonitor);
    //There was one more gene in the expression file that wasn't in the set of genes
    //make sure it was was added
    assertEquals(4, map.getNumberOfGenes());
    assertEquals(4, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumGenes());
    assertEquals(59, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumConditions());
    assertEquals(0.008720342, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMinExpression(), 0.0);
    assertEquals(5.131481026, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMaxExpression(), 0.0);
}
Also used : EnrichmentMapParameters(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) Test(org.junit.Test)

Example 34 with EnrichmentMap

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

the class FileReaderTest method testBingoEnrichmentsReader.

//test Bingo enrichment results
@Test
public void testBingoEnrichmentsReader(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load the test enrichment files - Bingo
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/BingoResults.bgo";
    //create a new instance of the parameters
    EnrichmentMapParameters params = empFactory.get();
    //set enrichment file name 
    params.getFiles().get(LegacySupport.DATASET1).setEnrichmentFileName1(testDataFileName);
    //Create a new Enrichment map
    EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
    //get the default dataset
    Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
    DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
    EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
    ParseBingoEnrichmentResults task = new ParseBingoEnrichmentResults(dataset);
    task.run(taskMonitor);
    //Get the enrichment
    Map<String, EnrichmentResult> enrichments = map.getDataSet(LegacySupport.DATASET1).getEnrichments().getEnrichments();
    assertEquals(74, enrichments.size());
    //check p-values
    assertEquals(0.0010354, ((GenericResult) enrichments.get("NUCLEOLAR PART")).getPvalue(), 0.0);
    //check fdr value
    assertEquals(0.047796, ((GenericResult) enrichments.get("NUCLEOLAR PART")).getFdrqvalue(), 0.0);
    //check geneset siz
    assertEquals(5, ((GenericResult) enrichments.get("NUCLEOLAR PART")).getGsSize());
    //check p-values
    assertEquals(0.0000000000016209, ((GenericResult) enrichments.get("NUCLEOLUS")).getPvalue(), 0.0);
    //check fdr value
    assertEquals(0.0000000042203, ((GenericResult) enrichments.get("NUCLEOLUS")).getFdrqvalue(), 0.0);
    //check geneset siz
    assertEquals(43, ((GenericResult) enrichments.get("NUCLEOLUS")).getGsSize());
}
Also used : EnrichmentResult(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult) EnrichmentMapParameters(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) Test(org.junit.Test)

Example 35 with EnrichmentMap

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

the class FileReaderTest method testExpression1ReaderCommentLines.

@Test
public void testExpression1ReaderCommentLines(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load the test expression file
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/Expressiontestfile_comments.gct";
    //create a new instance of the parameters
    EnrichmentMapParameters params = empFactory.get();
    //set gmt file name 
    params.getFiles().get(LegacySupport.DATASET1).setExpressionFileName(testDataFileName);
    //Create a new Enrichment map
    EnrichmentMap map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
    //get the default dataset
    Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
    DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
    EMDataSet dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
    //make sure that the genes are empty
    assertEquals(0, map.getNumberOfGenes());
    //add the gene to the master list of genes
    map.addGene("GLS");
    map.addGene("PSMA1");
    map.addGene("ZP1");
    map.addGene("ZYX");
    //make sure all four genes have been associated
    assertEquals(4, map.getNumberOfGenes());
    //load expression file
    ExpressionFileReaderTask task = new ExpressionFileReaderTask(dataset);
    task.run(taskMonitor);
    //There was one more gene in the expression file that wasn't in the set of genes
    //make sure it was was added
    assertEquals(4, map.getNumberOfGenes());
    assertEquals(5.131481026, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMaxExpression(), 0.0);
    assertEquals(4, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumGenes());
    assertEquals(59, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getNumConditions());
    assertEquals(0.008720342, map.getDataSet(LegacySupport.DATASET1).getExpressionSets().getMinExpression(), 0.0);
}
Also used : EnrichmentMapParameters(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) Test(org.junit.Test)

Aggregations

EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)57 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)27 Test (org.junit.Test)22 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)21 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)13 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)13 CyNetwork (org.cytoscape.model.CyNetwork)12 EnrichmentMapParameters (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters)11 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)10 CyNetworkView (org.cytoscape.view.model.CyNetworkView)10 Map (java.util.Map)8 CyEdge (org.cytoscape.model.CyEdge)7 CyRow (org.cytoscape.model.CyRow)7 NullTaskMonitor (org.baderlab.csplugins.enrichmentmap.util.NullTaskMonitor)6 TaskIterator (org.cytoscape.work.TaskIterator)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 HashSet (java.util.HashSet)5 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)5 Inject (com.google.inject.Inject)4 ActionEvent (java.awt.event.ActionEvent)4