Search in sources :

Example 36 with EnrichmentMap

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

the class ControlPanelMediator method reset.

public void reset(ViewParams params) {
    long netViewID = params.getNetworkViewID();
    invokeOnEDT(() -> {
        EMViewControlPanel viewPanel = getControlPanel().getViewControlPanel(netViewID);
        if (viewPanel == null)
            return;
        EnrichmentMap map = emManager.getEnrichmentMap(viewPanel.getNetworkView().getModel().getSUID());
        if (map == null)
            return;
        try {
            // Update Filters
            if (params.getPValue() != null && viewPanel.getPValueSliderPanel() != null)
                viewPanel.getPValueSliderPanel().setValue(params.getPValue());
            if (params.getQValue() != null && viewPanel.getQValueSliderPanel() != null)
                viewPanel.getQValueSliderPanel().setValue(params.getQValue());
            if (params.getSimilarityCoefficient() != null && viewPanel.getSimilaritySliderPanel() != null)
                viewPanel.getSimilaritySliderPanel().setValue(params.getSimilarityCoefficient());
            if (params.getNodeCutoffParam() == CutoffParam.P_VALUE)
                viewPanel.getPValueRadio().doClick();
            else if (params.getNodeCutoffParam() == CutoffParam.Q_VALUE)
                viewPanel.getQValueRadio().doClick();
            Set<String> filteredOutDataSetNames = params.getFilteredOutDataSets();
            if (filteredOutDataSetNames != null && !filteredOutDataSetNames.isEmpty()) {
                Set<AbstractDataSet> allDataSets = viewPanel.getAllDataSets();
                Set<AbstractDataSet> filteredDataSets = allDataSets.stream().filter(ds -> !filteredOutDataSetNames.contains(ds.getName())).collect(Collectors.toSet());
                viewPanel.getDataSetSelector().setCheckedItems(filteredDataSets);
            }
            // Update Style options
            ChartOptions chartOptions = params.getChartOptions();
            viewPanel.getChartDataCombo().setSelectedItem(chartOptions != null ? chartOptions.getData() : null);
            viewPanel.getChartTypeCombo().setSelectedItem(chartOptions != null ? chartOptions.getType() : null);
            viewPanel.getChartColorsCombo().setSelectedItem(chartOptions != null ? chartOptions.getColorScheme() : null);
            viewPanel.getShowChartLabelsCheck().setSelected(chartOptions != null && chartOptions.isShowLabels());
            viewPanel.getPublicationReadyCheck().setSelected(params.isPublicationReady());
            viewPanel.updateChartDataCombo();
            updateVisualStyle(map, viewPanel);
            filterNodesAndEdges(viewPanel, map);
        } finally {
            updating = false;
        }
    });
}
Also used : EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) ViewParams(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) SliderBarPanel(org.baderlab.csplugins.enrichmentmap.view.util.SliderBarPanel) CyCustomGraphics2(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) CyNetwork(org.cytoscape.model.CyNetwork) Map(java.util.Map) SetCurrentNetworkViewEvent(org.cytoscape.application.events.SetCurrentNetworkViewEvent) LegendPanelMediator(org.baderlab.csplugins.enrichmentmap.view.legend.LegendPanelMediator) FinishStatus(org.cytoscape.work.FinishStatus) JComboBox(javax.swing.JComboBox) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) EDGE_DATASET_VALUE_COMPOUND(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_DATASET_VALUE_COMPOUND) Timer(javax.swing.Timer) EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) Columns(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns) ItemEvent(java.awt.event.ItemEvent) EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) NetworkViewAboutToBeDestroyedListener(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedListener) Collection(java.util.Collection) SetCurrentNetworkViewListener(org.cytoscape.application.events.SetCurrentNetworkViewListener) Set(java.util.Set) CyNetworkManager(org.cytoscape.model.CyNetworkManager) FilterMode(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask.FilterMode) Collectors(java.util.stream.Collectors) NODE_GS_TYPE(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NODE_GS_TYPE) ColorScheme(org.baderlab.csplugins.enrichmentmap.style.ColorScheme) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) ColumnDescriptor(org.baderlab.csplugins.enrichmentmap.style.ColumnDescriptor) List(java.util.List) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) RemoveSignatureDataSetsTask(org.baderlab.csplugins.enrichmentmap.task.postanalysis.RemoveSignatureDataSetsTask) TaskObserver(org.cytoscape.work.TaskObserver) CyNetworkViewManager(org.cytoscape.view.model.CyNetworkViewManager) ApplyEMStyleTask(org.baderlab.csplugins.enrichmentmap.task.ApplyEMStyleTask) ObservableTask(org.cytoscape.work.ObservableTask) Singleton(com.google.inject.Singleton) ActionListener(java.awt.event.ActionListener) VisualStyle(org.cytoscape.view.vizmap.VisualStyle) EDGE_INTERACTION_VALUE_SIG(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.EDGE_INTERACTION_VALUE_SIG) CyNode(org.cytoscape.model.CyNode) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) NetworkViewAboutToBeDestroyedEvent(org.cytoscape.view.model.events.NetworkViewAboutToBeDestroyedEvent) HashMap(java.util.HashMap) Action(javax.swing.Action) TaskIterator(org.cytoscape.work.TaskIterator) HashSet(java.util.HashSet) FilterNodesEdgesTask(org.baderlab.csplugins.enrichmentmap.task.FilterNodesEdgesTask) CyRow(org.cytoscape.model.CyRow) JMenuItem(javax.swing.JMenuItem) PostAnalysisPanelMediator(org.baderlab.csplugins.enrichmentmap.view.postanalysis.PostAnalysisPanelMediator) ShowEnrichmentMapDialogAction(org.baderlab.csplugins.enrichmentmap.actions.ShowEnrichmentMapDialogAction) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions) NetworkViewAddedListener(org.cytoscape.view.model.events.NetworkViewAddedListener) CyTable(org.cytoscape.model.CyTable) NetworkViewAddedEvent(org.cytoscape.view.model.events.NetworkViewAddedEvent) Properties(java.util.Properties) CyCustomGraphics2Factory(org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2Factory) JPopupMenu(javax.swing.JPopupMenu) CyColumnIdentifier(org.cytoscape.view.presentation.property.values.CyColumnIdentifier) EnrichmentMapManager(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapManager) JOptionPane(javax.swing.JOptionPane) CutoffParam(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams.CutoffParam) ActionEvent(java.awt.event.ActionEvent) CytoPanel(org.cytoscape.application.swing.CytoPanel) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) DialogTaskManager(org.cytoscape.work.swing.DialogTaskManager) CytoPanelComponent(org.cytoscape.application.swing.CytoPanelComponent) Provider(com.google.inject.Provider) EdgeWidthDialog(org.baderlab.csplugins.enrichmentmap.view.postanalysis.EdgeWidthDialog) NODE_GS_TYPE_ENRICHMENT(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder.Columns.NODE_GS_TYPE_ENRICHMENT) ForkJoinPool(java.util.concurrent.ForkJoinPool) ChartUtil(org.baderlab.csplugins.enrichmentmap.view.util.ChartUtil) ChartFactoryManager(org.baderlab.csplugins.enrichmentmap.style.ChartFactoryManager) CyNetworkView(org.cytoscape.view.model.CyNetworkView) CyColumnIdentifierFactory(org.cytoscape.view.presentation.property.values.CyColumnIdentifierFactory) EMSignatureDataSet(org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet) CyEdge(org.cytoscape.model.CyEdge) WidthFunction(org.baderlab.csplugins.enrichmentmap.style.WidthFunction) Collections(java.util.Collections) SwingUtil.invokeOnEDT(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil.invokeOnEDT) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions)

Example 37 with EnrichmentMap

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

the class ControlPanelMediator method createStyleOptions.

public EMStyleOptions createStyleOptions(CyNetworkView netView) {
    EnrichmentMap map = netView != null ? emManager.getEnrichmentMap(netView.getModel().getSUID()) : null;
    EMViewControlPanel viewPanel = getControlPanel().getViewControlPanel(netView);
    return createStyleOptions(map, viewPanel);
}
Also used : EMViewControlPanel(org.baderlab.csplugins.enrichmentmap.view.control.ControlPanel.EMViewControlPanel) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)

Example 38 with EnrichmentMap

use of org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap 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 39 with EnrichmentMap

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

the class LegendPanelMediator method showCreationParamsDialog.

@SuppressWarnings("serial")
private void showCreationParamsDialog() {
    JDialog d = new JDialog(dialog, "EnrichmentMap Creation Parameters", ModalityType.APPLICATION_MODAL);
    d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    d.setMinimumSize(new Dimension(420, 260));
    d.setPreferredSize(new Dimension(580, 460));
    JButton closeButton = new JButton(new AbstractAction("Close") {

        @Override
        public void actionPerformed(ActionEvent e) {
            d.dispose();
        }
    });
    JPanel bottomPanel = LookAndFeelUtil.createOkCancelPanel(null, closeButton);
    d.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
    CyNetworkView netView = legendPanelProvider.get().getOptions().getNetworkView();
    if (netView != null) {
        EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
        CreationParametersPanel paramsPanel = new CreationParametersPanel(map);
        d.getContentPane().add(paramsPanel, BorderLayout.CENTER);
    }
    LookAndFeelUtil.setDefaultOkCancelKeyStrokes(d.getRootPane(), null, closeButton.getAction());
    d.getRootPane().setDefaultButton(closeButton);
    d.setLocationRelativeTo(dialog);
    d.pack();
    d.setVisible(true);
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) AbstractAction(javax.swing.AbstractAction) CyNetworkView(org.cytoscape.view.model.CyNetworkView) JDialog(javax.swing.JDialog)

Example 40 with EnrichmentMap

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

the class HeatMapMainPanel method updateSetting_RankOption.

public void updateSetting_RankOption(RankingOption rankOption) {
    selectedRankOption = rankOption;
    List<String> genes = getGenes(getOperator());
    HeatMapTableModel tableModel = (HeatMapTableModel) table.getModel();
    EnrichmentMap map = tableModel.getEnrichmentMap();
    List<Integer> geneIds = genes.stream().map(map::getHashFromGene).collect(Collectors.toList());
    CompletableFuture<Optional<Map<Integer, RankValue>>> rankingFuture = rankOption.computeRanking(geneIds);
    if (rankingFuture != null) {
        rankingFuture.whenComplete((ranking, ex) -> {
            if (ranking.isPresent()) {
                tableModel.setRanking(rankOption.getName(), ranking.get());
                table.getColumnModel().getColumn(HeatMapTableModel.RANK_COL).setHeaderValue(rankOption);
            } else {
                tableModel.setRanking(rankOption.getName(), null);
                table.getColumnModel().getColumn(HeatMapTableModel.RANK_COL).setHeaderValue(new RankOptionErrorHeader(rankOption));
            }
            table.getTableHeader().repaint();
        });
    }
    settingChanged();
}
Also used : Optional(java.util.Optional) HeatMapTableModel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) RankValue(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue) RankOptionErrorHeader(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankOptionErrorHeader)

Aggregations

EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)57 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)27 Test (org.junit.Test)22 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)21 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)13 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)13 CyNetwork (org.cytoscape.model.CyNetwork)12 EnrichmentMapParameters (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters)11 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)10 CyNetworkView (org.cytoscape.view.model.CyNetworkView)10 Map (java.util.Map)8 CyEdge (org.cytoscape.model.CyEdge)7 CyRow (org.cytoscape.model.CyRow)7 NullTaskMonitor (org.baderlab.csplugins.enrichmentmap.util.NullTaskMonitor)6 TaskIterator (org.cytoscape.work.TaskIterator)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 HashSet (java.util.HashSet)5 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)5 Inject (com.google.inject.Inject)4 ActionEvent (java.awt.event.ActionEvent)4