use of org.baderlab.csplugins.enrichmentmap.view.heatmap.RankingOption in project EnrichmentMapApp by BaderLab.
the class HeatMapRanksTest method testLeadingEdge.
@Test
public void testLeadingEdge(EnrichmentMapManager emManager) throws Exception {
final String geneSetName = "ENVELOPE%GO%GO:0031975";
final int leadingEdgeSize = 170;
// Sanity test
EnrichmentMap map = emManager.getAllEnrichmentMaps().values().iterator().next();
EMDataSet dataset = map.getDataSet(LegacySupport.DATASET1);
GeneSet gs = dataset.getGeneSetsOfInterest().getGeneSets().get(geneSetName);
assertNotNull(gs);
// Run the ranking
RankingOption rankingOption = new GSEALeadingEdgeRankingOption(dataset, geneSetName, Ranking.GSEARanking);
Map<Integer, RankValue> ranks = rankingOption.computeRanking(gs.getGenes()).get().get();
assertEquals(454, ranks.size());
// Convert to useful collections
Map<RankValue, Integer> rankToGeneId = HashBiMap.create(ranks).inverse();
List<RankValue> sortedRanks = ranks.values().stream().sorted().collect(Collectors.toList());
// Test leading edge
for (int i = 0; i < sortedRanks.size(); i++) {
RankValue v = sortedRanks.get(i);
assertTrue(v.isSignificant() == i < leadingEdgeSize);
}
// Test genes are the same
List<Integer> expectedGeneOrder = getGeneOrderFromFile(map, PATH + "gene_order_leading_edge.txt");
List<Integer> actualGeneOrder = sortedRanks.stream().map(rankToGeneId::get).collect(Collectors.toList());
assertEquals(expectedGeneOrder, actualGeneOrder);
}
use of org.baderlab.csplugins.enrichmentmap.view.heatmap.RankingOption in project EnrichmentMapApp by BaderLab.
the class ColumnHeaderRankOptionRenderer method menuButtonClicked.
private void menuButtonClicked(JTable table, JButton button) {
JTableHeader header = table.getTableHeader();
List<RankingOption> rankOptions = mainPanel.getAllRankingOptions();
JPopupMenu menu = new JPopupMenu();
for (RankingOption rankOption : rankOptions) {
JMenuItem item = new JCheckBoxMenuItem(rankOption.getName());
item.setSelected(rankOption == mainPanel.getSelectedRankOption());
SwingUtil.makeSmall(item);
menu.add(item);
item.addActionListener(e -> mainPanel.updateSetting_RankOption(rankOption));
}
int y = button.getHeight();
int x = 0;
for (int i = 0; i < colIndex; i++) {
TableColumn tableColumn = table.getColumnModel().getColumn(i);
x += tableColumn.getWidth();
}
menu.show(header, x, y);
}
use of org.baderlab.csplugins.enrichmentmap.view.heatmap.RankingOption in project EnrichmentMapApp by BaderLab.
the class ColumnHeaderRankOptionRenderer method getTableCellRendererComponent.
@Override
public Component getTableCellRendererComponent(JTable table, final Object value, boolean isSelected, boolean hasFocus, int row, int col) {
// Convert RankingOption to display String
String text = null;
if (value instanceof RankingOption) {
RankingOption rankingOption = (RankingOption) value;
text = rankingOption.getTableHeaderText();
} else if (value instanceof RankOptionErrorHeader) {
RankOptionErrorHeader headerValue = (RankOptionErrorHeader) value;
text = headerValue.getRankingOption().getTableHeaderText();
}
// Use the default renderer to paint the header nicely (with sort arrows)
JTableHeader header = table.getTableHeader();
TableCellRenderer delegate = table.getTableHeader().getDefaultRenderer();
Component component = delegate.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, col);
// Create the panel
JButton button = new JButton("Sort");
SwingUtil.makeSmall(button);
if (isAquaLAF())
button.putClientProperty("JButton.buttonType", "gradient");
button.addActionListener(e -> menuButtonClicked(table, button));
JPanel buttonPanel = new JPanel(new BorderLayout());
buttonPanel.add(button, BorderLayout.CENTER);
buttonPanel.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
buttonPanel.setForeground(header.getForeground());
buttonPanel.setBackground(header.getBackground());
JPanel panel = new JPanel(new BorderLayout());
panel.setForeground(header.getForeground());
panel.setBackground(header.getBackground());
panel.add(component, BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.NORTH);
if (value instanceof RankOptionErrorHeader) {
JLabel icon = new JLabel(IconManager.ICON_TIMES_CIRCLE);
icon.setForeground(Color.RED.darker());
icon.setFont(iconManager.getIconFont(13.0f));
icon.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
icon.setOpaque(false);
panel.add(icon, BorderLayout.WEST);
}
// Add mouse listener
if (mouseListener != null) {
header.removeMouseListener(mouseListener);
}
header.addMouseListener(mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int col = header.columnAtPoint(e.getPoint());
if (col == colIndex)
if (e.getY() <= button.getHeight())
button.doClick();
else
sortColumn(table);
else
sortOrder = null;
}
});
return panel;
}
Aggregations