Search in sources :

Example 1 with RankOptionErrorHeader

use of org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankOptionErrorHeader 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

Optional (java.util.Optional)1 EnrichmentMap (org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap)1 HeatMapTableModel (org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel)1 RankOptionErrorHeader (org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankOptionErrorHeader)1 RankValue (org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue)1