@@ -73,16 +73,20 @@ public void run(TaskMonitor tm) {
73
73
74
74
Map <CyNode ,Double > nodeSig = new HashMap <>();
75
75
for (CyNode node : nodes ) {
76
- nodeSig .put (node , getNodeAvgSig (network , node , columnIDs ));
76
+ var nodeAvgSig = getNodeAvgSig (network , node , columnIDs );
77
+ if (nodeAvgSig != null ) {
78
+ nodeSig .put (node , nodeAvgSig );
79
+ }
77
80
}
78
81
79
- nodes .sort (compareSignificance (nodeSig , chartData ));
80
-
81
- // System.out.println("** significance command **");
82
- // columnIDs.forEach(System.out::println);
83
- // nodes.forEach(node -> System.out.println("Node:" + node.getSUID() + ", sig:" + nodeSig.get(node)));
82
+ results = nodes .stream ()
83
+ .filter (nodeSig ::containsKey )
84
+ .sorted (compareSignificance (nodeSig , chartData ))
85
+ .collect (Collectors .toList ());
84
86
85
- results = nodes ;
87
+ System .out .println ("** significance command **" );
88
+ columnIDs .forEach (System .out ::println );
89
+ results .forEach (node -> System .out .println ("Node:" + node .getSUID () + ", sig:" + nodeSig .get (node )));
86
90
}
87
91
88
92
@@ -119,8 +123,8 @@ private static Comparator<CyNode> compareSignificance(Map<CyNode,Double> nodeSig
119
123
default :
120
124
case P_VALUE :
121
125
case FDR_VALUE :
122
- return (n1 , n2 ) -> Double .compare (nodeSig .get (n1 ), nodeSig .get (n2 ));
123
- case NONE : // NONE defaults to -log10
126
+ return (n1 , n2 ) -> Double .compare (nodeSig .get (n1 ), nodeSig .get (n2 ));
127
+ case NONE : // -log10
124
128
case LOG10_PVAL :
125
129
return (n1 , n2 ) -> -Double .compare (nodeSig .get (n1 ), nodeSig .get (n2 ));
126
130
case NES_VALUE :
@@ -157,7 +161,7 @@ private List<CyColumnIdentifier> getSignificanceColumns(EnrichmentMap map, CyNet
157
161
if (styleCol != null ) {
158
162
return List .of (styleCol );
159
163
}
160
- columnDescriptor = EMStyleBuilder .Columns .NODE_PVALUE ; // default to p-value
164
+ columnDescriptor = EMStyleBuilder .Columns .NODE_LOG_PVALUE_MAX ;
161
165
}
162
166
163
167
EMDataSet ds = getDataSet (map );
@@ -170,24 +174,27 @@ private List<CyColumnIdentifier> getSignificanceColumns(EnrichmentMap map, CyNet
170
174
}
171
175
172
176
173
- private double getNodeAvgSig (CyNetwork network , CyNode node , List <CyColumnIdentifier > columnIDs ) {
177
+ private Double getNodeAvgSig (CyNetwork network , CyNode node , List <CyColumnIdentifier > columnIDs ) {
174
178
CyTable nodeTable = network .getDefaultNodeTable ();
175
179
176
180
double sigSum = 0 ;
177
181
boolean hasSig = false ;
178
182
179
183
for (var colID : columnIDs ) {
180
184
String colName = colID .getColumnName ();
181
- Object val = network .getRow (node ).get (colName , nodeTable .getColumn (colName ).getType ());
182
- if (val instanceof Number ) {
183
- double sig = ((Number )val ).doubleValue ();
184
- sigSum += sig ;
185
- hasSig = true ;
185
+ var column = nodeTable .getColumn (colName );
186
+ if (column != null ) {
187
+ Object val = network .getRow (node ).get (colName , column .getType ());
188
+ if (val instanceof Number ) {
189
+ double sig = ((Number )val ).doubleValue ();
190
+ sigSum += sig ;
191
+ hasSig = true ;
192
+ }
186
193
}
187
194
}
188
195
189
196
if (!hasSig )
190
- return Double . NaN ;
197
+ return null ;
191
198
192
199
return sigSum / columnIDs .size ();
193
200
}
0 commit comments