Search in sources :

Example 6 with EMDataSet

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

the class ColorRenderer method getTableCellRendererComponent.

public JLabel getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    JLabel label = new JLabel();
    //MUST do this for background to show up.
    label.setOpaque(true);
    HeatMapTableModel model = (HeatMapTableModel) table.getModel();
    EMDataSet dataset = model.getDataSet(col);
    Transform transform = model.getTransform();
    DataSetColorRange range = getRange(dataset, transform);
    if (value instanceof Double) {
        Color color = getColor(range.getTheme(), range.getRange(), (Double) value);
        label.setBackground(color);
        Border border = BorderFactory.createMatteBorder(1, 1, 1, 1, isSelected ? table.getSelectionForeground() : color);
        label.setBorder(border);
        if (Double.isFinite((Double) value))
            label.setToolTipText(value.toString());
    }
    return label;
}
Also used : Color(java.awt.Color) JLabel(javax.swing.JLabel) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) Transform(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform) Border(javax.swing.border.Border)

Example 7 with EMDataSet

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

the class MannWhitneyRanksDialog method createDataSetPanel.

private JPanel createDataSetPanel() {
    JPanel panel = new JPanel(new GridBagLayout());
    panel.setBorder(LookAndFeelUtil.createTitledBorder("Select ranks to use for each data set."));
    int y = 0;
    List<EMDataSet> dataSets = getDataSets();
    for (EMDataSet dataset : dataSets) {
        final String dataSetName = dataset.getName();
        JLabel label = new JLabel(dataSetName + ":");
        JComboBox<String> combo = new JComboBox<>();
        for (String ranksName : dataset.getExpressionSets().getAllRanksNames()) {
            combo.addItem(ranksName);
        }
        SwingUtil.makeSmall(label, combo);
        if (combo.getItemCount() <= 1) {
            combo.setEnabled(false);
        }
        combo.addActionListener(e -> {
            String ranks = combo.getSelectedItem().toString();
            results.put(dataSetName, ranks);
        });
        results.put(dataSetName, combo.getSelectedItem().toString());
        panel.add(label, GBCFactory.grid(0, y).weightx(.5).anchor(EAST).fill(NONE).get());
        panel.add(combo, GBCFactory.grid(1, y).weightx(.5).get());
        y++;
    }
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) JLabel(javax.swing.JLabel) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Example 8 with EMDataSet

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

the class HeatMapTableModel method getColumnName.

@Override
public String getColumnName(int col) {
    if (col == GENE_COL)
        return "Gene";
    if (col == DESC_COL)
        return "Description";
    if (col == RANK_COL)
        return ranksColName;
    EMDataSet dataset = getDataSet(col);
    if (transform.isCompress()) {
        return dataset.getName();
    } else {
        int index = getIndexInDataSet(col) + 2;
        String[] columns = dataset.getExpressionSets().getColumnNames();
        return columns[index];
    }
}
Also used : EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Example 9 with EMDataSet

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

the class LegendPanel method updateNodeColorPanel.

private void updateNodeColorPanel(Collection<EMDataSet> dataSets, EnrichmentMap map) {
    JPanel p = getNodeColorPanel();
    p.removeAll();
    if (dataSets != null && dataSets.size() == 1) {
        EMDataSet ds = dataSets.iterator().next();
        ColorLegendPanel clp = new ColorLegendPanel(Colors.MAX_PHENOTYPE_1, Colors.MAX_PHENOTYPE_2, ds.getEnrichments().getPhenotype1(), ds.getEnrichments().getPhenotype2());
        GroupLayout layout = (GroupLayout) p.getLayout();
        layout.setHorizontalGroup(layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(clp, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addGap(0, 0, Short.MAX_VALUE));
        layout.setVerticalGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(clp));
        p.setVisible(true);
    } else {
        p.setVisible(false);
    }
}
Also used : JPanel(javax.swing.JPanel) GroupLayout(javax.swing.GroupLayout) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Example 10 with EMDataSet

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

the class LoadGMTFileOnlyTest method testGMTOnly.

@Test
public void testGMTOnly() throws Exception {
    //for a dataset we require genesets, an expression file (optional), enrichment results
    String testGmtFileName = "src/test/resources/org/baderlab/csplugins/enrichmentmap/task/genesets_subset.gmt";
    DataSetFiles files = new DataSetFiles();
    files.setGMTFileName(testGmtFileName);
    //create an new enrichment Map
    double similarityCutoff = 0.5;
    double pvalue = 1.0;
    double qvalue = 1.0;
    EMCreationParameters params = new EMCreationParameters("EM1_", pvalue, qvalue, NESFilter.ALL, Optional.empty(), SimilarityMetric.JACCARD, similarityCutoff, 0.5);
    EnrichmentMap em = new EnrichmentMap(params, serviceRegistrar);
    //Load data set
    //create a dataset
    EMDataSet dataset = em.createDataSet(LegacySupport.DATASET1, Method.GSEA, files);
    //create a DatasetTask
    //set up task
    GMTFileReaderTask task = new GMTFileReaderTask(dataset);
    task.run(taskMonitor);
    dataset.setGeneSetsOfInterest(dataset.getSetOfGeneSets());
    //create dummy expression
    CreateDummyExpressionTask dummyExpressionTask = new CreateDummyExpressionTask(dataset);
    dummyExpressionTask.run(taskMonitor);
    em.filterGenesets();
    InitializeGenesetsOfInterestTask genesets_init = new InitializeGenesetsOfInterestTask(em);
    genesets_init.run(taskMonitor);
    Baton<Map<SimilarityKey, GenesetSimilarity>> baton = new Baton<>();
    ComputeSimilarityTaskParallel similarities = new ComputeSimilarityTaskParallel(em, baton.consumer());
    similarities.run(taskMonitor);
    //check to see if the dataset loaded - there should be 36 genesets
    assertEquals(36, dataset.getSetOfGeneSets().getGeneSets().size());
    //there should be (36 * 35)/2 edges (geneset similarities)
    assertEquals(18, baton.supplier().get().size());
    //there should be 523 genes
    assertEquals(523, em.getNumberOfGenes());
    assertEquals(523, dataset.getExpressionSets().getNumGenes());
    assertEquals(523, dataset.getDataSetGenes().size());
    assertEquals(3, dataset.getExpressionSets().getNumConditions());
}
Also used : EMCreationParameters(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) GMTFileReaderTask(org.baderlab.csplugins.enrichmentmap.parsers.GMTFileReaderTask) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) 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) Test(org.junit.Test)

Aggregations

EMDataSet (org.baderlab.csplugins.enrichmentmap.model.EMDataSet)58 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)30 DataSetFiles (org.baderlab.csplugins.enrichmentmap.model.DataSetFiles)20 Test (org.junit.Test)19 Method (org.baderlab.csplugins.enrichmentmap.model.EMDataSet.Method)13 EnrichmentMapParameters (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMapParameters)11 Map (java.util.Map)10 EMCreationParameters (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters)10 Set (java.util.Set)8 EnrichmentResult (org.baderlab.csplugins.enrichmentmap.model.EnrichmentResult)8 GeneSet (org.baderlab.csplugins.enrichmentmap.model.GeneSet)7 CyNode (org.cytoscape.model.CyNode)7 JPanel (javax.swing.JPanel)6 Inject (com.google.inject.Inject)5 Color (java.awt.Color)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 JLabel (javax.swing.JLabel)5 CyEdge (org.cytoscape.model.CyEdge)5 CyNetwork (org.cytoscape.model.CyNetwork)5