cytoscape / enrichment-table-app

Creates a new table for performing, storing and viewing functional enrichment analysis
GNU Lesser General Public License v2.1
6 stars 5 forks source link

Manual sorting of scientific notation is wrong #66

Closed AlexanderPico closed 2 years ago

AlexanderPico commented 2 years ago

Manual sorting of adjusted p-values is not working.

When the table of results first appears (or when it is refreshed) the sort order is correct (using the scientific notation, e.g., E-8). But if you click on the column header to sort by adjusted p-value it is not correct (it ignores the scientific notation).

Can manual sorting be fixed to use the same comparison logic as the initial sorting?

yihangx commented 2 years ago

The current fix disabled scientific notation. Need to find a better way to deal with this.

yihangx commented 2 years ago

We use auto sorter here, but don't know how to override it. https://github.com/cytoscape/enrichment-table-app/blob/768ed2ac45bf0510f8b0c2ba3c42e25292468e83/src/main/java/org/nrnb/gsoc/enrichment/ui/EnrichmentCytoPanel.java#L470

AlexanderPico commented 2 years ago

From Scooter:

Here are the key pieces: 1) When you create the table:

tcm.getColumn(EnrichmentTerm.fdrColumn).setCellRenderer(new DecimalFormatRenderer());

2) Add the class DecimalFormatRenderer:


static class DecimalFormatRenderer extends DefaultTableCellRenderer {
private static final DecimalFormat formatter = new DecimalFormat("0.#####E0");
public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
  try {
    if (value != null && (double) value < 0.001) {
      value = formatter.format((Number) value);
    }
  } catch (Exception ex) {
    // ignore and return original value
  }
  return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
      column);
}

}


>Where, as you see, we create the correct format, but the source data is actually a double value.  This is in edu.ucsf.rbvi.stringApp.internal.ui.EnrichmentCytoPanel.java
AlexanderPico commented 2 years ago

@yihangx Do you think this can be fixed for v1?

yihangx commented 2 years ago

@AlexanderPico I don't think so. I tried to fix with Scooter's suggestion but failed. Previous p-value fix changed a lot of code.

AkMo3 commented 2 years ago

Fixed by #82