Search in sources :

Example 1 with AbstractDataSet

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

the class ControlPanelMediator method createStyleOptions.

private EMStyleOptions createStyleOptions(EnrichmentMap map, EMViewControlPanel viewPanel) {
    if (map == null || viewPanel == null)
        return null;
    Set<AbstractDataSet> dataSets = viewPanel.getDataSetSelector().getCheckedItems();
    boolean publicationReady = viewPanel.getPublicationReadyCheck().isSelected();
    boolean postAnalysis = map.hasSignatureDataSets();
    ChartData data = (ChartData) viewPanel.getChartDataCombo().getSelectedItem();
    ChartType type = getChartType(viewPanel);
    ColorScheme colorScheme = (ColorScheme) viewPanel.getChartColorsCombo().getSelectedItem();
    boolean showLabels = viewPanel.getShowChartLabelsCheck().isSelected();
    ChartOptions chartOptions = new ChartOptions(data, type, colorScheme, showLabels);
    return new EMStyleOptions(viewPanel.getNetworkView(), map, dataSets::contains, chartOptions, postAnalysis, publicationReady);
}
Also used : EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) ChartData(org.baderlab.csplugins.enrichmentmap.style.ChartData) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) ColorScheme(org.baderlab.csplugins.enrichmentmap.style.ColorScheme) ChartType(org.baderlab.csplugins.enrichmentmap.style.ChartType) ChartOptions(org.baderlab.csplugins.enrichmentmap.style.ChartOptions)

Example 2 with AbstractDataSet

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

the class DataSetSelector method update.

public void update() {
    Map<AbstractDataSet, Boolean> oldCheckedItems = new HashMap<>(checkedItems);
    items.clear();
    checkedItems.clear();
    List<AbstractDataSet> newItems = new ArrayList<>();
    newItems.addAll(map.getDataSetList());
    newItems.addAll(map.getSignatureSetList());
    if (newItems != null) {
        for (AbstractDataSet ds : newItems) {
            items.add(ds);
            boolean selected = // New items are selected by default!
            !oldCheckedItems.containsKey(ds) || oldCheckedItems.get(ds) == Boolean.TRUE;
            checkedItems.put(ds, selected);
        }
    }
    updateTable();
    updateSelectionButtons();
    updateRemoveButton();
}
Also used : HashMap(java.util.HashMap) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) ArrayList(java.util.ArrayList)

Example 3 with AbstractDataSet

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

the class DataSetSelector method updateTable.

private void updateTable() {
    final Object[][] data = new Object[items.size()][HEARDER_NAMES.length];
    int i = 0;
    for (AbstractDataSet ds : items) {
        data[i][SELECTED_COL_IDX] = checkedItems.get(ds);
        data[i][TYPE_COL_IDX] = ds;
        data[i][NAME_COL_IDX] = ds;
        data[i][GENES_COL_IDX] = ds.getGeneSetsOfInterest().size();
        i++;
    }
    final DefaultTableModel model = new DefaultTableModel(data, HEARDER_NAMES) {

        @Override
        public boolean isCellEditable(int row, int column) {
            // TODO Allow renaming?
            return false;
        }
    };
    getTable().setModel(model);
    JCheckBox tmpField = new JCheckBox();
    makeSmall(tmpField);
    getTable().getColumnModel().getColumn(TYPE_COL_IDX).setMaxWidth(16);
    getTable().getColumnModel().getColumn(SELECTED_COL_IDX).setMaxWidth(tmpField.getPreferredSize().width);
    getTable().getColumnModel().getColumn(GENES_COL_IDX).setMaxWidth(48);
    getTable().getColumnModel().getColumn(TYPE_COL_IDX).setResizable(false);
    getTable().getColumnModel().getColumn(SELECTED_COL_IDX).setResizable(false);
}
Also used : JCheckBox(javax.swing.JCheckBox) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) DefaultTableModel(javax.swing.table.DefaultTableModel)

Example 4 with AbstractDataSet

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

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

the class ControlPanelMediator method getAllViewParams.

public Map<Long, ViewParams> getAllViewParams() {
    Map<Long, ViewParams> map = new HashMap<>();
    getControlPanel().getAllControlPanels().forEach((suid, panel) -> {
        CutoffParam cuttofParam = panel.getPValueRadio().isSelected() ? CutoffParam.P_VALUE : CutoffParam.Q_VALUE;
        Double pVal = panel.getPValueSliderPanel() != null ? panel.getPValueSliderPanel().getValue() : null;
        Double qVal = panel.getQValueSliderPanel() != null ? panel.getQValueSliderPanel().getValue() : null;
        Double sCoeff = panel.getSimilaritySliderPanel() != null ? panel.getSimilaritySliderPanel().getValue() : null;
        Set<AbstractDataSet> uncheckedDataSets = panel.getUncheckedDataSets();
        Set<String> filteredDataSets = uncheckedDataSets.stream().map(AbstractDataSet::getName).collect(Collectors.toSet());
        EMStyleOptions options = createStyleOptions(panel.getNetworkView());
        boolean pubReady = panel.getPublicationReadyCheck().isSelected();
        ViewParams params = new ViewParams(suid, cuttofParam, pVal, qVal, sCoeff, filteredDataSets, options.getChartOptions(), pubReady);
        map.put(suid, params);
    });
    return map;
}
Also used : EMStyleOptions(org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions) ViewParams(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams) HashMap(java.util.HashMap) AbstractDataSet(org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet) CutoffParam(org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams.CutoffParam)

Aggregations

AbstractDataSet (org.baderlab.csplugins.enrichmentmap.model.AbstractDataSet)12 HashMap (java.util.HashMap)4 EMSignatureDataSet (org.baderlab.csplugins.enrichmentmap.model.EMSignatureDataSet)4 EMStyleOptions (org.baderlab.csplugins.enrichmentmap.style.EMStyleOptions)4 Inject (com.google.inject.Inject)3 HashSet (java.util.HashSet)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)3 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)3 ViewParams (org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams)3 CutoffParam (org.baderlab.csplugins.enrichmentmap.view.control.io.ViewParams.CutoffParam)3 CyEdge (org.cytoscape.model.CyEdge)3 CyNetwork (org.cytoscape.model.CyNetwork)3 CyNode (org.cytoscape.model.CyNode)3 CyNetworkView (org.cytoscape.view.model.CyNetworkView)3 CyCustomGraphics2 (org.cytoscape.view.presentation.customgraphics.CyCustomGraphics2)3 VisualStyle (org.cytoscape.view.vizmap.VisualStyle)3 Provider (com.google.inject.Provider)2 Singleton (com.google.inject.Singleton)2