Search in sources :

Example 51 with EMDataSet

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

the class HeatMapTableModel method getPhenotype.

public Optional<String> getPhenotype(int col) {
    if (transform.isCompress())
        return Optional.empty();
    EMDataSet dataset = getDataSet(col);
    int index = getIndexInDataSet(col);
    String[] classes = dataset.getExpressionSets().getPhenotypes();
    if (classes != null && index < classes.length) {
        return Optional.ofNullable(classes[index]);
    }
    return Optional.empty();
}
Also used : EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Example 52 with EMDataSet

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

the class HeatMapTableModel method getValueAt.

@Override
public Object getValueAt(int row, int col) {
    if (row < 0)
        // Why is it passing -1?
        return null;
    if (col == RANK_COL)
        return getRankValue(row);
    String gene = genes.get(row);
    if (col == GENE_COL)
        return gene;
    int geneID = map.getHashFromGene(gene);
    if (col == DESC_COL)
        return getDescription(geneID);
    EMDataSet dataset = getDataSet(col);
    if (transform.isCompress()) {
        return getCompressedExpression(dataset, geneID, transform);
    } else {
        double[] vals = getExpression(dataset, geneID, transform);
        return vals == null ? Double.NaN : vals[getIndexInDataSet(col)];
    }
}
Also used : EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

Example 53 with EMDataSet

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

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

the class ColumnHeaderVerticalRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) {
    HeatMapTableModel model = (HeatMapTableModel) table.getModel();
    EMDataSet dataset = model.getDataSet(col);
    String labelText = SwingUtil.abbreviate(value.toString(), 40);
    JLabel verticalLabel = createVerticalLabel(labelText);
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(verticalLabel, BorderLayout.CENTER);
    Color barColor = dataset.getColor();
    if (barColor != null) {
        JPanel barPanel = new JPanel();
        barPanel.setPreferredSize(new Dimension(verticalLabel.getWidth(), 5));
        barPanel.setBackground(barColor);
        panel.add(barPanel, BorderLayout.NORTH);
    }
    if (labelBackgroundColor.isPresent()) {
        panel.setBackground(labelBackgroundColor.get());
    }
    panel.setToolTipText(value.toString());
    return panel;
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) Color(java.awt.Color) JLabel(javax.swing.JLabel) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) Dimension(java.awt.Dimension)

Example 55 with EMDataSet

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

the class PAKnownSignatureCommandTask method processMannWhitneyArgs.

private void processMannWhitneyArgs(EnrichmentMap map, PostAnalysisParameters.Builder builder) {
    if (mannWhitRanks.isEmpty() && map.isSingleRanksPerDataset()) {
        for (EMDataSet dataset : map.getDataSetList()) {
            String ranksName = dataset.getExpressionSets().getAllRanksNames().iterator().next();
            builder.addDataSetToRankFile(dataset.getName(), ranksName);
        }
    } else {
        if (mannWhitRanks.isEmpty()) {
            throw new IllegalArgumentException("At least one of the data sets you have specified has more than one ranks file. " + "You must use the 'mannWhitRanks' parameter to specify which ranking to use for each data set.");
        }
        List<EMDataSet> dataSetList = isBatch() ? map.getDataSetList() : Arrays.asList(map.getDataSet(dataSetName));
        for (EMDataSet dataSet : dataSetList) {
            String dsName = dataSet.getName();
            String rankFile = mannWhitRanks.getRankFile(dsName);
            Set<String> ranksNames = dataSet.getExpressionSets().getAllRanksNames();
            if (ranksNames.size() > 1) {
                if (rankFile == null)
                    throw new IllegalArgumentException("The data set '" + dsName + "' has more than one ranks file, you must specify the rank file using the 'mannWhatRanks' parameter.");
                if (!ranksNames.contains(rankFile))
                    throw new IllegalArgumentException("The data set '" + dsName + "' does not contain the rank file '" + rankFile + "'.");
            }
            if (rankFile == null && ranksNames.size() == 1) {
                builder.addDataSetToRankFile(dsName, ranksNames.iterator().next());
            } else {
                builder.addDataSetToRankFile(dsName, rankFile);
            }
        }
    }
}
Also used : EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet)

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