Search in sources :

Example 1 with ClassFileReaderTask

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

Aggregations

Map (java.util.Map)1 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)1 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)1 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)1 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)1 ClassFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.ClassFileReaderTask)1 DetermineEnrichmentResultFileReader (org.baderlab.csplugins.enrichmentmap.parsers.DetermineEnrichmentResultFileReader)1 ExpressionFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.ExpressionFileReaderTask)1 GMTFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask)1 RanksFileReaderTask (org.baderlab.csplugins.enrichmentmap.parsers.RanksFileReaderTask)1 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)1 Baton (org.baderlab.csplugins.enrichmentmap.util.Baton)1 TaskIterator (org.cytoscape.work.TaskIterator)1