Search in sources :

Example 16 with EMCreationParameters

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

the class MasterDetailDialogPage method finish.

@Override
public void finish() {
    if (!validateInput())
        return;
    String prefix = legacySupport.getNextAttributePrefix();
    SimilarityMetric similarityMetric = cutoffPanel.getSimilarityMetric();
    double pvalue = cutoffPanel.getPValue();
    double qvalue = cutoffPanel.getQValue();
    NESFilter nesFilter = cutoffPanel.getNESFilter();
    double cutoff = cutoffPanel.getCutoff();
    double combined = cutoffPanel.getCombinedConstant();
    Optional<Integer> minExperiments = cutoffPanel.getMinimumExperiments();
    EMCreationParameters params = new EMCreationParameters(prefix, pvalue, qvalue, nesFilter, minExperiments, similarityMetric, cutoff, combined);
    params.setCreateDistinctEdges(distinctEdgesCheckbox.isSelected());
    List<DataSetParameters> dataSets = dataSetListModel.toList().stream().map(DataSetListItem::getDetailPanel).map(DetailPanel::createDataSetParameters).filter(x -> x != null).collect(Collectors.toList());
    // Overwrite all the expression files if the common file has been provided
    String exprPath = commonPanel.getExpressionFile();
    if (!isNullOrEmpty(exprPath)) {
        for (DataSetParameters dsp : dataSets) {
            dsp.getFiles().setExpressionFileName(exprPath);
        }
    }
    // Overwrite all the gmt files if a common file has been provided
    String gmtPath = commonPanel.getGmtFile();
    if (!isNullOrEmpty(gmtPath)) {
        for (DataSetParameters dsp : dataSets) {
            dsp.getFiles().setGMTFileName(gmtPath);
        }
    }
    CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(params, dataSets);
    TaskIterator tasks = taskFactory.createTaskIterator();
    // Close this dialog after the progress dialog finishes normally
    tasks.append(new AbstractTask() {

        public void run(TaskMonitor taskMonitor) {
            callback.close();
        }
    });
    dialogTaskManager.execute(tasks);
}
Also used : Color(java.awt.Color) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) UIManager(javax.swing.UIManager) Inject(com.google.inject.Inject) IterableListModel(org.baderlab.csplugins.enrichmentmap.view.util.IterableListModel) Border(javax.swing.border.Border) IconManager(org.cytoscape.util.swing.IconManager) FileBrowser(org.baderlab.csplugins.enrichmentmap.view.util.FileBrowser) Map(java.util.Map) FinishStatus(org.cytoscape.work.FinishStatus) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) ResolverTask(org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) LegacySupport(org.baderlab.csplugins.enrichmentmap.model.LegacySupport) BorderFactory(javax.swing.BorderFactory) Component(java.awt.Component) Collectors(java.util.stream.Collectors) List(java.util.List) Stream(java.util.stream.Stream) Alignment(javax.swing.GroupLayout.Alignment) MessageType(org.baderlab.csplugins.enrichmentmap.view.creation.ErrorMessageDialog.MessageType) SwingUtil(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) TaskObserver(org.cytoscape.work.TaskObserver) JPanel(javax.swing.JPanel) ObservableTask(org.cytoscape.work.ObservableTask) ListSelectionModel(javax.swing.ListSelectionModel) CardDialogPage(org.baderlab.csplugins.enrichmentmap.view.util.CardDialogPage) CardLayout(java.awt.CardLayout) JSplitPane(javax.swing.JSplitPane) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles) AbstractTask(org.cytoscape.work.AbstractTask) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) Function(java.util.function.Function) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) TaskIterator(org.cytoscape.work.TaskIterator) ArrayList(java.util.ArrayList) NESFilter(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) TaskMonitor(org.cytoscape.work.TaskMonitor) FlowLayout(java.awt.FlowLayout) Method(org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method) JButton(javax.swing.JButton) Iterator(java.util.Iterator) CardDialogCallback(org.baderlab.csplugins.enrichmentmap.view.util.CardDialogCallback) JList(javax.swing.JList) JOptionPane(javax.swing.JOptionPane) File(java.io.File) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) JScrollPane(javax.swing.JScrollPane) LayoutStyle(javax.swing.LayoutStyle) ListCellRenderer(javax.swing.ListCellRenderer) Provider(com.google.inject.Provider) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) ListModel(javax.swing.ListModel) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) AbstractTask(org.cytoscape.work.AbstractTask) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) NESFilter(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)

Example 17 with EMCreationParameters

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

the class LegendPanel method update.

/**
	 * Update parameters panel based on given enrichment map parameters
	 * @param chartType 
	 */
void update(EMStyleOptions options, Collection<EMDataSet> filteredDataSets) {
    this.options = options;
    CyNetworkView networkView = options != null ? options.getNetworkView() : null;
    removeAll();
    EnrichmentMap map = networkView != null ? emManager.getEnrichmentMap(networkView.getModel().getSUID()) : null;
    EMCreationParameters params = map != null ? map.getParams() : null;
    if (params == null) {
        JLabel infoLabel = new JLabel("No EnrichmentMap View selected");
        infoLabel.setEnabled(false);
        infoLabel.setForeground(UIManager.getColor("Label.disabledForeground"));
        infoLabel.setHorizontalAlignment(JLabel.CENTER);
        infoLabel.setVerticalAlignment(JLabel.CENTER);
        infoLabel.setBorder(new EmptyBorder(120, 40, 120, 40));
        add(infoLabel, BorderLayout.CENTER);
    } else {
        nodeLegendPanel = null;
        nodeColorPanel = null;
        nodeShapePanel = null;
        nodeChartPanel = null;
        edgeLegendPanel = null;
        edgeColorPanel = null;
        updateNodeColorPanel(filteredDataSets, map);
        updateNodeShapePanel(map);
        updateNodeChartPanel(filteredDataSets, map);
        updateEdgeColorPanel(map);
        JPanel panel = new JPanel();
        final GroupLayout layout = new GroupLayout(panel);
        panel.setLayout(layout);
        layout.setAutoCreateContainerGaps(true);
        layout.setAutoCreateGaps(true);
        layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER, true).addComponent(getNodeLegendPanel(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(getEdgeLegendPanel(), DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createSequentialGroup().addComponent(getNodeLegendPanel(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(getEdgeLegendPanel(), PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE));
        JScrollPane scrollPane = new JScrollPane(panel);
        add(scrollPane, BorderLayout.CENTER);
    }
    revalidate();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) GroupLayout(javax.swing.GroupLayout) JLabel(javax.swing.JLabel) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) EmptyBorder(javax.swing.border.EmptyBorder) CyNetworkView(org.cytoscape.view.model.CyNetworkView)

Example 18 with EMCreationParameters

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

the class CreationParametersPanel method getInfoText.

/**
	 * Get the files and parameters corresponding to the current enrichment map
	 */
private String getInfoText() {
    EMCreationParameters params = map.getParams();
    StringWriter writer = new StringWriter();
    new Html(writer) {

        {
            bind("bold", "font-weight: bold;");
            bind("code", "font-family: Courier,monospaced;");
            html().body().style("font-family: Helvetica,Arial,sans-serif; font-size: 1em;");
            ol();
            addTitle("Cut-Off Values");
            ul();
            addCutOffItem("P-value", params.getPvalue());
            addCutOffItem("FDR Q-value", params.getQvalue());
            if (params.getSimilarityMetric() == SimilarityMetric.JACCARD)
                addCutOffItem("Jaccard", params.getSimilarityCutoff(), "Jaccard Index");
            else if (params.getSimilarityMetric() == SimilarityMetric.OVERLAP)
                addCutOffItem("Overlap", params.getSimilarityCutoff(), "Overlap Index");
            else if (params.getSimilarityMetric() == SimilarityMetric.COMBINED)
                addCutOffItem("Jaccard Overlap Combined", params.getSimilarityCutoff(), "Jaccard Overlap Combined Index (k constant = " + params.getCombinedConstant() + ")");
            end();
            addTitle("Data Sets");
            ol();
            for (EMDataSet ds : map.getDataSetList()) addDataSet(ds);
            end();
            end();
            endAll();
            done();
        }

        Html addTitle(String s) {
            return li().style("${bold} font-size: 1.1em;").text(s + ": ").end();
        }

        Html addCutOffItem(String k, Object v) {
            return addCutOffItem(k, v, null);
        }

        Html addCutOffItem(String k, Object v, String test) {
            li().b().text(k + ": ").end().span().style("${code}").text("" + v).end();
            if (test != null)
                br().span().style("${padding}").text("Test used: ").i().text(test).end().end();
            return end();
        }

        Html addDataSet(EMDataSet ds) {
            li().b().text(ds.getName()).end();
            ul();
            li().text("Gene Sets File: ").span().style("${code}").text(shortenPathname(ds.getDataSetFiles().getGMTFileName())).end().end();
            String ef1 = ds.getDataSetFiles().getEnrichmentFileName1();
            String ef2 = ds.getDataSetFiles().getEnrichmentFileName2();
            if (ef1 != null || ef2 != null) {
                li().text("Data Files:");
                if (ef1 != null)
                    br().span().style("${code}").raw(INDENT).text(shortenPathname(ef1)).end();
                if (ef2 != null)
                    br().span().style("${code}").raw(INDENT).text(shortenPathname(ef2)).end();
                end();
            }
            if (ds.getDataSetFiles().getExpressionFileName() != null) {
                li().text("Expression File: ").span().style("${code}").text(shortenPathname(ds.getDataSetFiles().getExpressionFileName())).end().end();
            }
            if (ds.getDataSetFiles().getGseaHtmlReportFile() != null) {
                li().text("GSEA Report: ").span().style("${code}").text(shortenPathname(ds.getDataSetFiles().getGseaHtmlReportFile())).end().end();
            }
            end();
            return end();
        }
    };
    return writer.getBuffer().toString();
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) StringWriter(java.io.StringWriter) Html(com.googlecode.jatl.Html) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Example 19 with EMCreationParameters

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

the class EMGseaCommandTask method buildEnrichmentMap.

private void buildEnrichmentMap() {
    //set all files as extracted from the edb directory
    List<DataSetParameters> dataSets = new ArrayList<>(2);
    DataSetFiles files1 = initializeFiles(edbdir, expressionfile);
    dataSets.add(new DataSetParameters(LegacySupport.DATASET1, Method.GSEA, files1));
    //only add second dataset if there is a second edb directory.
    if (edbdir2 != null && !edbdir2.equalsIgnoreCase("")) {
        DataSetFiles files2 = initializeFiles(edbdir2, expressionfile2);
        dataSets.add(new DataSetParameters(LegacySupport.DATASET2, Method.GSEA, files2));
    }
    SimilarityMetric metric = EnrichmentMapParameters.stringToSimilarityMetric(similaritymetric.getSelectedValue());
    String prefix = legacySupport.getNextAttributePrefix();
    EMCreationParameters creationParams = new EMCreationParameters(prefix, pvalue, qvalue, NESFilter.ALL, Optional.empty(), metric, overlap, combinedconstant);
    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) DataSetFiles(org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)

Example 20 with EMCreationParameters

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

the class ResolverCommandTask method run.

@Override
public void run(TaskMonitor taskMonitor) throws Exception {
    logger.info("Running EnrichmentMap Data Set Resolver Task");
    // Scan root folder (note: throws exception if no data sets were found)
    ResolverTask resolverTask = new ResolverTask(rootFolder);
    // blocks
    taskManager.execute(new TaskIterator(resolverTask));
    List<DataSetParameters> dataSets = resolverTask.getDataSetResults();
    logger.info("resolved " + dataSets.size() + " data sets");
    dataSets.forEach(params -> logger.info(params.toString()));
    // Overwrite all the expression files if the common file has been provided
    if (commonExpressionFile != null) {
        if (!commonExpressionFile.canRead()) {
            throw new IllegalArgumentException("Cannot read commonExpressionFile: " + commonExpressionFile);
        }
        for (DataSetParameters dsp : dataSets) {
            dsp.getFiles().setExpressionFileName(commonExpressionFile.getAbsolutePath());
        }
    }
    // Overwrite all the gmt files if a common file has been provided
    if (commonGMTFile != null) {
        if (!commonGMTFile.canRead()) {
            throw new IllegalArgumentException("Cannot read commonGMTFile: " + commonGMTFile);
        }
        for (DataSetParameters dsp : dataSets) {
            dsp.getFiles().setGMTFileName(commonGMTFile.getAbsolutePath());
        }
    }
    // Create Enrichment Map
    String prefix = legacySupport.getNextAttributePrefix();
    SimilarityMetric sm = SimilarityMetric.valueOf(similarityMetric.getSelectedValue());
    NESFilter nesf = NESFilter.valueOf(nesFilter.getSelectedValue());
    String info = String.format("prefix:%s, pvalue:%f, qvalue:%f, nesFilter:%s, minExperiments:%d, similarityMetric:%s, similarityCutoff:%f, combinedConstant:%f", prefix, pvalue, qvalue, nesf, minExperiments, sm, similarityCutoff, combinedConstant);
    logger.info(info);
    EMCreationParameters params = new EMCreationParameters(prefix, pvalue, qvalue, nesf, Optional.ofNullable(minExperiments), sm, similarityCutoff, combinedConstant);
    params.setCreateDistinctEdges(distinctEdges);
    CreateEnrichmentMapTaskFactory taskFactory = taskFactoryFactory.create(params, dataSets);
    TaskIterator tasks = taskFactory.createTaskIterator();
    taskManager.execute(tasks);
    logger.info("Done.");
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) TaskIterator(org.cytoscape.work.TaskIterator) CreateEnrichmentMapTaskFactory(org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory) DataSetParameters(org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) NESFilter(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter) ResolverTask(org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask)

Aggregations

EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)21 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)15 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)11 Test (org.junit.Test)11 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)9 Map (java.util.Map)4 SimilarityMetric (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric)4 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)4 CreateEnrichmentMapTaskFactory (org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory)4 CyNetwork (org.cytoscape.model.CyNetwork)4 ArrayList (java.util.ArrayList)3 Baton (org.baderlab.csplugins.enrichmentmap.util.Baton)3 GroupLayout (javax.swing.GroupLayout)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 BaseIntegrationTest (org.baderlab.csplugins.enrichmentmap.integration.BaseIntegrationTest)2 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)2 NESFilter (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter)2 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)2