Skip to content

Commit b19b271

Browse files
committed
Fix for #540
1 parent ae4b9bc commit b19b271

File tree

2 files changed

+29
-35
lines changed

2 files changed

+29
-35
lines changed

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/style/EMStyleBuilder.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -493,22 +493,19 @@ private void setNodeBorderColors(VisualStyle vs, EMStyleOptions options) {
493493
}
494494

495495
public static ColumnDescriptor<Double> getDefaultMappingColumn(EMStyleOptions options) {
496-
var isSingleGSEA = options.getEnrichmentMap().isSingleGSEA();
497-
if(isSingleGSEA)
498-
return Columns.NODE_LOG_PVALUE_NES;
499-
else
500-
return Columns.NODE_LOG_PVALUE_MAX;
496+
boolean isSingleGSEA = options.getEnrichmentMap().isSingleGSEA();
497+
return isSingleGSEA
498+
? Columns.NODE_LOG_PVALUE_NES
499+
: Columns.NODE_LOG_PVALUE_MAX;
501500
}
502501

503502
public static String getDefaultMappingColumnName(EMStyleOptions options) {
504503
var map = options.getEnrichmentMap();
505504
var prefix = options.getAttributePrefix();
506505
boolean isSingleGSEA = map.isSingleGSEA();
507-
508-
if(isSingleGSEA)
509-
return Columns.NODE_LOG_PVALUE_NES.with(prefix, map.getDataSetList().get(0));
510-
else
511-
return Columns.NODE_LOG_PVALUE_MAX.with(prefix);
506+
return isSingleGSEA
507+
? Columns.NODE_LOG_PVALUE_NES.with(prefix, map.getDataSetList().get(0))
508+
: Columns.NODE_LOG_PVALUE_MAX.with(prefix);
512509
}
513510

514511

@@ -525,14 +522,14 @@ private ContinuousMapping<Double,Paint> createLog10NodeColorMapping(EMStyleOptio
525522
var colList = List.of(columnIdFactory.createColumnIdentifier(logPValCol));
526523
var range = ChartUtil.calculateGlobalRange(network, colList, true);
527524

528-
var colors = DEF_NODE_COLOR_SCHEME.getColors();
529-
var negColor = colors.get(2);
530-
var zeroColor = colors.get(1);
531-
var posColor = colors.get(0);
525+
var colors = DEF_NODE_COLOR_SCHEME;
526+
var negColor = colors.getNegColor();
527+
var zeroColor = colors.getZeroColor();
528+
var posColor = colors.getPosColor();
532529

533-
var negPoint = new BoundaryRangeValues<Paint>(negColor, negColor, negColor);
530+
var negPoint = new BoundaryRangeValues<Paint>(negColor, negColor, negColor);
534531
var zeroPoint = new BoundaryRangeValues<Paint>(zeroColor, zeroColor, zeroColor);
535-
var posPoint = new BoundaryRangeValues<Paint>(posColor, posColor, posColor);
532+
var posPoint = new BoundaryRangeValues<Paint>(posColor, posColor, posColor);
536533

537534
eventHelper.silenceEventSource(mapping);
538535
try {

EnrichmentMapPlugin/src/main/java/org/baderlab/csplugins/enrichmentmap/task/CreateEMNetworkTask.java

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ else if(result instanceof GenericResult)
199199

200200

201201
private boolean needsInit = true;
202-
private Double minPValueThatsNotZero = null;
202+
private double minPValueThatsNotZero;
203203

204-
private Double getMinPValueThatsNotZero() {
204+
private double getMinPValueThatsNotZero() {
205205
if(needsInit) {
206206
Double minPValue = null;
207207

@@ -217,48 +217,45 @@ private Double getMinPValueThatsNotZero() {
217217
}
218218
}
219219

220-
minPValueThatsNotZero = minPValue; // could still possibly be null
220+
if(minPValue == null) {
221+
minPValueThatsNotZero = 1e-10; // bug #540
222+
} else {
223+
minPValueThatsNotZero = minPValue;
224+
}
225+
221226
needsInit = false;
222227
}
223228
return minPValueThatsNotZero;
224229
}
225230

226231

227-
private Double getNegLog10pval(EMDataSet dataset, EnrichmentResult result) {
232+
private double getNegLog10pval(EMDataSet dataset, EnrichmentResult result) {
228233
double pval = result.getPvalue();
229234
if(pval > 0.0) {
230235
return -Math.log10(pval);
231-
} else if(pval == 0.0) {
232-
Double minPval = getMinPValueThatsNotZero();
233-
if(minPval != null) {
234-
return -Math.log10(minPval);
235-
}
236+
} else {
237+
double minPval = getMinPValueThatsNotZero();
238+
return -Math.log10(minPval);
236239
}
237-
return null;
238240
}
239241

240242

241-
private Double getMaxNegLog10pval(String genesetName) {
242-
boolean hasVal = false;
243+
private double getMaxNegLog10pval(String genesetName) {
243244
double maxVal = Double.MIN_VALUE;
244245

245246
for(EMDataSet ds : map.getDataSetList()) {
246247
var result = ds.getEnrichment(genesetName);
247248
if(result != null) {
248249
double pval = result.getPvalue();
249250
if(pval > 0.0) {
250-
hasVal = true;
251251
maxVal = Math.max(maxVal, -Math.log10(pval));
252252
} else {
253-
Double minPval = getMinPValueThatsNotZero();
254-
if(minPval != null) {
255-
hasVal = true;
256-
maxVal = Math.max(maxVal, -Math.log10(minPval));
257-
}
253+
double minPval = getMinPValueThatsNotZero();
254+
maxVal = Math.max(maxVal, -Math.log10(minPval));
258255
}
259256
}
260257
}
261-
return hasVal ? maxVal : null; // leave the cell blank
258+
return maxVal; // leave the cell blank
262259
}
263260

264261

0 commit comments

Comments
 (0)