Skip to content

Commit dae8e50

Browse files
committed
Cluster prior set according to graph size
1 parent 1b18ba2 commit dae8e50

3 files changed

Lines changed: 29 additions & 63 deletions

File tree

src/main/java/edu/virginia/uvacluster/internal/MyControlPanel.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ public void actionPerformed(ActionEvent e) {
488488
numSeeds.setText(Integer.toString(numNodes / 8));
489489
}
490490
}
491+
setClusterPrior();
491492
}
492493
}
493494
}
@@ -1151,12 +1152,13 @@ private void evaluateButtonPressed(File evaluateFile) throws IOException {
11511152
}
11521153

11531154
private Double minScoreThreshold() {
1154-
if (proteinGraph.getSelectedItem().toString().equals(" - Select Network - ")) {
1155+
String proteinGraphName = proteinGraph.getSelectedItem().toString();
1156+
if (proteinGraphName.equals(" - Select Network - ")) {
11551157
JOptionPane.showMessageDialog(this, "Please select a protein graph under 'Search'");
11561158
} else {
11571159
CyNetwork nw = null;
11581160
for (CyNetwork network: CyActivator.networkManager.getNetworkSet()) {
1159-
if (network.getRow(network).get(CyNetwork.NAME, String.class).equals(proteinGraph.getSelectedItem().toString())) {
1161+
if (network.getRow(network).get(CyNetwork.NAME, String.class).equals(proteinGraphName)) {
11601162
nw = network;
11611163
break;
11621164
}
@@ -1259,6 +1261,26 @@ private InputTask createInputTask() {
12591261
return inputTask;
12601262
}
12611263

1264+
private int getProteinGraphSize(String proteinGraphName) {
1265+
CyNetwork nw = null;
1266+
for (CyNetwork network: CyActivator.networkManager.getNetworkSet()) {
1267+
if (network.getRow(network).get(CyNetwork.NAME, String.class).equals(proteinGraphName)) {
1268+
nw = network;
1269+
break;
1270+
}
1271+
}
1272+
return nw.getNodeCount();
1273+
}
1274+
1275+
private void setClusterPrior() {
1276+
int graphSize = getProteinGraphSize(proteinGraph.getSelectedItem().toString());
1277+
if (graphSize <= 1000) {
1278+
clusterPrior.setText("0.5");
1279+
} else {
1280+
clusterPrior.setText("0.0001");
1281+
}
1282+
}
1283+
12621284
private Integer validateInput() {
12631285

12641286
if (learningScoreOption.isSelected() && !trainDefaultModel.isSelected() && !trainCustomModel.isSelected()) {

src/main/java/edu/virginia/uvacluster/internal/SupervisedModel.java

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -284,73 +284,17 @@ private CySubNetwork genNegativeExample(int size, List<CySubNetwork> positiveExa
284284
* Convenience method for training networks on positive *and* negative examples
285285
*/
286286
public void train(List<CySubNetwork> positiveExamples, List<CySubNetwork> negativeExamples) {
287-
System.out.println("Entered TRAIN");
288-
289-
for (FeatureSet feature : features) {
290-
for (String desc : feature.getDescriptions()) {
291-
System.out.println(desc);
292-
}
293-
}
294-
295287
List<Cluster> posExamples = new ArrayList<Cluster>(), negExamples = new ArrayList<Cluster>();
296288
for(CySubNetwork pos: positiveExamples) {posExamples.add(new Cluster(features, pos)); }
297289
for(CySubNetwork neg: negativeExamples) {negExamples.add(new Cluster(features, neg));}
298290

299291
System.out.println("Lists of pos and neg training examples created");
300-
301-
// System.out.println("TRAINING BINS ON POSITIVE COMPLEXES:");
292+
302293
posBayesGraph.trainBins(posExamples);
303-
// for (FeatureSet feature : features) {
304-
// List<String> statNames = feature.getDescriptions();
305-
// Map<String, Statistic> statMap = feature.getStatisticMap();
306-
// for (String statName : statNames) {
307-
// Statistic stat = statMap.get(statName);
308-
// Double min = stat.getRange().getMin();
309-
// Double max = stat.getRange().getMax();
310-
// System.out.println(statName + "\n\tMin: " + min + "\n\tMax: " + max);
311-
// }
312-
// }
313-
314-
// System.out.println("TRAINING BINS ON NEGATIVE COMPLEXES:");
315294
negBayesGraph.trainBins(negExamples);
316-
// for (FeatureSet feature : features) {
317-
// List<String> statNames = feature.getDescriptions();
318-
// Map<String, Statistic> statMap = feature.getStatisticMap();
319-
// for (String statName : statNames) {
320-
// Statistic stat = statMap.get(statName);
321-
// Double min = stat.getRange().getMin();
322-
// Double max = stat.getRange().getMax();
323-
// System.out.println(statName + "\n\tMin: " + min + "\n\tMax: " + max);
324-
// }
325-
// }
326-
327-
// System.out.println("TRAINING PROBABILITY - POSITIVE:");
328-
posBayesGraph.trainOn(posExamples);
329-
// Min/max stable
330-
// for (FeatureSet feature : features) {
331-
// List<String> statNames = feature.getDescriptions();
332-
// Map<String, Statistic> statMap = feature.getStatisticMap();
333-
// for (String statName : statNames) {
334-
// Statistic stat = statMap.get(statName);
335-
// Double min = stat.getRange().getMin();
336-
// Double max = stat.getRange().getMax();
337-
// System.out.println(statName + "\n\tMin: " + min + "\n\tMax: " + max);
338-
// }
339-
// }
340-
341-
// System.out.println("TRAINING PROBABILITY - NEGATIVE:");
295+
posBayesGraph.trainOn(posExamples);
342296
negBayesGraph.trainOn(negExamples);
343-
// Min/max stable
344-
// for (FeatureSet feature : features) {
345-
// List<String> statNames = feature.getDescriptions();
346-
// Map<String, Statistic> statMap = feature.getStatisticMap();
347-
// for (String statName : statNames) {
348-
// Statistic stat = statMap.get(statName);
349-
// Double min = stat.getRange().getMin();
350-
// Double max = stat.getRange().getMax();
351-
// System.out.println(statName + "\n\tMin: " + min + "\n\tMax: " + max);
352-
// }
353-
// }
297+
354298
System.out.println("Model has finished training on " + negativeExamples.size() + " negative Examples.");
355299
}
356300

src/main/java/edu/virginia/uvacluster/internal/feature/FeatureUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public static List<FeatureSet> parse(Set<String> featureKeys) {
4848
m.matches();
4949
numBins = Integer.parseInt(m.group(2));
5050

51-
// Check if Mean : weight -- to use alternative mean calculation
52-
// over all possible edges
51+
/* Check if Mean : weight -- to use alternative mean calculation
52+
over all possible edges */
5353
if (weightFeaturePattern.matcher(featureName).matches() && statName.equals("Mean"))
5454
statName = "mean possible";
5555

0 commit comments

Comments
 (0)