Search in sources :

Example 21 with DataSetFiles

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

the class LoadDatasetTaskTest method testLoadDataset1GSEAResult_withexpression.

@Test
public void testLoadDataset1GSEAResult_withexpression() throws Exception {
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testGMTFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/gs_apop_mouse.gmt";
    String testExpressionFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/Expressiontestfile.gct";
    String testGSEAResults1FileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_enrichments1.xls";
    String testGSEAResults2FileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/LoadDataset/GSEA_enrichments2.xls";
    DataSetFiles files = new DataSetFiles();
    files.setGMTFileName(testGMTFileName);
    files.setExpressionFileName(testExpressionFileName);
    files.setEnrichmentFileName1(testGSEAResults1FileName);
    files.setEnrichmentFileName2(testGSEAResults2FileName);
    EMCreationParameters params = new EMCreationParameters("EM1_", 0.1, 0.1, NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, 0.1, 0.1);
    //create an new enrichment Map
    EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
    //create a dataset
    EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.Generic, files);
    //load Data
    GMTFileReaderTask task = new GMTFileReaderTask(dataset);
    task.run(taskMonitor);
    ParseGSEAEnrichmentResults enrichmentResultsFilesTask = new ParseGSEAEnrichmentResults(dataset);
    enrichmentResultsFilesTask.run(taskMonitor);
    //load expression file
    ExpressionFileReaderTask exptask = new ExpressionFileReaderTask(dataset);
    exptask.run(taskMonitor);
    //check to see if the dataset loaded
    assertEquals(193, 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) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) GMTFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask) ExpressionFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.ExpressionFileReaderTask) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) ParseGSEAEnrichmentResults(org.baderlab.csplugins.enrichmentmap.parsers.ParseGSEAEnrichmentResults) Test(org.junit.Test)

Example 22 with DataSetFiles

use of org.baderlab.csplugins.enrichmentmap.model.DataSetFiles 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 23 with DataSetFiles

use of org.baderlab.csplugins.enrichmentmap.model.DataSetFiles 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 24 with DataSetFiles

use of org.baderlab.csplugins.enrichmentmap.model.DataSetFiles 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 25 with DataSetFiles

use of org.baderlab.csplugins.enrichmentmap.model.DataSetFiles 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)

Aggregations

DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)33 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)21 Test (org.junit.Test)21 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)20 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)14 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)14 EnrichmentMapParameters (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters)11 Map (java.util.Map)6 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)6 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)5 CyNetwork (org.cytoscape.model.CyNetwork)5 GMTFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask)4 Baton (org.baderlab.csplugins.enrichmentmap.util.Baton)4 ArrayList (java.util.ArrayList)3 ExpressionFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.ExpressionFileReaderTask)3 File (java.io.File)2 Path (java.nio.file.Path)2 HashMap (java.util.HashMap)2 BaseIntegrationTest (org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest)2 SimilarityMetric (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric)2