Search in sources :

Example 1 with SimilarityMetric

use of org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric 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 SimilarityMetric

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

the class EnrichmentMapParameters method getCreationParameters.

public EMCreationParameters getCreationParameters() {
    SimilarityMetric similarityMetric = stringToSimilarityMetric(getSimilarityMetric());
    EMCreationParameters params = new EMCreationParameters(getAttributePrefix(), getPvalue(), getQvalue(), NESFilter.ALL, Optional.empty(), similarityMetric, getSimilarityCutOff(), getCombinedConstant());
    params.setEnrichmentEdgeType(enrichment_edge_type);
    params.setFDR(fdr);
    return params;
}
Also used : SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric)

Example 3 with SimilarityMetric

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

the class CutoffPropertiesPanel method createFilterEdgesPanel.

private JPanel createFilterEdgesPanel() {
    JPanel panel = new JPanel();
    panel.setBorder(LookAndFeelUtil.createTitledBorder("Similarity Filtering (Edges)"));
    JLabel cutoffLabel = new JLabel("Cutoff:");
    JLabel metricLabel = new JLabel("Metric:");
    SwingUtil.makeSmall(cutoffLabel, metricLabel);
    SimilarityMetric defaultMetric = propertyManager.getDefaultSimilarityMetric();
    double defaultCutoff = propertyManager.getDefaultCutOff(defaultMetric);
    similarityCutoffText = new JFormattedTextField(getFormatterFactory(false));
    similarityCutoffText.setValue(defaultCutoff);
    cutoffMetricCombo = new JComboBox<>();
    cutoffMetricCombo.addItem(new ComboItem<>(SimilarityMetric.JACCARD, "Jaccard"));
    cutoffMetricCombo.addItem(new ComboItem<>(SimilarityMetric.OVERLAP, "Overlap"));
    cutoffMetricCombo.addItem(new ComboItem<>(SimilarityMetric.COMBINED, "Jaccard+Overlap Combined"));
    SwingUtil.makeSmall(similarityCutoffText, cutoffMetricCombo);
    ActionListener sliderUpdate = e -> {
        SimilarityMetric type = getSimilarityMetric();
        similarityCutoffText.setValue(cutoffValues.get(type));
        combinedConstantSlider.setVisible(type == SimilarityMetric.COMBINED);
    };
    double combinedConstant = propertyManager.getDefaultCombinedConstant();
    int tick = (int) (combinedConstant * 100.0);
    combinedConstantSlider = new CombinedConstantSlider(tick);
    combinedConstantSlider.setOpaque(false);
    // default
    cutoffMetricCombo.setSelectedItem(ComboItem.of(defaultMetric));
    cutoffMetricCombo.addActionListener(sliderUpdate);
    similarityCutoffText.addPropertyChangeListener("value", e -> {
        double value = ((Number) e.getNewValue()).doubleValue();
        cutoffValues.put(getSimilarityMetric(), value);
    });
    sliderUpdate.actionPerformed(null);
    final GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup().addComponent(cutoffLabel).addComponent(metricLabel)).addGroup(layout.createParallelGroup().addComponent(similarityCutoffText, PREFERRED_SIZE, 100, PREFERRED_SIZE).addComponent(cutoffMetricCombo, PREFERRED_SIZE, PREFERRED_SIZE, PREFERRED_SIZE).addComponent(combinedConstantSlider, PREFERRED_SIZE, PREFERRED_SIZE, PREFERRED_SIZE)).addGap(0, 0, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(cutoffLabel).addComponent(similarityCutoffText)).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(metricLabel).addComponent(cutoffMetricCombo)).addComponent(combinedConstantSlider, PREFERRED_SIZE, PREFERRED_SIZE, PREFERRED_SIZE).addGap(0, 0, Short.MAX_VALUE));
    if (LookAndFeelUtil.isAquaLAF())
        panel.setOpaque(false);
    return panel;
}
Also used : ActionListener(java.awt.event.ActionListener) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) NumberFormat(java.text.NumberFormat) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) NESFilter(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter) ComboItem(org.baderlab.csplugins.enrichmentmap.view.util.ComboItem) InternationalFormatter(javax.swing.text.InternationalFormatter) Map(java.util.Map) JComboBox(javax.swing.JComboBox) AbstractFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory) JFormattedTextField(javax.swing.JFormattedTextField) EnumMap(java.util.EnumMap) DecimalFormat(java.text.DecimalFormat) PREFERRED_SIZE(javax.swing.GroupLayout.PREFERRED_SIZE) Alignment(javax.swing.GroupLayout.Alignment) LookAndFeelUtil(org.cytoscape.util.swing.LookAndFeelUtil) JLabel(javax.swing.JLabel) SwingUtil(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil) GroupLayout(javax.swing.GroupLayout) JCheckBox(javax.swing.JCheckBox) AbstractFormatter(javax.swing.JFormattedTextField.AbstractFormatter) Optional(java.util.Optional) PropertyManager(org.baderlab.csplugins.enrichmentmap.PropertyManager) JPanel(javax.swing.JPanel) JPanel(javax.swing.JPanel) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) ActionListener(java.awt.event.ActionListener) GroupLayout(javax.swing.GroupLayout)

Example 4 with SimilarityMetric

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

use of org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric 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)

Aggregations

SimilarityMetric (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric)6 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)4 DataSetParameters (org.baderlab.csplugins.enrichmentmap.resolver.DataSetParameters)4 CreateEnrichmentMapTaskFactory (org.baderlab.csplugins.enrichmentmap.task.CreateEnrichmentMapTaskFactory)4 ArrayList (java.util.ArrayList)3 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)3 NESFilter (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter)3 Inject (com.google.inject.Inject)2 Map (java.util.Map)2 Optional (java.util.Optional)2 GroupLayout (javax.swing.GroupLayout)2 Alignment (javax.swing.GroupLayout.Alignment)2 JCheckBox (javax.swing.JCheckBox)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 ResolverTask (org.baderlab.csplugins.enrichmentmap.resolver.ResolverTask)2 SwingUtil (org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil)2 TaskIterator (org.cytoscape.work.TaskIterator)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 Provider (com.google.inject.Provider)1