Search in sources :

Example 1 with DataSetParameters

use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.

the class EMBuildCommandTask method buildEnrichmentMap.

/**
	 * buildEnrichmentMap - parses all GSEA input files and creates an enrichment map
	 */
public void buildEnrichmentMap() {
    // Note we must continue to use the old constants from EnrichmentMapParameters for backwards compatibility
    Method method = EnrichmentMapParameters.stringToMethod(analysisType.getSelectedValue());
    SimilarityMetric metric = EnrichmentMapParameters.stringToSimilarityMetric(coeffecients.getSelectedValue());
    //Set Dataset1 Files
    DataSetFiles dataset1files = new DataSetFiles();
    if (gmtFile != null)
        dataset1files.setGMTFileName(gmtFile.getAbsolutePath());
    if (expressionDataset1 != null)
        dataset1files.setExpressionFileName(expressionDataset1.getAbsolutePath());
    if (enrichmentsDataset1 != null)
        dataset1files.setEnrichmentFileName1(enrichmentsDataset1.getAbsolutePath());
    if (enrichments2Dataset1 != null)
        dataset1files.setEnrichmentFileName2(enrichments2Dataset1.getAbsolutePath());
    if (ranksDataset1 != null)
        dataset1files.setRankedFile(ranksDataset1.getAbsolutePath());
    if (classDataset1 != null)
        dataset1files.setClassFile(classDataset1.getAbsolutePath());
    if (phenotype1Dataset1 != null)
        dataset1files.setPhenotype1(phenotype1Dataset1);
    if (phenotype2Dataset1 != null)
        dataset1files.setPhenotype2(phenotype2Dataset1);
    //Set Dataset2 Files
    DataSetFiles dataset2files = new DataSetFiles();
    if (expressionDataset2 != null)
        dataset2files.setExpressionFileName(expressionDataset2.getAbsolutePath());
    if (enrichmentsDataset2 != null)
        dataset2files.setEnrichmentFileName1(enrichmentsDataset2.getAbsolutePath());
    if (enrichments2Dataset2 != null)
        dataset2files.setEnrichmentFileName2(enrichments2Dataset2.getAbsolutePath());
    if (ranksDataset2 != null)
        dataset2files.setRankedFile(ranksDataset2.getAbsolutePath());
    if (classDataset2 != null)
        dataset2files.setClassFile(classDataset2.getAbsolutePath());
    if (phenotype1Dataset2 != null)
        dataset2files.setPhenotype1(phenotype1Dataset2);
    if (phenotype2Dataset2 != null)
        dataset2files.setPhenotype2(phenotype2Dataset2);
    List<DataSetParameters> dataSets = new ArrayList<>(2);
    dataSets.add(new DataSetParameters(LegacySupport.DATASET1, method, dataset1files));
    if (!dataset2files.isEmpty()) {
        dataSets.add(new DataSetParameters(LegacySupport.DATASET2, method, dataset2files));
    }
    String prefix = legacySupport.getNextAttributePrefix();
    EMCreationParameters creationParams = new EMCreationParameters(prefix, pvalue, qvalue, NESFilter.ALL, Optional.empty(), metric, similaritycutoff, propertyManager.getDefaultCombinedConstant());
    if (distinctEdges != null)
        creationParams.setCreateDistinctEdges(distinctEdges);
    else if (!dataset2files.isEmpty())
        creationParams.setCreateDistinctEdges(true);
    CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(creationParams, dataSets);
    insertTasksAfterCurrentTask(taskFactory.createTaskIterator());
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) ArrayList(java.util.ArrayList) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)

Example 2 with DataSetParameters

use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.

the class BaseNetworkTest method buildEnrichmentMap.

protected void buildEnrichmentMap(EMCreationParameters params, DataSetFiles datasetFiles, Method method, String datasetName) {
    List<DataSetParameters> dataSets = Arrays.asList(new DataSetParameters(datasetName, method, datasetFiles));
    CreateEnrichmentMapTaskFactory taskFactory = masterMapTaskFactoryFactory.create(params, dataSets);
    TaskIterator taskIterator = taskFactory.createTaskIterator();
    // make sure the task iterator completes
    TaskObserver observer = new TaskObserver() {

        public void taskFinished(ObservableTask task) {
        }

        public void allFinished(FinishStatus finishStatus) {
            if (finishStatus == null)
                fail();
            if (finishStatus.getType() != FinishStatus.Type.SUCCEEDED)
                throw new AssertionError("TaskIterator Failed", finishStatus.getException());
        }
    };
    SerialTestTaskManager testTaskManager = new SerialTestTaskManager();
    testTaskManager.ignoreTask(CreateEMViewTask.class);
    testTaskManager.execute(taskIterator, observer);
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) SerialTestTaskManager(org.baderlab.csplugins.enrichmentmap.SerialTestTaskManager) TaskIterator(org.cytoscape.work.TaskIterator) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) FinishStatus(org.cytoscape.work.FinishStatus)

Example 3 with DataSetParameters

use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.

the class CreateEnrichmentMapTaskTest method buildEnrichmentMap.

protected void buildEnrichmentMap(EMCreationParameters params, DataSetFiles datasetFiles, String datasetName) {
    List<DataSetParameters> dataSets = Arrays.asList(new DataSetParameters(datasetName, Method.Generic, datasetFiles));
    CreateEnrichmentMapTaskFactory.Factory masterMapTaskFactoryFactory = injector.getInstance(CreateEnrichmentMapTaskFactory.Factory.class);
    CreateEnrichmentMapTaskFactory taskFactory = masterMapTaskFactoryFactory.create(params, dataSets);
    TaskIterator taskIterator = taskFactory.createTaskIterator();
    SerialTestTaskManager taskManager = new SerialTestTaskManager();
    taskManager.execute(taskIterator);
}
Also used : SerialTestTaskManager(org.baderlab.csplugins.enrichmentmap.integration.SerialTestTaskManager) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) TaskIterator(org.cytoscape.work.TaskIterator) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)

Example 4 with DataSetParameters

use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters 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 5 with DataSetParameters

use of org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters in project EnrichmentMapApp by BaderLab.

the class EditDataSetPanel method createDataSetParameters.

@Override
public DataSetParameters createDataSetParameters() {
    String name = nameText.getText().trim();
    Method method = getMethod();
    DataSetFiles files = new DataSetFiles();
    if (!enrichments1Text.isEmpty())
        files.setEnrichmentFileName1(enrichments1Text.getText());
    if (!enrichments2Text.isEmpty() && method == Method.GSEA)
        files.setEnrichmentFileName2(enrichments2Text.getText());
    if (!expressionsText.isEmpty())
        files.setExpressionFileName(expressionsText.getText());
    if (!gmtText.isEmpty())
        files.setGMTFileName(gmtText.getText());
    if (!ranksText.isEmpty())
        files.setRankedFile(ranksText.getText());
    if (!classesText.isEmpty())
        files.setClassFile(classesText.getText());
    String positive = positiveText.getText();
    String negative = negativeText.getText();
    if (!isNullOrEmpty(positive) && !isNullOrEmpty(negative) && classes != null) {
        files.setPhenotype1(positive);
        files.setPhenotype2(negative);
        files.setTemp_class1(classes);
    }
    return new DataSetParameters(name, method, files);
}
Also used : DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)

Aggregations

DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)9 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)6 CreateEnrichmentMapTaskFactory (org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory)5 TaskIterator (org.cytoscape.work.TaskIterator)5 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)4 SimilarityMetric (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric)4 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)2 NESFilter (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter)2 ResolverTask (org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 BorderLayout (java.awt.BorderLayout)1 CardLayout (java.awt.CardLayout)1 Color (java.awt.Color)1 Component (java.awt.Component)1 FlowLayout (java.awt.FlowLayout)1 File (java.io.File)1