Search in sources :

Example 1 with GMTFileReaderTask

use of org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask in project EnrichmentMapApp by BaderLab.

the class CreateEnrichmentMapTaskFactory method createTaskIterator.

@Override
public TaskIterator createTaskIterator() {
    TaskIterator tasks = new TaskIterator();
    if (dataSets.isEmpty())
        return tasks;
    tasks.append(new TitleTask("Building EnrichmentMap"));
    EnrichmentMap map = new EnrichmentMap(params, serviceRegistrar);
    for (DataSetParameters dataSetParameters : dataSets) {
        String datasetName = dataSetParameters.getName();
        Method method = dataSetParameters.getMethod();
        DataSetFiles files = dataSetParameters.getFiles();
        EMDataSet dataset = map.createDataSet(datasetName, method, files);
        // Load GMT File
        if (!Strings.isNullOrEmpty(dataset.getSetOfGeneSets().getFilename())) {
            tasks.append(new GMTFileReaderTask(dataset));
        }
        // Load the enrichments 
        tasks.append(new DetermineEnrichmentResultFileReader(dataset).getParsers());
        // If there is no expression file then create a dummy file to associate with this dataset so we can still use the expression viewer (heat map)
        if (Strings.isNullOrEmpty(dataset.getDataSetFiles().getExpressionFileName())) {
            tasks.append(new CreateDummyExpressionTask(dataset));
        } else {
            tasks.append(new ExpressionFileReaderTask(dataset));
        }
        // Load ranks if present
        String ranksName = dataset.getMethod() == Method.GSEA ? Ranking.GSEARanking : datasetName;
        if (dataset.getExpressionSets().getRanksByName(ranksName) != null) {
            String filename = dataset.getExpressionSets().getRanksByName(ranksName).getFilename();
            tasks.append(new RanksFileReaderTask(filename, dataset, ranksName, false));
        }
        if (!Strings.isNullOrEmpty(dataset.getDataSetFiles().getClassFile())) {
            tasks.append(new ClassFileReaderTask(dataset));
        }
    }
    // NOTE: First filter out genesets that don't pass the thresholds, 
    // Then filter the remaining genesets of interest to only contain genes from the expression file.
    // Filter out genesets that don't pass the p-value and q-value thresholds
    InitializeGenesetsOfInterestTask genesetsTask = new InitializeGenesetsOfInterestTask(map);
    //		genesetsTask.setThrowIfMissing(false); // TEMPORARY
    tasks.append(genesetsTask);
    // Trim the genesets to only contain the genes that are in the data file.
    tasks.append(new FilterGenesetsByDatasetGenes(map));
    // Link the ComputeSimilarityTask to the MasterMapNetworkTask by a "pipe"
    Baton<Map<SimilarityKey, GenesetSimilarity>> pipe = new Baton<>();
    // Compute the geneset similarities
    tasks.append(new ComputeSimilarityTaskParallel(map, pipe.consumer()));
    // Create the network
    tasks.append(createEMNetworkTaskFactory.create(map, pipe.supplier()));
    // Create style and layout
    if (!headless) {
        tasks.append(createEMViewTaskFactory.create(map));
    }
    return tasks;
}
Also used : ClassFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.ClassFileReaderTask) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) GMTFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask) TaskIterator(org.cytoscape.work.TaskIterator) RanksFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.RanksFileReaderTask) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) ExpressionFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.ExpressionFileReaderTask) 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) DetermineEnrichmentResultFileReader(org.baderlab.csplugins.enrichmentmap.parsers.DetermineEnrichmentResultFileReader)

Example 2 with GMTFileReaderTask

use of org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask in project EnrichmentMapApp by BaderLab.

the class LoadGMTFileOnlyTest method testGMTOnly.

@Test
public void testGMTOnly() throws Exception {
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testGmtFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/genesets_subset.gmt";
    DataSetFiles files = new DataSetFiles();
    files.setGMTFileName(testGmtFileName);
    //create an new enrichment Map
    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);
    EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
    //Load data set
    //create a dataset
    EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.GSEA, files);
    //create a DatasetTask
    //set up task
    GMTFileReaderTask task = new GMTFileReaderTask(dataset);
    task.run(taskMonitor);
    dataset.setGeneSetsOfInterest(dataset.getSetOfGeneSets());
    //create dummy expression
    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 36 genesets
    assertEquals(36, dataset.getSetOfGeneSets().getGeneSets().size());
    //there should be (36 * 35)/2 edges (geneset similarities)
    assertEquals(18, baton.supplier().get().size());
    //there should be 523 genes
    assertEquals(523, em.getNumberOfGenes());
    assertEquals(523, dataset.getExpressionSets().getNumGenes());
    assertEquals(523, dataset.getDataSetGenes().size());
    assertEquals(3, dataset.getExpressionSets().getNumConditions());
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) GMTFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask) 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) Test(org.junit.Test)

Example 3 with GMTFileReaderTask

use of org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask 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 4 with GMTFileReaderTask

use of org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask in project EnrichmentMapApp by BaderLab.

the class SetOfGenesetsTest method before.

@Before
public void before(Provider<EnrichmentMapParameters> empFactory) throws Exception {
    //load Genesets from the gmt file associated with this test
    String testDataFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/model/Genesetstestfile.gmt";
    //create a new instance of the parameters
    EnrichmentMapParameters params = empFactory.get();
    //set gmt file name 
    params.getFiles().get(LegacySupport.DATASET1).setGMTFileName(testDataFileName);
    //Create a new Enrichment map
    map = new EnrichmentMap(params.getCreationParameters(), serviceRegistrar);
    Method method = EnrichmentMapParameters.stringToMethod(params.getMethod());
    DataSetFiles files = params.getFiles().get(LegacySupport.DATASET1);
    dataset = map.createDataSet(LegacySupport.DATASET1, method, files);
    //set up task
    GMTFileReaderTask task = new GMTFileReaderTask(dataset);
    task.run(taskMonitor);
}
Also used : Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) GMTFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask) Before(org.junit.Before)

Example 5 with GMTFileReaderTask

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

Aggregations

GMTFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask)7 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)4 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)4 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)4 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)3 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)3 Test (org.junit.Test)3 Map (java.util.Map)2 ExpressionFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.ExpressionFileReaderTask)2 Baton (org.baderlab.csplugins.enrichmentmap.util.Baton)2 TaskIterator (org.cytoscape.work.TaskIterator)2 Before (org.junit.Before)2 SetOfGeneSets (org.baderlab.csplugins.enrichmentmap.model.SetOfGeneSets)1 ClassFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.ClassFileReaderTask)1 DetermineEnrichmentResultFileReader (org.baderlab.csplugins.enrichmentmap.parsers.DetermineEnrichmentResultFileReader)1 ParseEDBEnrichmentResults (org.baderlab.csplugins.enrichmentmap.parsers.ParseEDBEnrichmentResults)1 ParseGSEAEnrichmentResults (org.baderlab.csplugins.enrichmentmap.parsers.ParseGSEAEnrichmentResults)1 RanksFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.RanksFileReaderTask)1 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)1