Author: scooter
Date: 2011-10-14 20:26:41 -0700 (Fri, 14 Oct 2011)
New Revision: 27199
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/AbstractClusterAlgorithm.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterAlgorithm.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterer.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/autosome/AutoSOMECluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KMeansCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMedoidCluster.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/treeview/dendroview/ColorPresets.java
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/treeview/dendroview/PixelSettingsSelector.java
Log:
More changes from Aaron in preparation for clusterMaker paper resubmission
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/AbstractClusterAlgorithm.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/AbstractClusterAlgorithm.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/AbstractClusterAlgorithm.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -122,6 +122,8 @@
public void halt() { canceled = true; }
+ public boolean halted() { return canceled; }
+
public ClusterResults getResults() { return results; }
public PropertyChangeSupport getPropertyChangeSupport() {return pcs;}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterAlgorithm.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterAlgorithm.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterAlgorithm.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -52,6 +52,7 @@
import cytoscape.task.TaskMonitor;
import clusterMaker.ClusterMaker;
+import clusterMaker.algorithms.AbstractClusterAlgorithm;
import clusterMaker.algorithms.attributeClusterers.silhouette.SilhouetteResult;
import clusterMaker.algorithms.attributeClusterers.silhouette.SilhouetteUtil;
@@ -80,6 +81,7 @@
protected boolean selectedOnly = false;
protected boolean zeroMissing = false;
protected boolean useSilhouette = false;
+ protected AbstractClusterAlgorithm clusterAlgorithm = null;
public Matrix getMatrix() { return matrix; }
public DistanceMetric getMetric() { return metric; }
@@ -92,6 +94,7 @@
public void setDebug(boolean val) { debug = val; }
public void setUseSilhouette(boolean val) { useSilhouette = val; }
public void setKMax(int val) { kMax = val; }
+ public void setClusterInterface(AbstractClusterAlgorithm alg) {
clusterAlgorithm = alg; }
/**
* This method is called by all of the attribute cluster algorithms to
update the
@@ -329,10 +332,12 @@
int nThreads =
Runtime.getRuntime().availableProcessors()-1;
if (nThreads > 1)
- runThreadedSilhouette(kMax, nIterations,
nThreads);
+ runThreadedSilhouette(kMax, nIterations,
nThreads, saveMonitor);
else
- runLinearSilhouette(kMax, nIterations);
+ runLinearSilhouette(kMax, nIterations,
saveMonitor);
+ if (halted()) return "Halted by user";
+
// Now get the results and find our best k
double maxSil = Double.MIN_VALUE;
for (int kEstimate = 2; kEstimate < kMax; kEstimate++) {
@@ -348,8 +353,12 @@
}
int[] clusters = new int[matrix.nRows()];
+
+ if (halted()) return "Halted by user";
+
// Cluster
int ifound = kcluster(nClusters, nIterations, matrix, metric,
clusters);
+ if (halted()) return "Halted by user";
// OK, now run our silhouette on our final result
SilhouetteResult sResult =
SilhouetteUtil.SilhouetteCalculator(matrix, metric, clusters);
@@ -412,7 +421,7 @@
}
}
- private void runThreadedSilhouette(int kMax, int nIterations, int
nThreads) {
+ private void runThreadedSilhouette(int kMax, int nIterations, int
nThreads, TaskMonitor saveMonitor) {
// Set up the thread pools
ExecutorService[] threadPools = new ExecutorService[nThreads];
for (int pool = 0; pool < threadPools.length; pool++)
@@ -421,7 +430,7 @@
// Dispatch a kmeans calculation to each pool
for (int kEstimate = 2; kEstimate < kMax; kEstimate++) {
int[] clusters = new int[matrix.nRows()];
- Runnable r = new RunKMeans(matrix, clusters, kEstimate,
nIterations);
+ Runnable r = new RunKMeans(matrix, clusters, kEstimate,
nIterations, saveMonitor);
threadPools[(kEstimate-2)%nThreads].submit(r);
// threadPools[0].submit(r);
}
@@ -435,29 +444,41 @@
}
}
- private void runLinearSilhouette(int kMax, int nIterations) {
+ private void runLinearSilhouette(int kMax, int nIterations, TaskMonitor
saveMonitor) {
for (int kEstimate = 2; kEstimate < kMax; kEstimate++) {
int[] clusters = new int[matrix.nRows()];
+ if (halted()) return;
+ if (saveMonitor != null) saveMonitor.setStatus("Getting
silhouette with a k estimate of "+kEstimate);
int ifound = kcluster(kEstimate, nIterations, matrix,
metric, clusters);
silhouetteResults[kEstimate] =
SilhouetteUtil.SilhouetteCalculator(matrix, metric, clusters);
}
}
+ private boolean halted() {
+ if (clusterAlgorithm != null)
+ return clusterAlgorithm.halted();
+ return false;
+ }
+
private class RunKMeans implements Runnable {
Matrix matrix;
int[] clusters;
int kEstimate;
int nIterations;
+ TaskMonitor saveMonitor = null;
- public RunKMeans (Matrix matrix, int[] clusters, int k, int
nIterations) {
+ public RunKMeans (Matrix matrix, int[] clusters, int k, int
nIterations, TaskMonitor saveMonitor) {
this.matrix = matrix;
this.clusters = clusters;
this.kEstimate = k;
this.nIterations = nIterations;
+ this.saveMonitor = saveMonitor;
}
public void run() {
int[] clusters = new int[matrix.nRows()];
+ if (halted()) return;
+ if (saveMonitor != null) saveMonitor.setStatus("Getting
silhouette with a k estimate of "+kEstimate);
int ifound = kcluster(kEstimate, nIterations, matrix,
metric, clusters);
try {
silhouetteResults[kEstimate] =
SilhouetteUtil.SilhouetteCalculator(matrix, metric, clusters);
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterer.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterer.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/AbstractAttributeClusterer.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -168,7 +168,7 @@
}
public void tunableChanged(Tunable t) {
- System.out.println("Tunable changed");
+ // System.out.println("Tunable changed");
if (t.getName().equals("useSilhouette")) {
useSilhouette = ((Boolean) t.getValue()).booleanValue();
if (useSilhouette) {
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/autosome/AutoSOMECluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/autosome/AutoSOMECluster.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/autosome/AutoSOMECluster.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -206,18 +206,19 @@
clusterProperties.add(new Tunable("pvalueThresh",
"P-Value Threshold",
Tunable.DOUBLE, new
Double(0.05),
- new Integer(0), new
Integer(1), 0));
+ new Double(0), new Double(1),
0));
// Number of iterations
clusterProperties.add(new Tunable("numThreads",
"Number of Threads (No.
CPUs)",
Tunable.INTEGER, new
Integer(Runtime.getRuntime().availableProcessors()),
new Integer(1), (Object)null,
0));
+
//normalization tunables
clusterProperties.add(new Tunable("tunables_panel2",
"Data Normalization",
- Tunable.GROUP, new
Integer(5), new Boolean(true), null, Tunable.COLLAPSABLE));
+ Tunable.GROUP, new
Integer(6), new Boolean(true), null, Tunable.COLLAPSABLE));
Tunable norm_mode = new Tunable("norm_mode",
"Normalization mode",
@@ -226,6 +227,7 @@
norm_mode.addTunableValueListener(this);
clusterProperties.add(norm_mode);
+
logscaling = new Tunable("logScaling",
"Log2 Scaling",
Tunable.BOOLEAN, new
Boolean(false));
@@ -248,7 +250,13 @@
new Object[]{"None", "Genes",
"Arrays", "Both"}, (Object)null, 0);
clusterProperties.add(sumSqr);
+ fillMV = new Tunable("fillMV", "Missing value handling",
+ Tunable.LIST, 0,
+ new Object[]{"Row Mean", "Row
Median", "Column Mean", "Column Median"}, (Object)null, 0);
+ if (ignoreMissing) fillMV.setImmutable(true);
+ clusterProperties.add(fillMV);
+
//fuzzy clustering tunables
clusterProperties.add(new Tunable("fuzzyclustering", "Fuzzy
Cluster Network Settings",
Tunable.GROUP, new Integer(4),
@@ -288,12 +296,6 @@
// new Boolean(false), null,
Tunable.COLLAPSABLE));
- fillMV = new Tunable("fillMV", "Missing value handling",
- Tunable.LIST, 0,
- new Object[]{"Row Mean", "Row
Median", "Column Mean", "Column Median"}, (Object)null, 0);
- if (ignoreMissing) fillMV.setImmutable(true);
- clusterProperties.add(fillMV);
-
//output tunables
clusterProperties.add(new Tunable("tunables_panel4",
"Data Output",
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KCluster.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KCluster.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -181,6 +181,8 @@
if (monitor != null)
monitor.setPercentCompleted(0);
+ // System.out.println("RUnning kmeans with "+nClusters+"
clusters");
+
random = null;
int nelements = matrix.nRows();
int ifound = 1;
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KMeansCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KMeansCluster.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmeans/KMeansCluster.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -193,7 +193,8 @@
this.monitor = monitor;
// Sanity check all of our settings
if (debug)
- logger.debug("Performing k-means cluster with
k="+kNumber+" using "+distanceMetric+" and attributes: "+dataAttributes);
+ logger.debug("Performing k-means cluster with
k="+kNumber+" using "+
+ distanceMetric+" and attributes:
"+dataAttributes);
if (dataAttributes == null || dataAttributes.length() == 0) {
if (monitor != null) {
@@ -216,6 +217,7 @@
algorithm.setDebug(debug);
algorithm.setUseSilhouette(useSilhouette);
algorithm.setKMax(kMax);
+ algorithm.setClusterInterface(this);
String resultsString = "K-Means results:";
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMedoidCluster.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMedoidCluster.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/algorithms/attributeClusterers/kmedoid/KMedoidCluster.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -216,6 +216,7 @@
algorithm.setDebug(debug);
algorithm.setUseSilhouette(useSilhouette);
algorithm.setKMax(kMax);
+ algorithm.setClusterInterface(this);
String resultsString = "K-Medoid results:";
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/treeview/dendroview/ColorPresets.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/treeview/dendroview/ColorPresets.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/treeview/dendroview/ColorPresets.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -104,10 +104,16 @@
public static ColorSet[] defaultColorSets;
static {
- defaultColorSets = new ColorSet[2];
- defaultColorSets[0] = new ColorSet("RedGreen", "#FF0000",
"#000000", "#00FF00", "#909090", "#FFFFFF");
- defaultColorSets[1] = new ColorSet("YellowCyan",
- "#FEFF00", "#000000", "#1BB7E5", "#909090",
"#FFFFFF");
+ defaultColorSets = new ColorSet[7];
+ defaultColorSets[0] = new ColorSet("RedYellow", "#FF0000",
"#000000", "#FEFF00", "#909090", "#FFFFFF");
+ defaultColorSets[1] = new ColorSet("YellowCyan", "#FEFF00",
"#000000", "#1BB7E5", "#909090", "#FFFFFF");
+ defaultColorSets[2] = new ColorSet("YellowPurple", "#FEFF00",
"#000000", "#CC00CC", "#909090", "#FFFFFF");
+ defaultColorSets[3] = new ColorSet("GreenPurple", "#00FF00",
"#000000", "#CC00CC", "#909090", "#FFFFFF");
+ defaultColorSets[4] = new ColorSet("YellowBlue", "#FEFF00",
"#000000", "#0000FF", "#909090", "#FFFFFF");
+ defaultColorSets[5] = new ColorSet("OrangeBlue", "#FF7F00",
"#000000", "#0000FF", "#909090", "#FFFFFF");
+ defaultColorSets[6] = new ColorSet("RedGreen", "#FF0000",
"#000000", "#00FF00", "#909090", "#FFFFFF");
+ // defaultColorSets[7] = new ColorSet("OrangePurple",
"#FF7F00", "#000000", "#CC00CC", "#909090", "#FFFFFF");
+ // defaultColorSets[8] = new ColorSet("YellowGreen", "#FEFF00",
"#000000", "#00FF00", "#909090", "#FFFFFF");
}
Modified:
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/treeview/dendroview/PixelSettingsSelector.java
===================================================================
---
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/treeview/dendroview/PixelSettingsSelector.java
2011-10-14 23:58:46 UTC (rev 27198)
+++
csplugins/trunk/ucsf/scooter/clusterMaker/src/clusterMaker/treeview/dendroview/PixelSettingsSelector.java
2011-10-15 03:26:41 UTC (rev 27199)
@@ -123,6 +123,7 @@
// color stuff...
gbc.gridy += 1;
+ gbc.gridx = 0;
add(new JLabel("Colors:"), gbc);
JPanel temp2 = new JPanel();
temp2.setBorder(border);
@@ -132,7 +133,10 @@
temp2.add(colorExtractorEditor);
temp2.add(new CEEButtons());
colorPresetsPanel = new ColorPresetsPanel();
- temp2.add(new JScrollPane(colorPresetsPanel,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS));
+ // temp2.add(colorPresetsPanel);
+ JScrollPane colorScrollPane = new
JScrollPane(colorPresetsPanel, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
+ colorScrollPane.setMinimumSize(new Dimension(100,60));
+ temp2.add(colorScrollPane);
gbc.gridx = 1;
add(temp2, gbc);
}
@@ -399,9 +403,11 @@
ColorPresetsPanel() {
redoLayout();
}
+ // TODO: Need to use a layout smarter than simple JPanel
public void redoLayout() {
removeAll();
int nPresets = m_presets.getNumPresets();
+ // setLayout(new GridLayout((nPresets/4)+1, 4));
JButton [] buttons = new JButton[nPresets];
for (int i = 0; i < nPresets; i++) {
JButton presetButton = new
JButton((m_presets.getPresetNames()) [i]);
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.