Search in sources :

Example 6 with TaskIterator

use of org.cytoscape.work.TaskIterator in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method removeSignatureDataSets.

private void removeSignatureDataSets(EnrichmentMap map, EMViewControlPanel viewPanel) {
    Set<EMSignatureDataSet> dataSets = viewPanel.getSelectedSignatureDataSets();
    if (!dataSets.isEmpty()) {
        if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(getControlPanel(), "Are you sure you want to remove the selected Signature Gene Sets\nand associated nodes?", "Remove Signature Gene Sets", JOptionPane.YES_NO_OPTION))
            return;
        RemoveSignatureDataSetsTask task = removeDataSetsTaskFactory.create(dataSets, map);
        dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {

            @Override
            public void taskFinished(ObservableTask task) {
            }

            @Override
            public void allFinished(FinishStatus finishStatus) {
                viewPanel.updateDataSetSelector();
                updateLegends(viewPanel);
                viewPanel.getNetworkView().updateView();
            }
        });
    }
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) EMSignatureDataSet(org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet) TaskIterator(org.cytoscape.work.TaskIterator) FinishStatus(org.cytoscape.work.FinishStatus) RemoveSignatureDataSetsTask(org.baderlab.csplugins.enrichmentmap.task.postanalysis.RemoveSignatureDataSetsTask)

Example 7 with TaskIterator

use of org.cytoscape.work.TaskIterator in project EnrichmentMapApp by BaderLab.

the class ControlPanelMediator method applyVisualStyle.

private void applyVisualStyle(EMStyleOptions options, CyCustomGraphics2<?> chart, boolean updateChartOnly) {
    ApplyEMStyleTask task = applyStyleTaskFactory.create(options, chart, updateChartOnly);
    dialogTaskManager.execute(new TaskIterator(task), new TaskObserver() {

        @Override
        public void taskFinished(ObservableTask task) {
        }

        @Override
        public void allFinished(FinishStatus finishStatus) {
            EMViewControlPanel viewPanel = getControlPanel().getViewControlPanel(options.getNetworkView());
            updateLegends(viewPanel);
        }
    });
}
Also used : TaskObserver(org.cytoscape.work.TaskObserver) ObservableTask(org.cytoscape.work.ObservableTask) EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) TaskIterator(org.cytoscape.work.TaskIterator) ApplyEMStyleTask(org.baderlab.csplugins.enrichmentmap.task.ApplyEMStyleTask) FinishStatus(org.cytoscape.work.FinishStatus)

Example 8 with TaskIterator

use of org.cytoscape.work.TaskIterator in project EnrichmentMapApp by BaderLab.

the class CreateEMViewTask method visualizeMap.

private void visualizeMap() {
    CyNetwork network = networkManager.getNetwork(map.getNetworkID());
    CyNetworkView view = networkViewFactory.createNetworkView(network);
    networkViewManager.addNetworkView(view);
    //apply force directed layout
    CyLayoutAlgorithm layout = layoutManager.getLayout("force-directed");
    if (layout == null)
        layout = layoutManager.getDefaultLayout();
    Task styleTask = applyStyleTaskFactory.create(new EMStyleOptions(view, map), null, false);
    TaskIterator layoutTasks = layout.createTaskIterator(view, layout.createLayoutContext(), CyLayoutAlgorithm.ALL_NODE_VIEWS, null);
    TaskIterator moreTasks = new TaskIterator();
    moreTasks.append(styleTask);
    moreTasks.append(layoutTasks);
    insertTasksAfterCurrentTask(moreTasks);
}
Also used : EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) Task(org.cytoscape.work.Task) AbstractTask(org.cytoscape.work.AbstractTask) TaskIterator(org.cytoscape.work.TaskIterator) CyLayoutAlgorithm(org.cytoscape.view.layout.CyLayoutAlgorithm) CyNetwork(org.cytoscape.model.CyNetwork) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 9 with TaskIterator

use of org.cytoscape.work.TaskIterator 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 10 with TaskIterator

use of org.cytoscape.work.TaskIterator in project EnrichmentMapApp by BaderLab.

the class EdgeWidthDialog method createButtonPanel.

private JPanel createButtonPanel() {
    JButton restoreDefaultsButton = new JButton("Restore Defaults");
    restoreDefaultsButton.addActionListener(e -> {
        setTextFieldValues(EdgeWidthParams.defaultValues());
    });
    JButton cancelButton = new JButton(new AbstractAction("Cancel") {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    JButton okButton = new JButton(new AbstractAction("OK") {

        @Override
        public void actionPerformed(ActionEvent e) {
            double emLowerWidth = ((Number) emLowerWidthText.getValue()).doubleValue();
            double emUpperWidth = ((Number) emUpperWidthText.getValue()).doubleValue();
            double lessThan100 = ((Number) lessThan100Text.getValue()).doubleValue();
            double lessThan10 = ((Number) lessThan10Text.getValue()).doubleValue();
            double greaterThan = ((Number) greaterThanText.getValue()).doubleValue();
            EdgeWidthParams params = new EdgeWidthParams(emLowerWidth, emUpperWidth, lessThan100, lessThan10, greaterThan);
            params.save(network);
            Task task = new Task() {

                public void run(TaskMonitor taskMonitor) throws Exception {
                    taskMonitor.setTitle("EnrichmentMap");
                    taskMonitor.setStatusMessage("Calculating Post-Analysis Edge Widths");
                    WidthFunction widthFunction = widthFunctionProvider.get();
                    widthFunction.setEdgeWidths(network, prefix, taskMonitor);
                }

                public void cancel() {
                }
            };
            taskManager.execute(new TaskIterator(task));
            dispose();
        }
    });
    JPanel bottomPanel = LookAndFeelUtil.createOkCancelPanel(okButton, cancelButton, restoreDefaultsButton);
    LookAndFeelUtil.setDefaultOkCancelKeyStrokes(getRootPane(), okButton.getAction(), cancelButton.getAction());
    getRootPane().setDefaultButton(okButton);
    return bottomPanel;
}
Also used : JPanel(javax.swing.JPanel) Task(org.cytoscape.work.Task) TaskIterator(org.cytoscape.work.TaskIterator) ActionEvent(java.awt.event.ActionEvent) TaskMonitor(org.cytoscape.work.TaskMonitor) WidthFunction(org.baderlab.csplugins.enrichmentmap.style.WidthFunction) EdgeWidthParams(org.baderlab.csplugins.enrichmentmap.style.WidthFunction.EdgeWidthParams) JButton(javax.swing.JButton) AbstractAction(javax.swing.AbstractAction)

Aggregations

TaskIterator (org.cytoscape.work.TaskIterator)23 File (java.io.File)7 FinishStatus (org.cytoscape.work.FinishStatus)7 ObservableTask (org.cytoscape.work.ObservableTask)7 TaskObserver (org.cytoscape.work.TaskObserver)7 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)5 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)4 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)4 CyNetwork (org.cytoscape.model.CyNetwork)4 AbstractTask (org.cytoscape.work.AbstractTask)4 ResolverTask (org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask)3 CreateEnrichmentMapTaskFactory (org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory)3 TaskMonitor (org.cytoscape.work.TaskMonitor)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 JButton (javax.swing.JButton)2 JList (javax.swing.JList)2 SerialTestTaskManager (org.baderlab.csplugins.enrichmentmap.SerialTestTaskManager)2