Skip to content

Commit

Permalink
Fix p-value colors going in wrong direction.
Browse files Browse the repository at this point in the history
Refs #452
  • Loading branch information
mikekucera committed Mar 30, 2021
1 parent 725b3a7 commit ce03605
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ public static NodeShape getDefaultNodeShape(ChartType chartType) {


public void updateStyle(VisualStyle vs, EMStyleOptions options, CyCustomGraphics2<?> chart, StyleUpdateScope scope) {
System.out.println("EMStyleBuilder.updateStyle(): " + scope);
String chartName = chart != null ? chart.getDisplayName() : null;
ChartType chartType = ChartType.toChartType(chartName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,13 @@ public CyCustomGraphics2<?> createChart() {

ColorScheme colorScheme = chartOptions != null ? chartOptions.getColorScheme() : null;

if (colorScheme != null && colorScheme.getPoints() != null) {
List<Double> points = colorScheme.getPoints();

if (!points.isEmpty())
props.put(AbstractChart.COLOR_POINTS, points);
}
if (colorScheme != null && !colorScheme.getPoints().isEmpty()) {
props.put(AbstractChart.COLOR_POINTS, colorScheme.getPoints());
}
}

try {
CyCustomGraphics2Factory<?> factory = chartFactoryManager.getChartFactory(type.getId());

if (factory != null)
chart = factory.getInstance(props);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,16 @@ private void updateNodeChartColorPanel(Collection<EMDataSet> dataSets) {
double max = range.get(1);

String posMaxLabel = max > 0 ? String.format("%.2f", max) : "N/A";
Color posMaxColor = colors.get(0);
Color posMinColor = colors.get(colors.size()/2);
Color posMaxColor;
Color posMinColor;
if(data == ChartData.NES_VALUE) {
posMaxColor = colors.get(0);
posMinColor = colors.get(colors.size()/2);
} else {
posMaxColor = colors.get(colors.size()/2);
posMinColor = colors.get(0);
}

chartPosLegend = new ColorLegendPanel(posMaxColor, posMinColor, posMaxLabel, "0", false);
JLabel posLabel = new JLabel("Positive");
SwingUtil.makeSmall(posLabel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static List<Color> getChartColors(ChartOptions options, boolean forStyle)
// The 3-color schemes need to be swapped when the chart only includes positive numbers.
// Swap UP and ZERO colors if q or p-value (it should not have negative values!)
if ((data == ChartData.FDR_VALUE || data == ChartData.P_VALUE) && colors.size() == 3)
colors = Arrays.asList(colors.get(1), colors.get(0), colors.get(1));
colors = Arrays.asList(colors.get(0), colors.get(1));
}

return colors;
Expand Down

0 comments on commit ce03605

Please sign in to comment.