2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2005, The Institute for Genomic Research (TIGR). |
2 |
26 Feb 07 |
jari |
All rights reserved. |
2 |
26 Feb 07 |
jari |
4 |
*/ |
2 |
26 Feb 07 |
jari |
5 |
/* |
2 |
26 Feb 07 |
jari |
* KNNCGUI.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on September 2, 2003, 4:59 PM |
2 |
26 Feb 07 |
jari |
9 |
*/ |
2 |
26 Feb 07 |
jari |
10 |
|
2 |
26 Feb 07 |
jari |
11 |
package org.tigr.microarray.mev.cluster.gui.impl.knnc; |
2 |
26 Feb 07 |
jari |
12 |
|
2 |
26 Feb 07 |
jari |
13 |
import java.awt.event.ActionEvent; |
2 |
26 Feb 07 |
jari |
14 |
import java.awt.event.WindowEvent; |
2 |
26 Feb 07 |
jari |
15 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
16 |
import java.util.Arrays; |
2 |
26 Feb 07 |
jari |
17 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
18 |
|
2 |
26 Feb 07 |
jari |
19 |
import javax.swing.JFileChooser; |
2 |
26 Feb 07 |
jari |
20 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
21 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
22 |
import javax.swing.tree.DefaultMutableTreeNode; |
2 |
26 Feb 07 |
jari |
23 |
|
2 |
26 Feb 07 |
jari |
24 |
import org.tigr.microarray.mev.cluster.Cluster; |
2 |
26 Feb 07 |
jari |
25 |
import org.tigr.microarray.mev.cluster.Node; |
2 |
26 Feb 07 |
jari |
26 |
import org.tigr.microarray.mev.cluster.NodeList; |
2 |
26 Feb 07 |
jari |
27 |
import org.tigr.microarray.mev.cluster.NodeValueList; |
2 |
26 Feb 07 |
jari |
28 |
import org.tigr.microarray.mev.cluster.algorithm.AbortException; |
2 |
26 Feb 07 |
jari |
29 |
import org.tigr.microarray.mev.cluster.algorithm.Algorithm; |
2 |
26 Feb 07 |
jari |
30 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmData; |
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmEvent; |
2 |
26 Feb 07 |
jari |
32 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmException; |
2 |
26 Feb 07 |
jari |
33 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmListener; |
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmParameters; |
2 |
26 Feb 07 |
jari |
35 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
36 |
import org.tigr.microarray.mev.cluster.gui.IClusterGUI; |
2 |
26 Feb 07 |
jari |
37 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
38 |
import org.tigr.microarray.mev.cluster.gui.IDistanceMenu; |
2 |
26 Feb 07 |
jari |
39 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
41 |
import org.tigr.microarray.mev.cluster.gui.LeafInfo; |
2 |
26 Feb 07 |
jari |
42 |
import org.tigr.microarray.mev.cluster.gui.helpers.CentroidUserObject; |
2 |
26 Feb 07 |
jari |
43 |
import org.tigr.microarray.mev.cluster.gui.helpers.ClusterTableViewer; |
2 |
26 Feb 07 |
jari |
44 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentClusterCentroidViewer; |
2 |
26 Feb 07 |
jari |
45 |
import org.tigr.microarray.mev.cluster.gui.helpers.ExperimentClusterTableViewer; |
2 |
26 Feb 07 |
jari |
46 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.DialogListener; |
2 |
26 Feb 07 |
jari |
47 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.Progress; |
2 |
26 Feb 07 |
jari |
48 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLGUI; |
2 |
26 Feb 07 |
jari |
49 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLInitDialog; |
2 |
26 Feb 07 |
jari |
50 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLTreeData; |
2 |
26 Feb 07 |
jari |
51 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLViewer; |
2 |
26 Feb 07 |
jari |
52 |
import org.tigr.microarray.mev.script.scriptGUI.IScriptGUI; |
2 |
26 Feb 07 |
jari |
53 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
54 |
|
2 |
26 Feb 07 |
jari |
55 |
/** |
2 |
26 Feb 07 |
jari |
56 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
58 |
*/ |
2 |
26 Feb 07 |
jari |
59 |
public class KNNCGUI implements IClusterGUI, IScriptGUI { |
2 |
26 Feb 07 |
jari |
60 |
|
2 |
26 Feb 07 |
jari |
61 |
private Algorithm algorithm; |
2 |
26 Feb 07 |
jari |
62 |
private Progress progress; |
2 |
26 Feb 07 |
jari |
63 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
64 |
private IData data; |
2 |
26 Feb 07 |
jari |
65 |
private int[][] clusters; |
2 |
26 Feb 07 |
jari |
66 |
private FloatMatrix means; |
2 |
26 Feb 07 |
jari |
67 |
private FloatMatrix variances; |
2 |
26 Feb 07 |
jari |
68 |
private int k, usedNumNeibs; |
2 |
26 Feb 07 |
jari |
69 |
KNNClassificationEditor kcEditor; |
2 |
26 Feb 07 |
jari |
70 |
boolean validate, classifyGenes, useVarianceFilter, useCorrelFilter; |
2 |
26 Feb 07 |
jari |
71 |
int numClasses, numVarFilteredVectors, numNeighbors, numPerms; |
2 |
26 Feb 07 |
jari |
72 |
double correlPValue; |
2 |
26 Feb 07 |
jari |
73 |
Vector[] classificationVector; |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
75 |
int[] classIndices, classes, origNumInFiltTrgSetByClass, numberCorrectlyClassifiedByClass, numberIncorrectlyClassifiedByClass; |
2 |
26 Feb 07 |
jari |
76 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of KNNCGUI */ |
2 |
26 Feb 07 |
jari |
78 |
public KNNCGUI() { |
2 |
26 Feb 07 |
jari |
79 |
} |
2 |
26 Feb 07 |
jari |
80 |
|
2 |
26 Feb 07 |
jari |
/** This method should return a tree with calculation results or |
2 |
26 Feb 07 |
jari |
* null, if analysis start was canceled. |
2 |
26 Feb 07 |
jari |
83 |
* |
2 |
26 Feb 07 |
jari |
* @param framework the reference to <code>IFramework</code> implementation, |
2 |
26 Feb 07 |
jari |
* which is used to obtain an initial analysis data and parameters. |
2 |
26 Feb 07 |
jari |
* @throws AlgorithmException if calculation was failed. |
2 |
26 Feb 07 |
jari |
* @throws AbortException if calculation was canceled. |
2 |
26 Feb 07 |
jari |
* @see IFramework |
2 |
26 Feb 07 |
jari |
89 |
*/ |
2 |
26 Feb 07 |
jari |
90 |
public DefaultMutableTreeNode execute(IFramework framework) throws AlgorithmException { |
2 |
26 Feb 07 |
jari |
91 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
92 |
this.experiment = framework.getData().getExperiment(); |
2 |
26 Feb 07 |
jari |
//this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
94 |
|
2 |
26 Feb 07 |
jari |
95 |
int number_of_samples = experiment.getNumberOfSamples(); |
2 |
26 Feb 07 |
jari |
96 |
int number_of_genes = experiment.getNumberOfGenes(); |
2 |
26 Feb 07 |
jari |
97 |
|
2 |
26 Feb 07 |
jari |
98 |
KNNClassifyOrValidateDialog kCOrVDialog = new KNNClassifyOrValidateDialog((JFrame)framework.getFrame(), true); |
2 |
26 Feb 07 |
jari |
99 |
kCOrVDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
100 |
validate = !(kCOrVDialog.classify()); |
2 |
26 Feb 07 |
jari |
101 |
if (!kCOrVDialog.isOkPressed()) { |
2 |
26 Feb 07 |
jari |
102 |
return null; |
2 |
26 Feb 07 |
jari |
103 |
} |
2 |
26 Feb 07 |
jari |
104 |
|
2 |
26 Feb 07 |
jari |
105 |
if (!validate) { |
2 |
26 Feb 07 |
jari |
106 |
KNNCStatusDialog kStatDialog = new KNNCStatusDialog((JFrame)framework.getFrame(), false); |
2 |
26 Feb 07 |
jari |
107 |
kStatDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
108 |
KNNCFirstDialog kDialog = new KNNCFirstDialog((JFrame)framework.getFrame(), true, framework); |
2 |
26 Feb 07 |
jari |
109 |
kDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
110 |
|
2 |
26 Feb 07 |
jari |
111 |
if (!kDialog.isOkPressed()) { |
2 |
26 Feb 07 |
jari |
112 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
113 |
return null; |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
classifyGenes = kDialog.classifyGenes(); |
2 |
26 Feb 07 |
jari |
117 |
numClasses = kDialog.getNumClasses(); |
2 |
26 Feb 07 |
jari |
118 |
numNeighbors = kDialog.getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
119 |
useVarianceFilter = kDialog.useVarianceFilter(); |
2 |
26 Feb 07 |
jari |
120 |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
121 |
numVarFilteredVectors = kDialog.getNumVectors(); |
2 |
26 Feb 07 |
jari |
122 |
} |
2 |
26 Feb 07 |
jari |
123 |
useCorrelFilter = kDialog.useCorrelFilter(); |
2 |
26 Feb 07 |
jari |
124 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
125 |
correlPValue = kDialog.getCorrPValue(); |
2 |
26 Feb 07 |
jari |
126 |
numPerms = kDialog.getNumPerms(); |
2 |
26 Feb 07 |
jari |
127 |
} |
2 |
26 Feb 07 |
jari |
128 |
k = numClasses*4 + 1; |
2 |
26 Feb 07 |
jari |
129 |
kcEditor = new KNNClassificationEditor(framework, classifyGenes, numClasses); |
2 |
26 Feb 07 |
jari |
130 |
if (kDialog.createNewTrgSet()) { |
2 |
26 Feb 07 |
jari |
131 |
kcEditor.showModal(true); |
2 |
26 Feb 07 |
jari |
132 |
} else { |
2 |
26 Feb 07 |
jari |
133 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
134 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
135 |
int returnVal = fc.showOpenDialog(framework.getFrame()); |
2 |
26 Feb 07 |
jari |
136 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
137 |
kcEditor.loadFromFile(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
138 |
} else { |
2 |
26 Feb 07 |
jari |
139 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
140 |
return null; |
2 |
26 Feb 07 |
jari |
141 |
} |
2 |
26 Feb 07 |
jari |
142 |
} |
2 |
26 Feb 07 |
jari |
143 |
|
2 |
26 Feb 07 |
jari |
144 |
if (kcEditor.fileIsIncompatible()) { |
2 |
26 Feb 07 |
jari |
145 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
146 |
return null; |
2 |
26 Feb 07 |
jari |
147 |
} |
2 |
26 Feb 07 |
jari |
148 |
|
2 |
26 Feb 07 |
jari |
149 |
while (!kcEditor.isNextPressed()) { |
2 |
26 Feb 07 |
jari |
150 |
continue; |
2 |
26 Feb 07 |
jari |
151 |
} |
2 |
26 Feb 07 |
jari |
152 |
|
2 |
26 Feb 07 |
jari |
//System.out.println("KNNCGUI: kcEditor.proceed() = " + kcEditor.proceed()); |
2 |
26 Feb 07 |
jari |
154 |
|
2 |
26 Feb 07 |
jari |
155 |
if (!kcEditor.proceed()) { |
2 |
26 Feb 07 |
jari |
156 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
157 |
return null; |
2 |
26 Feb 07 |
jari |
158 |
} |
2 |
26 Feb 07 |
jari |
159 |
|
2 |
26 Feb 07 |
jari |
// **** DONE UP TO HERE: 9_25_03, AT THIS POINT, NEED TO getClassificaiton() from kcEditor |
2 |
26 Feb 07 |
jari |
161 |
|
2 |
26 Feb 07 |
jari |
162 |
classificationVector = kcEditor.getClassification(); |
2 |
26 Feb 07 |
jari |
163 |
classIndices = new int[classificationVector[0].size()]; |
2 |
26 Feb 07 |
jari |
164 |
classes = new int[classificationVector[1].size()]; |
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
166 |
for (int i = 0; i < classIndices.length; i++) { |
2 |
26 Feb 07 |
jari |
167 |
classIndices[i] = ((Integer)(classificationVector[0].get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
168 |
classes[i] = ((Integer)(classificationVector[1].get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
169 |
} |
2 |
26 Feb 07 |
jari |
170 |
|
2 |
26 Feb 07 |
jari |
171 |
boolean isHierarchicalTree = kDialog.drawTrees(); |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
IDistanceMenu menu = framework.getDistanceMenu(); |
2 |
26 Feb 07 |
jari |
174 |
int function = menu.getDistanceFunction(); |
2 |
26 Feb 07 |
jari |
175 |
if (function == Algorithm.DEFAULT) { |
2 |
26 Feb 07 |
jari |
176 |
function = Algorithm.EUCLIDEAN; |
2 |
26 Feb 07 |
jari |
177 |
} |
2 |
26 Feb 07 |
jari |
178 |
|
2 |
26 Feb 07 |
jari |
// hcl init |
2 |
26 Feb 07 |
jari |
180 |
int hcl_method = 0; |
2 |
26 Feb 07 |
jari |
181 |
boolean hcl_samples = false; |
2 |
26 Feb 07 |
jari |
182 |
boolean hcl_genes = false; |
2 |
26 Feb 07 |
jari |
183 |
int hcl_function = 4; |
2 |
26 Feb 07 |
jari |
184 |
boolean hcl_absolute = false; |
2 |
26 Feb 07 |
jari |
185 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
186 |
HCLInitDialog hcl_dialog = new HCLInitDialog(framework.getFrame(), menu.getFunctionName(function), menu.isAbsoluteDistance(), true); |
2 |
26 Feb 07 |
jari |
187 |
if (hcl_dialog.showModal() != JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
188 |
return null; |
2 |
26 Feb 07 |
jari |
189 |
} |
2 |
26 Feb 07 |
jari |
190 |
hcl_method = hcl_dialog.getMethod(); |
2 |
26 Feb 07 |
jari |
191 |
hcl_samples = hcl_dialog.isClusterExperiments(); |
2 |
26 Feb 07 |
jari |
192 |
hcl_genes = hcl_dialog.isClusterGenes(); |
2 |
26 Feb 07 |
jari |
193 |
hcl_function = hcl_dialog.getDistanceMetric(); |
2 |
26 Feb 07 |
jari |
194 |
hcl_absolute = hcl_dialog.getAbsoluteSelection(); |
2 |
26 Feb 07 |
jari |
195 |
} |
2 |
26 Feb 07 |
jari |
196 |
|
2 |
26 Feb 07 |
jari |
197 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
198 |
|
2 |
26 Feb 07 |
jari |
199 |
try { |
2 |
26 Feb 07 |
jari |
//System.out.println("Proceeded to algorithm"); |
2 |
26 Feb 07 |
jari |
201 |
algorithm = framework.getAlgorithmFactory().getAlgorithm("KNNC"); |
2 |
26 Feb 07 |
jari |
202 |
algorithm.addAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
203 |
|
2 |
26 Feb 07 |
jari |
204 |
this.progress = new Progress(framework.getFrame(), "KNN classification", listener); |
2 |
26 Feb 07 |
jari |
205 |
this.progress.show(); |
2 |
26 Feb 07 |
jari |
206 |
|
2 |
26 Feb 07 |
jari |
207 |
AlgorithmData data = new AlgorithmData(); |
2 |
26 Feb 07 |
jari |
208 |
|
2 |
26 Feb 07 |
jari |
209 |
data.addMatrix("experiment", experiment.getMatrix()); |
2 |
26 Feb 07 |
jari |
210 |
data.addParam("distance-factor", String.valueOf(1.0f)); |
2 |
26 Feb 07 |
jari |
211 |
|
2 |
26 Feb 07 |
jari |
212 |
data.addParam("distance-absolute", String.valueOf(menu.isAbsoluteDistance())); |
2 |
26 Feb 07 |
jari |
213 |
|
2 |
26 Feb 07 |
jari |
214 |
data.addParam("distance-function", String.valueOf(function)); |
2 |
26 Feb 07 |
jari |
215 |
|
2 |
26 Feb 07 |
jari |
216 |
data.addParam("validate", String.valueOf(validate)); |
2 |
26 Feb 07 |
jari |
217 |
data.addParam("classifyGenes", String.valueOf(classifyGenes)); |
2 |
26 Feb 07 |
jari |
218 |
if (classifyGenes) { |
2 |
26 Feb 07 |
jari |
219 |
data.addMatrix("experiment", experiment.getMatrix()); |
2 |
26 Feb 07 |
jari |
220 |
} else { |
2 |
26 Feb 07 |
jari |
221 |
data.addMatrix("experiment", experiment.getMatrix().transpose()); |
2 |
26 Feb 07 |
jari |
222 |
} |
2 |
26 Feb 07 |
jari |
223 |
data.addParam("useVarianceFilter", String.valueOf(useVarianceFilter)); |
2 |
26 Feb 07 |
jari |
224 |
data.addParam("useCorrelFilter", String.valueOf(useCorrelFilter)); |
2 |
26 Feb 07 |
jari |
225 |
data.addParam("numClasses", String.valueOf(numClasses)); |
2 |
26 Feb 07 |
jari |
226 |
data.addParam("numNeighbors", String.valueOf(numNeighbors)); |
2 |
26 Feb 07 |
jari |
227 |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
228 |
data.addParam("numVarFilteredVectors", String.valueOf(numVarFilteredVectors)); |
2 |
26 Feb 07 |
jari |
229 |
} |
2 |
26 Feb 07 |
jari |
230 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
231 |
data.addParam("correlPValue", String.valueOf((float)correlPValue)); |
2 |
26 Feb 07 |
jari |
232 |
data.addParam("numPerms", String.valueOf(numPerms)); |
2 |
26 Feb 07 |
jari |
233 |
} |
2 |
26 Feb 07 |
jari |
234 |
data.addIntArray("classIndices", classIndices); |
2 |
26 Feb 07 |
jari |
235 |
data.addIntArray("classes", classes); |
2 |
26 Feb 07 |
jari |
// hcl parameters |
2 |
26 Feb 07 |
jari |
237 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
238 |
data.addParam("hierarchical-tree", String.valueOf(true)); |
2 |
26 Feb 07 |
jari |
239 |
data.addParam("method-linkage", String.valueOf(hcl_method)); |
2 |
26 Feb 07 |
jari |
240 |
data.addParam("calculate-genes", String.valueOf(hcl_genes)); |
2 |
26 Feb 07 |
jari |
241 |
data.addParam("calculate-experiments", String.valueOf(hcl_samples)); |
2 |
26 Feb 07 |
jari |
242 |
data.addParam("hcl-distance-function", String.valueOf(hcl_function)); |
2 |
26 Feb 07 |
jari |
243 |
data.addParam("hcl-distance-absolute", String.valueOf(hcl_absolute)); |
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
|
2 |
26 Feb 07 |
jari |
246 |
long start = System.currentTimeMillis(); |
2 |
26 Feb 07 |
jari |
247 |
AlgorithmData result = algorithm.execute(data); |
2 |
26 Feb 07 |
jari |
248 |
long time = System.currentTimeMillis() - start; |
2 |
26 Feb 07 |
jari |
// getting the results |
2 |
26 Feb 07 |
jari |
250 |
Cluster result_cluster = result.getCluster("cluster"); |
2 |
26 Feb 07 |
jari |
251 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
252 |
this.clusters = new int[k][]; |
2 |
26 Feb 07 |
jari |
253 |
for (int i=0; i<k; i++) { |
2 |
26 Feb 07 |
jari |
254 |
clusters[i] = nodeList.getNode(i).getFeaturesIndexes(); |
2 |
26 Feb 07 |
jari |
255 |
} |
2 |
26 Feb 07 |
jari |
256 |
this.means = result.getMatrix("clusters_means"); |
2 |
26 Feb 07 |
jari |
257 |
this.variances = result.getMatrix("clusters_variances"); |
2 |
26 Feb 07 |
jari |
258 |
|
2 |
26 Feb 07 |
jari |
259 |
this.numberCorrectlyClassifiedByClass = result.getIntArray("numberCorrectlyClassifiedByClass"); |
2 |
26 Feb 07 |
jari |
260 |
this.numberIncorrectlyClassifiedByClass = result.getIntArray("numberIncorrectlyClassifiedByClass"); |
2 |
26 Feb 07 |
jari |
261 |
this.origNumInFiltTrgSetByClass = result.getIntArray("origNumInFiltTrgSetByClass"); |
2 |
26 Feb 07 |
jari |
262 |
|
2 |
26 Feb 07 |
jari |
263 |
GeneralInfo info = new GeneralInfo(); |
2 |
26 Feb 07 |
jari |
//info.clusters = k; |
2 |
26 Feb 07 |
jari |
265 |
info.time = time; |
2 |
26 Feb 07 |
jari |
266 |
info.hcl = isHierarchicalTree; |
2 |
26 Feb 07 |
jari |
267 |
info.hcl_genes = hcl_genes; |
2 |
26 Feb 07 |
jari |
268 |
info.hcl_samples = hcl_samples; |
2 |
26 Feb 07 |
jari |
269 |
info.hcl_method = hcl_method; |
2 |
26 Feb 07 |
jari |
270 |
info.numClasses = numClasses; |
2 |
26 Feb 07 |
jari |
271 |
info.numNeighbors = numNeighbors; |
2 |
26 Feb 07 |
jari |
272 |
info.usedVarFilter = useVarianceFilter; |
2 |
26 Feb 07 |
jari |
273 |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
274 |
info.numVarFiltered = this.numVarFilteredVectors; |
2 |
26 Feb 07 |
jari |
275 |
info.postVarDataSetSize = (result.getParams()).getInt("postVarDataSetSize"); |
2 |
26 Feb 07 |
jari |
276 |
info.postVarClassSetSize = (result.getParams()).getInt("postVarClassSetSize"); |
2 |
26 Feb 07 |
jari |
277 |
} |
2 |
26 Feb 07 |
jari |
278 |
info.usedCorrelFilter = this.useCorrelFilter; |
2 |
26 Feb 07 |
jari |
279 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
280 |
info.correlPvalue = this.correlPValue; |
2 |
26 Feb 07 |
jari |
281 |
info.numPerms = this.numPerms; |
2 |
26 Feb 07 |
jari |
282 |
info.postCorrDataSetSize = (result.getParams()).getInt("postCorrDataSetSize"); |
2 |
26 Feb 07 |
jari |
283 |
} |
2 |
26 Feb 07 |
jari |
284 |
info.usedNumNeibs = (result.getParams()).getInt("usedNumNeibs"); |
2 |
26 Feb 07 |
jari |
285 |
info.origDataSetSize = (result.getParams()).getInt("origDataSetSize"); |
2 |
26 Feb 07 |
jari |
286 |
info.origClassSetSize = (result.getParams()).getInt("origClassSetSize"); |
2 |
26 Feb 07 |
jari |
287 |
|
2 |
26 Feb 07 |
jari |
288 |
return createResultTree(result_cluster, info); |
2 |
26 Feb 07 |
jari |
289 |
|
2 |
26 Feb 07 |
jari |
290 |
} finally { |
2 |
26 Feb 07 |
jari |
291 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
292 |
if (algorithm != null) { |
2 |
26 Feb 07 |
jari |
293 |
algorithm.removeAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
294 |
} |
2 |
26 Feb 07 |
jari |
295 |
if (progress != null) { |
2 |
26 Feb 07 |
jari |
296 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
297 |
} |
2 |
26 Feb 07 |
jari |
298 |
/* |
2 |
26 Feb 07 |
jari |
if (monitor != null) { |
2 |
26 Feb 07 |
jari |
monitor.dispose(); |
2 |
26 Feb 07 |
jari |
301 |
} |
2 |
26 Feb 07 |
jari |
302 |
*/ |
2 |
26 Feb 07 |
jari |
303 |
} |
2 |
26 Feb 07 |
jari |
304 |
|
2 |
26 Feb 07 |
jari |
305 |
} else {// if (validate) |
2 |
26 Feb 07 |
jari |
306 |
KNNCStatusDialog kStatDialog = new KNNCStatusDialog((JFrame)framework.getFrame(), false); |
2 |
26 Feb 07 |
jari |
307 |
kStatDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
308 |
KNNCValidationFirstDialog kvDialog = new KNNCValidationFirstDialog((JFrame)framework.getFrame(), true, framework); |
2 |
26 Feb 07 |
jari |
309 |
kvDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
310 |
|
2 |
26 Feb 07 |
jari |
311 |
if (!kvDialog.isOkPressed()) { |
2 |
26 Feb 07 |
jari |
312 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
313 |
return null; |
2 |
26 Feb 07 |
jari |
314 |
} |
2 |
26 Feb 07 |
jari |
315 |
|
2 |
26 Feb 07 |
jari |
316 |
classifyGenes = kvDialog.classifyGenes(); |
2 |
26 Feb 07 |
jari |
317 |
numClasses = kvDialog.getNumClasses(); |
2 |
26 Feb 07 |
jari |
318 |
numNeighbors = kvDialog.getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
319 |
|
2 |
26 Feb 07 |
jari |
320 |
useCorrelFilter = kvDialog.useCorrelFilter(); |
2 |
26 Feb 07 |
jari |
321 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
322 |
correlPValue = kvDialog.getCorrPValue(); |
2 |
26 Feb 07 |
jari |
323 |
numPerms = kvDialog.getNumPerms(); |
2 |
26 Feb 07 |
jari |
324 |
} |
2 |
26 Feb 07 |
jari |
325 |
k = numClasses*4 + 1; |
2 |
26 Feb 07 |
jari |
326 |
kcEditor = new KNNClassificationEditor(framework, classifyGenes, numClasses); |
2 |
26 Feb 07 |
jari |
327 |
if (kvDialog.createNewTrgSet()) { |
2 |
26 Feb 07 |
jari |
//kcEditor = new KNNClassificationEditor(framework, classifyGenes, numClasses); |
2 |
26 Feb 07 |
jari |
329 |
kcEditor.showModal(true); |
2 |
26 Feb 07 |
jari |
330 |
} else { |
2 |
26 Feb 07 |
jari |
331 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
332 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
333 |
int returnVal = fc.showOpenDialog(framework.getFrame()); |
2 |
26 Feb 07 |
jari |
334 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
//kcEditor = new KNNClassificationEditor(framework, classifyGenes, numClasses); |
2 |
26 Feb 07 |
jari |
//kcEditor.setVisible(true); |
2 |
26 Feb 07 |
jari |
337 |
kcEditor.loadFromFile(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
338 |
} else { |
2 |
26 Feb 07 |
jari |
339 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
340 |
return null; |
2 |
26 Feb 07 |
jari |
341 |
} |
2 |
26 Feb 07 |
jari |
342 |
} |
2 |
26 Feb 07 |
jari |
343 |
|
2 |
26 Feb 07 |
jari |
344 |
if (kcEditor.fileIsIncompatible()) { |
2 |
26 Feb 07 |
jari |
345 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
346 |
return null; |
2 |
26 Feb 07 |
jari |
347 |
} |
2 |
26 Feb 07 |
jari |
348 |
|
2 |
26 Feb 07 |
jari |
349 |
while (!kcEditor.isNextPressed()) { |
2 |
26 Feb 07 |
jari |
350 |
continue; |
2 |
26 Feb 07 |
jari |
351 |
} |
2 |
26 Feb 07 |
jari |
352 |
if (!kcEditor.proceed()) { |
2 |
26 Feb 07 |
jari |
353 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
354 |
return null; |
2 |
26 Feb 07 |
jari |
355 |
} |
2 |
26 Feb 07 |
jari |
356 |
|
2 |
26 Feb 07 |
jari |
357 |
classificationVector = kcEditor.getClassification(); |
2 |
26 Feb 07 |
jari |
358 |
classIndices = new int[classificationVector[0].size()]; |
2 |
26 Feb 07 |
jari |
359 |
classes = new int[classificationVector[1].size()]; |
2 |
26 Feb 07 |
jari |
360 |
|
2 |
26 Feb 07 |
jari |
361 |
for (int i = 0; i < classIndices.length; i++) { |
2 |
26 Feb 07 |
jari |
362 |
classIndices[i] = ((Integer)(classificationVector[0].get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
363 |
classes[i] = ((Integer)(classificationVector[1].get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
364 |
} |
2 |
26 Feb 07 |
jari |
365 |
|
2 |
26 Feb 07 |
jari |
366 |
boolean isHierarchicalTree = kvDialog.drawTrees(); |
2 |
26 Feb 07 |
jari |
367 |
|
2 |
26 Feb 07 |
jari |
368 |
IDistanceMenu menu = framework.getDistanceMenu(); |
2 |
26 Feb 07 |
jari |
369 |
int function = menu.getDistanceFunction(); |
2 |
26 Feb 07 |
jari |
370 |
if (function == Algorithm.DEFAULT) { |
2 |
26 Feb 07 |
jari |
371 |
function = Algorithm.EUCLIDEAN; |
2 |
26 Feb 07 |
jari |
372 |
} |
2 |
26 Feb 07 |
jari |
373 |
|
2 |
26 Feb 07 |
jari |
// hcl init |
2 |
26 Feb 07 |
jari |
375 |
int hcl_method = 0; |
2 |
26 Feb 07 |
jari |
376 |
boolean hcl_samples = false; |
2 |
26 Feb 07 |
jari |
377 |
boolean hcl_genes = false; |
2 |
26 Feb 07 |
jari |
378 |
int hcl_function = 4; |
2 |
26 Feb 07 |
jari |
379 |
boolean hcl_absolute = false; |
2 |
26 Feb 07 |
jari |
380 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
381 |
HCLInitDialog hcl_dialog = new HCLInitDialog(framework.getFrame(), menu.getFunctionName(function), menu.isAbsoluteDistance(), true); |
2 |
26 Feb 07 |
jari |
382 |
if (hcl_dialog.showModal() != JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
383 |
return null; |
2 |
26 Feb 07 |
jari |
384 |
} |
2 |
26 Feb 07 |
jari |
385 |
hcl_method = hcl_dialog.getMethod(); |
2 |
26 Feb 07 |
jari |
386 |
hcl_samples = hcl_dialog.isClusterExperiments(); |
2 |
26 Feb 07 |
jari |
387 |
hcl_genes = hcl_dialog.isClusterGenes(); |
2 |
26 Feb 07 |
jari |
388 |
hcl_function = hcl_dialog.getDistanceMetric(); |
2 |
26 Feb 07 |
jari |
389 |
hcl_absolute = hcl_dialog.getAbsoluteSelection(); |
2 |
26 Feb 07 |
jari |
390 |
} |
2 |
26 Feb 07 |
jari |
391 |
|
2 |
26 Feb 07 |
jari |
392 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
393 |
|
2 |
26 Feb 07 |
jari |
394 |
try { |
2 |
26 Feb 07 |
jari |
//System.out.println("Proceeded to algorithm"); |
2 |
26 Feb 07 |
jari |
396 |
algorithm = framework.getAlgorithmFactory().getAlgorithm("KNNC"); |
2 |
26 Feb 07 |
jari |
397 |
algorithm.addAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
398 |
|
2 |
26 Feb 07 |
jari |
399 |
this.progress = new Progress(framework.getFrame(), "KNN classification", listener); |
2 |
26 Feb 07 |
jari |
400 |
this.progress.show(); |
2 |
26 Feb 07 |
jari |
401 |
|
2 |
26 Feb 07 |
jari |
402 |
AlgorithmData data = new AlgorithmData(); |
2 |
26 Feb 07 |
jari |
403 |
|
2 |
26 Feb 07 |
jari |
404 |
data.addMatrix("experiment", experiment.getMatrix()); |
2 |
26 Feb 07 |
jari |
405 |
data.addParam("distance-factor", String.valueOf(1.0f)); |
2 |
26 Feb 07 |
jari |
406 |
data.addParam("distance-absolute", String.valueOf(menu.isAbsoluteDistance())); |
2 |
26 Feb 07 |
jari |
407 |
|
2 |
26 Feb 07 |
jari |
408 |
data.addParam("distance-function", String.valueOf(function)); |
2 |
26 Feb 07 |
jari |
409 |
|
2 |
26 Feb 07 |
jari |
410 |
data.addParam("validate", String.valueOf(validate)); |
2 |
26 Feb 07 |
jari |
411 |
data.addParam("classifyGenes", String.valueOf(classifyGenes)); |
2 |
26 Feb 07 |
jari |
412 |
if (classifyGenes) { |
2 |
26 Feb 07 |
jari |
413 |
data.addMatrix("experiment", experiment.getMatrix()); |
2 |
26 Feb 07 |
jari |
414 |
} else { |
2 |
26 Feb 07 |
jari |
415 |
data.addMatrix("experiment", experiment.getMatrix().transpose()); |
2 |
26 Feb 07 |
jari |
416 |
} |
2 |
26 Feb 07 |
jari |
//data.addParam("useVarianceFilter", String.valueOf(useVarianceFilter)); |
2 |
26 Feb 07 |
jari |
418 |
data.addParam("useCorrelFilter", String.valueOf(useCorrelFilter)); |
2 |
26 Feb 07 |
jari |
419 |
data.addParam("numClasses", String.valueOf(numClasses)); |
2 |
26 Feb 07 |
jari |
420 |
data.addParam("numNeighbors", String.valueOf(numNeighbors)); |
2 |
26 Feb 07 |
jari |
421 |
/* |
2 |
26 Feb 07 |
jari |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
data.addParam("numVarFilteredVectors", String.valueOf(numVarFilteredVectors)); |
2 |
26 Feb 07 |
jari |
424 |
} |
2 |
26 Feb 07 |
jari |
425 |
*/ |
2 |
26 Feb 07 |
jari |
426 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
427 |
data.addParam("correlPValue", String.valueOf((float)correlPValue)); |
2 |
26 Feb 07 |
jari |
428 |
data.addParam("numPerms", String.valueOf(numPerms)); |
2 |
26 Feb 07 |
jari |
429 |
} |
2 |
26 Feb 07 |
jari |
430 |
data.addIntArray("classIndices", classIndices); |
2 |
26 Feb 07 |
jari |
431 |
data.addIntArray("classes", classes); |
2 |
26 Feb 07 |
jari |
// hcl parameters |
2 |
26 Feb 07 |
jari |
433 |
|
2 |
26 Feb 07 |
jari |
434 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
435 |
data.addParam("hierarchical-tree", String.valueOf(true)); |
2 |
26 Feb 07 |
jari |
436 |
data.addParam("method-linkage", String.valueOf(hcl_method)); |
2 |
26 Feb 07 |
jari |
437 |
data.addParam("calculate-genes", String.valueOf(hcl_genes)); |
2 |
26 Feb 07 |
jari |
438 |
data.addParam("calculate-experiments", String.valueOf(hcl_samples)); |
2 |
26 Feb 07 |
jari |
439 |
data.addParam("hcl-distance-function", String.valueOf(hcl_function)); |
2 |
26 Feb 07 |
jari |
440 |
data.addParam("hcl-distance-absolute", String.valueOf(hcl_absolute)); |
2 |
26 Feb 07 |
jari |
441 |
} |
2 |
26 Feb 07 |
jari |
442 |
|
2 |
26 Feb 07 |
jari |
443 |
long start = System.currentTimeMillis(); |
2 |
26 Feb 07 |
jari |
444 |
AlgorithmData result = algorithm.execute(data); |
2 |
26 Feb 07 |
jari |
445 |
long time = System.currentTimeMillis() - start; |
2 |
26 Feb 07 |
jari |
// getting the results |
2 |
26 Feb 07 |
jari |
447 |
Cluster result_cluster = result.getCluster("cluster"); |
2 |
26 Feb 07 |
jari |
448 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
449 |
k = numClasses + 1; |
2 |
26 Feb 07 |
jari |
450 |
this.clusters = new int[k][]; |
2 |
26 Feb 07 |
jari |
451 |
for (int i=0; i<k; i++) { |
2 |
26 Feb 07 |
jari |
452 |
clusters[i] = nodeList.getNode(i).getFeaturesIndexes(); |
2 |
26 Feb 07 |
jari |
453 |
} |
2 |
26 Feb 07 |
jari |
454 |
this.means = result.getMatrix("clusters_means"); |
2 |
26 Feb 07 |
jari |
455 |
this.variances = result.getMatrix("clusters_variances"); |
2 |
26 Feb 07 |
jari |
456 |
|
2 |
26 Feb 07 |
jari |
457 |
this.numberCorrectlyClassifiedByClass = result.getIntArray("numberCorrectlyClassifiedByClass"); |
2 |
26 Feb 07 |
jari |
458 |
this.numberIncorrectlyClassifiedByClass = result.getIntArray("numberIncorrectlyClassifiedByClass"); |
2 |
26 Feb 07 |
jari |
459 |
this.origNumInFiltTrgSetByClass = result.getIntArray("origNumInFiltTrgSetByClass"); |
2 |
26 Feb 07 |
jari |
460 |
|
2 |
26 Feb 07 |
jari |
461 |
GeneralInfo info = new GeneralInfo(); |
2 |
26 Feb 07 |
jari |
//info.clusters = k; |
2 |
26 Feb 07 |
jari |
463 |
info.time = time; |
2 |
26 Feb 07 |
jari |
464 |
info.hcl = isHierarchicalTree; |
2 |
26 Feb 07 |
jari |
465 |
info.hcl_genes = hcl_genes; |
2 |
26 Feb 07 |
jari |
466 |
info.hcl_samples = hcl_samples; |
2 |
26 Feb 07 |
jari |
467 |
info.hcl_method = hcl_method; |
2 |
26 Feb 07 |
jari |
468 |
info.numClasses = numClasses; |
2 |
26 Feb 07 |
jari |
469 |
info.numNeighbors = numNeighbors; |
2 |
26 Feb 07 |
jari |
//info.usedVarFilter = useVarianceFilter; |
2 |
26 Feb 07 |
jari |
471 |
/* |
2 |
26 Feb 07 |
jari |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
info.numVarFiltered = this.numVarFilteredVectors; |
2 |
26 Feb 07 |
jari |
info.postVarDataSetSize = (result.getParams()).getInt("postVarDataSetSize"); |
2 |
26 Feb 07 |
jari |
info.postVarClassSetSize = (result.getParams()).getInt("postVarClassSetSize"); |
2 |
26 Feb 07 |
jari |
476 |
} |
2 |
26 Feb 07 |
jari |
477 |
*/ |
2 |
26 Feb 07 |
jari |
478 |
info.usedCorrelFilter = this.useCorrelFilter; |
2 |
26 Feb 07 |
jari |
479 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
480 |
info.correlPvalue = this.correlPValue; |
2 |
26 Feb 07 |
jari |
481 |
info.numPerms = this.numPerms; |
2 |
26 Feb 07 |
jari |
//info.postCorrDataSetSize = (result.getParams()).getInt("postCorrDataSetSize"); |
2 |
26 Feb 07 |
jari |
483 |
} |
2 |
26 Feb 07 |
jari |
484 |
info.usedNumNeibs = (result.getParams()).getInt("usedNumNeibs"); |
2 |
26 Feb 07 |
jari |
//info.origDataSetSize = (result.getParams()).getInt("origDataSetSize"); |
2 |
26 Feb 07 |
jari |
//info.origClassSetSize = (result.getParams()).getInt("origClassSetSize"); |
2 |
26 Feb 07 |
jari |
487 |
|
2 |
26 Feb 07 |
jari |
488 |
return createValidationResultTree(result_cluster, info); |
2 |
26 Feb 07 |
jari |
//return createResultTree(result_cluster, info); |
2 |
26 Feb 07 |
jari |
490 |
|
2 |
26 Feb 07 |
jari |
491 |
} finally { |
2 |
26 Feb 07 |
jari |
492 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
493 |
if (algorithm != null) { |
2 |
26 Feb 07 |
jari |
494 |
algorithm.removeAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
495 |
} |
2 |
26 Feb 07 |
jari |
496 |
if (progress != null) { |
2 |
26 Feb 07 |
jari |
497 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
498 |
} |
2 |
26 Feb 07 |
jari |
499 |
} |
2 |
26 Feb 07 |
jari |
500 |
|
2 |
26 Feb 07 |
jari |
501 |
} // end if (validate) |
2 |
26 Feb 07 |
jari |
502 |
|
2 |
26 Feb 07 |
jari |
//return null; //for now |
2 |
26 Feb 07 |
jari |
504 |
} |
2 |
26 Feb 07 |
jari |
505 |
|
2 |
26 Feb 07 |
jari |
506 |
|
2 |
26 Feb 07 |
jari |
507 |
|
2 |
26 Feb 07 |
jari |
508 |
|
2 |
26 Feb 07 |
jari |
509 |
|
2 |
26 Feb 07 |
jari |
510 |
|
2 |
26 Feb 07 |
jari |
511 |
|
2 |
26 Feb 07 |
jari |
512 |
public AlgorithmData getScriptParameters(IFramework framework) { |
2 |
26 Feb 07 |
jari |
513 |
|
2 |
26 Feb 07 |
jari |
514 |
AlgorithmData data = new AlgorithmData(); |
2 |
26 Feb 07 |
jari |
515 |
|
2 |
26 Feb 07 |
jari |
516 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
517 |
this.experiment = framework.getData().getExperiment(); |
2 |
26 Feb 07 |
jari |
//this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
519 |
|
2 |
26 Feb 07 |
jari |
520 |
int number_of_samples = experiment.getNumberOfSamples(); |
2 |
26 Feb 07 |
jari |
521 |
int number_of_genes = experiment.getNumberOfGenes(); |
2 |
26 Feb 07 |
jari |
522 |
|
2 |
26 Feb 07 |
jari |
//KNNCStatusDialog kStatDialog = new KNNCStatusDialog((JFrame)framework.getFrame(), false); |
2 |
26 Feb 07 |
jari |
//kStatDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
525 |
KNNClassifyOrValidateDialog kCOrVDialog = new KNNClassifyOrValidateDialog((JFrame)framework.getFrame(), true); |
2 |
26 Feb 07 |
jari |
526 |
kCOrVDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
527 |
validate = !(kCOrVDialog.classify()); |
2 |
26 Feb 07 |
jari |
528 |
if (!kCOrVDialog.isOkPressed()) { |
2 |
26 Feb 07 |
jari |
//kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
530 |
return null; |
2 |
26 Feb 07 |
jari |
531 |
} |
2 |
26 Feb 07 |
jari |
//KNNCInitDialog kDialog = new KNNCInitDialog((JFrame)framework.getFrame(), false, framework); |
2 |
26 Feb 07 |
jari |
533 |
|
2 |
26 Feb 07 |
jari |
534 |
if (!validate) { |
2 |
26 Feb 07 |
jari |
535 |
KNNCStatusDialog kStatDialog = new KNNCStatusDialog((JFrame)framework.getFrame(), false); |
2 |
26 Feb 07 |
jari |
536 |
kStatDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
537 |
KNNCFirstDialog kDialog = new KNNCFirstDialog((JFrame)framework.getFrame(), true, framework); |
2 |
26 Feb 07 |
jari |
538 |
kDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
539 |
|
2 |
26 Feb 07 |
jari |
540 |
if (!kDialog.isOkPressed()) { |
2 |
26 Feb 07 |
jari |
541 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
542 |
return null; |
2 |
26 Feb 07 |
jari |
543 |
} |
2 |
26 Feb 07 |
jari |
544 |
|
2 |
26 Feb 07 |
jari |
545 |
classifyGenes = kDialog.classifyGenes(); |
2 |
26 Feb 07 |
jari |
546 |
numClasses = kDialog.getNumClasses(); |
2 |
26 Feb 07 |
jari |
547 |
numNeighbors = kDialog.getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
548 |
useVarianceFilter = kDialog.useVarianceFilter(); |
2 |
26 Feb 07 |
jari |
549 |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
550 |
numVarFilteredVectors = kDialog.getNumVectors(); |
2 |
26 Feb 07 |
jari |
551 |
} |
2 |
26 Feb 07 |
jari |
552 |
useCorrelFilter = kDialog.useCorrelFilter(); |
2 |
26 Feb 07 |
jari |
553 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
554 |
correlPValue = kDialog.getCorrPValue(); |
2 |
26 Feb 07 |
jari |
555 |
numPerms = kDialog.getNumPerms(); |
2 |
26 Feb 07 |
jari |
556 |
} |
2 |
26 Feb 07 |
jari |
557 |
k = numClasses*4 + 1; |
2 |
26 Feb 07 |
jari |
558 |
kcEditor = new KNNClassificationEditor(framework, classifyGenes, numClasses); |
2 |
26 Feb 07 |
jari |
559 |
if (kDialog.createNewTrgSet()) { |
2 |
26 Feb 07 |
jari |
560 |
kcEditor.showModal(true); |
2 |
26 Feb 07 |
jari |
561 |
} else { |
2 |
26 Feb 07 |
jari |
562 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
563 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
564 |
int returnVal = fc.showOpenDialog(framework.getFrame()); |
2 |
26 Feb 07 |
jari |
565 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
566 |
kcEditor.loadFromFile(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
567 |
} else { |
2 |
26 Feb 07 |
jari |
568 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
569 |
return null; |
2 |
26 Feb 07 |
jari |
570 |
} |
2 |
26 Feb 07 |
jari |
571 |
} |
2 |
26 Feb 07 |
jari |
572 |
|
2 |
26 Feb 07 |
jari |
573 |
kcEditor.dispose(); |
2 |
26 Feb 07 |
jari |
574 |
|
2 |
26 Feb 07 |
jari |
// if (kcEditor.fileIsIncompatible()) { |
2 |
26 Feb 07 |
jari |
// kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
// return null; |
2 |
26 Feb 07 |
jari |
578 |
// } |
2 |
26 Feb 07 |
jari |
579 |
|
2 |
26 Feb 07 |
jari |
// while (!kcEditor.isNextPressed()) { |
2 |
26 Feb 07 |
jari |
// continue; |
2 |
26 Feb 07 |
jari |
582 |
// } |
2 |
26 Feb 07 |
jari |
583 |
|
2 |
26 Feb 07 |
jari |
//System.out.println("KNNCGUI: kcEditor.proceed() = " + kcEditor.proceed()); |
2 |
26 Feb 07 |
jari |
585 |
|
2 |
26 Feb 07 |
jari |
// if (!kcEditor.proceed()) { |
2 |
26 Feb 07 |
jari |
// kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
// return null; |
2 |
26 Feb 07 |
jari |
589 |
// } |
2 |
26 Feb 07 |
jari |
590 |
|
2 |
26 Feb 07 |
jari |
// **** DONE UP TO HERE: 9_25_03, AT THIS POINT, NEED TO getClassificaiton() from kcEditor |
2 |
26 Feb 07 |
jari |
592 |
|
2 |
26 Feb 07 |
jari |
593 |
classificationVector = kcEditor.getClassification(); |
2 |
26 Feb 07 |
jari |
594 |
classIndices = new int[classificationVector[0].size()]; |
2 |
26 Feb 07 |
jari |
595 |
classes = new int[classificationVector[1].size()]; |
2 |
26 Feb 07 |
jari |
596 |
|
2 |
26 Feb 07 |
jari |
597 |
for (int i = 0; i < classIndices.length; i++) { |
2 |
26 Feb 07 |
jari |
598 |
classIndices[i] = ((Integer)(classificationVector[0].get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
599 |
classes[i] = ((Integer)(classificationVector[1].get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
600 |
} |
2 |
26 Feb 07 |
jari |
601 |
|
2 |
26 Feb 07 |
jari |
602 |
boolean isHierarchicalTree = kDialog.drawTrees(); |
2 |
26 Feb 07 |
jari |
603 |
|
2 |
26 Feb 07 |
jari |
604 |
IDistanceMenu menu = framework.getDistanceMenu(); |
2 |
26 Feb 07 |
jari |
605 |
int function = menu.getDistanceFunction(); |
2 |
26 Feb 07 |
jari |
606 |
if (function == Algorithm.DEFAULT) { |
2 |
26 Feb 07 |
jari |
607 |
function = Algorithm.EUCLIDEAN; |
2 |
26 Feb 07 |
jari |
608 |
} |
2 |
26 Feb 07 |
jari |
609 |
|
2 |
26 Feb 07 |
jari |
// hcl init |
2 |
26 Feb 07 |
jari |
611 |
int hcl_method = 0; |
2 |
26 Feb 07 |
jari |
612 |
boolean hcl_samples = false; |
2 |
26 Feb 07 |
jari |
613 |
boolean hcl_genes = false; |
2 |
26 Feb 07 |
jari |
614 |
int hcl_function = 4; |
2 |
26 Feb 07 |
jari |
615 |
boolean hcl_absolute = false; |
2 |
26 Feb 07 |
jari |
616 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
617 |
HCLInitDialog hcl_dialog = new HCLInitDialog(framework.getFrame(), menu.getFunctionName(function), menu.isAbsoluteDistance(), true); |
2 |
26 Feb 07 |
jari |
618 |
if (hcl_dialog.showModal() != JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
619 |
return null; |
2 |
26 Feb 07 |
jari |
620 |
} |
2 |
26 Feb 07 |
jari |
621 |
hcl_method = hcl_dialog.getMethod(); |
2 |
26 Feb 07 |
jari |
622 |
hcl_samples = hcl_dialog.isClusterExperiments(); |
2 |
26 Feb 07 |
jari |
623 |
hcl_genes = hcl_dialog.isClusterGenes(); |
2 |
26 Feb 07 |
jari |
624 |
hcl_function = hcl_dialog.getDistanceMetric(); |
2 |
26 Feb 07 |
jari |
625 |
hcl_absolute = hcl_dialog.getAbsoluteSelection(); |
2 |
26 Feb 07 |
jari |
626 |
} |
2 |
26 Feb 07 |
jari |
627 |
|
2 |
26 Feb 07 |
jari |
628 |
data.addParam("distance-factor", String.valueOf(1.0f)); |
2 |
26 Feb 07 |
jari |
629 |
data.addParam("distance-absolute", String.valueOf(menu.isAbsoluteDistance())); |
2 |
26 Feb 07 |
jari |
630 |
|
2 |
26 Feb 07 |
jari |
631 |
data.addParam("distance-function", String.valueOf(function)); |
2 |
26 Feb 07 |
jari |
632 |
|
2 |
26 Feb 07 |
jari |
633 |
data.addParam("validate", String.valueOf(validate)); |
2 |
26 Feb 07 |
jari |
634 |
data.addParam("classifyGenes", String.valueOf(classifyGenes)); |
2 |
26 Feb 07 |
jari |
635 |
|
2 |
26 Feb 07 |
jari |
636 |
data.addParam("useVarianceFilter", String.valueOf(useVarianceFilter)); |
2 |
26 Feb 07 |
jari |
637 |
data.addParam("useCorrelFilter", String.valueOf(useCorrelFilter)); |
2 |
26 Feb 07 |
jari |
638 |
data.addParam("numClasses", String.valueOf(numClasses)); |
2 |
26 Feb 07 |
jari |
639 |
data.addParam("numNeighbors", String.valueOf(numNeighbors)); |
2 |
26 Feb 07 |
jari |
640 |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
641 |
data.addParam("numVarFilteredVectors", String.valueOf(numVarFilteredVectors)); |
2 |
26 Feb 07 |
jari |
642 |
} |
2 |
26 Feb 07 |
jari |
643 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
644 |
data.addParam("correlPValue", String.valueOf((float)correlPValue)); |
2 |
26 Feb 07 |
jari |
645 |
data.addParam("numPerms", String.valueOf(numPerms)); |
2 |
26 Feb 07 |
jari |
646 |
} |
2 |
26 Feb 07 |
jari |
647 |
data.addIntArray("classIndices", classIndices); |
2 |
26 Feb 07 |
jari |
648 |
data.addIntArray("classes", classes); |
2 |
26 Feb 07 |
jari |
// hcl parameters |
2 |
26 Feb 07 |
jari |
650 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
651 |
data.addParam("hierarchical-tree", String.valueOf(true)); |
2 |
26 Feb 07 |
jari |
652 |
data.addParam("method-linkage", String.valueOf(hcl_method)); |
2 |
26 Feb 07 |
jari |
653 |
data.addParam("calculate-genes", String.valueOf(hcl_genes)); |
2 |
26 Feb 07 |
jari |
654 |
data.addParam("calculate-experiments", String.valueOf(hcl_samples)); |
2 |
26 Feb 07 |
jari |
655 |
data.addParam("hcl-distance-function", String.valueOf(hcl_function)); |
2 |
26 Feb 07 |
jari |
656 |
data.addParam("hcl-distance-absolute", String.valueOf(hcl_absolute)); |
2 |
26 Feb 07 |
jari |
657 |
} |
2 |
26 Feb 07 |
jari |
// alg name |
2 |
26 Feb 07 |
jari |
659 |
data.addParam("name", "KNNC"); |
2 |
26 Feb 07 |
jari |
660 |
|
2 |
26 Feb 07 |
jari |
// alg type |
2 |
26 Feb 07 |
jari |
662 |
if(classifyGenes) |
2 |
26 Feb 07 |
jari |
663 |
data.addParam("alg-type", "cluster-genes"); |
2 |
26 Feb 07 |
jari |
664 |
else |
2 |
26 Feb 07 |
jari |
665 |
data.addParam("alg-type", "cluster-experiments"); |
2 |
26 Feb 07 |
jari |
666 |
|
2 |
26 Feb 07 |
jari |
// output class |
2 |
26 Feb 07 |
jari |
668 |
data.addParam("output-class", "partition-output"); |
2 |
26 Feb 07 |
jari |
669 |
|
2 |
26 Feb 07 |
jari |
//output nodes |
2 |
26 Feb 07 |
jari |
671 |
String [] outputNodes = new String[4*numClasses+1]; |
2 |
26 Feb 07 |
jari |
672 |
String str; |
2 |
26 Feb 07 |
jari |
673 |
for(int i = 0; i < numClasses ; i++) { |
2 |
26 Feb 07 |
jari |
674 |
str = String.valueOf(i+1)+" "; |
2 |
26 Feb 07 |
jari |
675 |
outputNodes[i] = "Used classifiers: Class "+str; |
2 |
26 Feb 07 |
jari |
676 |
outputNodes[numClasses+i] = "Unused classifiers: Class "+str; |
2 |
26 Feb 07 |
jari |
677 |
outputNodes[2*numClasses+i] = "Classified: Class "+str; |
2 |
26 Feb 07 |
jari |
678 |
outputNodes[3*numClasses+i] = "Used classifiers + classified: Class "+str; |
2 |
26 Feb 07 |
jari |
679 |
} |
2 |
26 Feb 07 |
jari |
680 |
outputNodes[4*numClasses] = "Unclassified"; |
2 |
26 Feb 07 |
jari |
681 |
|
2 |
26 Feb 07 |
jari |
682 |
data.addStringArray("output-nodes", outputNodes); |
2 |
26 Feb 07 |
jari |
683 |
|
2 |
26 Feb 07 |
jari |
684 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
685 |
|
2 |
26 Feb 07 |
jari |
686 |
} else { |
2 |
26 Feb 07 |
jari |
687 |
|
2 |
26 Feb 07 |
jari |
688 |
KNNCStatusDialog kStatDialog = new KNNCStatusDialog((JFrame)framework.getFrame(), false); |
2 |
26 Feb 07 |
jari |
689 |
kStatDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
690 |
KNNCValidationFirstDialog kvDialog = new KNNCValidationFirstDialog((JFrame)framework.getFrame(), true, framework); |
2 |
26 Feb 07 |
jari |
691 |
kvDialog.setVisible(true); |
2 |
26 Feb 07 |
jari |
692 |
|
2 |
26 Feb 07 |
jari |
693 |
if (!kvDialog.isOkPressed()) { |
2 |
26 Feb 07 |
jari |
694 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
695 |
return null; |
2 |
26 Feb 07 |
jari |
696 |
} |
2 |
26 Feb 07 |
jari |
697 |
|
2 |
26 Feb 07 |
jari |
698 |
classifyGenes = kvDialog.classifyGenes(); |
2 |
26 Feb 07 |
jari |
699 |
numClasses = kvDialog.getNumClasses(); |
2 |
26 Feb 07 |
jari |
700 |
numNeighbors = kvDialog.getNumNeighbors(); |
2 |
26 Feb 07 |
jari |
701 |
|
2 |
26 Feb 07 |
jari |
702 |
useCorrelFilter = kvDialog.useCorrelFilter(); |
2 |
26 Feb 07 |
jari |
703 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
704 |
correlPValue = kvDialog.getCorrPValue(); |
2 |
26 Feb 07 |
jari |
705 |
numPerms = kvDialog.getNumPerms(); |
2 |
26 Feb 07 |
jari |
706 |
} |
2 |
26 Feb 07 |
jari |
707 |
k = numClasses*4 + 1; |
2 |
26 Feb 07 |
jari |
708 |
kcEditor = new KNNClassificationEditor(framework, classifyGenes, numClasses); |
2 |
26 Feb 07 |
jari |
709 |
if (kvDialog.createNewTrgSet()) { |
2 |
26 Feb 07 |
jari |
//kcEditor = new KNNClassificationEditor(framework, classifyGenes, numClasses); |
2 |
26 Feb 07 |
jari |
711 |
kcEditor.showModal(true); |
2 |
26 Feb 07 |
jari |
712 |
} else { |
2 |
26 Feb 07 |
jari |
713 |
final JFileChooser fc = new JFileChooser(); |
2 |
26 Feb 07 |
jari |
714 |
fc.setCurrentDirectory(new File("Data")); |
2 |
26 Feb 07 |
jari |
715 |
int returnVal = fc.showOpenDialog(framework.getFrame()); |
2 |
26 Feb 07 |
jari |
716 |
if (returnVal == JFileChooser.APPROVE_OPTION) { |
2 |
26 Feb 07 |
jari |
717 |
kcEditor.loadFromFile(fc.getSelectedFile()); |
2 |
26 Feb 07 |
jari |
718 |
} else { |
2 |
26 Feb 07 |
jari |
719 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
720 |
return null; |
2 |
26 Feb 07 |
jari |
721 |
} |
2 |
26 Feb 07 |
jari |
722 |
} |
2 |
26 Feb 07 |
jari |
723 |
|
2 |
26 Feb 07 |
jari |
724 |
if (kcEditor.fileIsIncompatible()) { |
2 |
26 Feb 07 |
jari |
725 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
726 |
return null; |
2 |
26 Feb 07 |
jari |
727 |
} |
2 |
26 Feb 07 |
jari |
728 |
|
2 |
26 Feb 07 |
jari |
729 |
while (!kcEditor.isNextPressed()) { |
2 |
26 Feb 07 |
jari |
730 |
continue; |
2 |
26 Feb 07 |
jari |
731 |
} |
2 |
26 Feb 07 |
jari |
732 |
if (!kcEditor.proceed()) { |
2 |
26 Feb 07 |
jari |
733 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
734 |
return null; |
2 |
26 Feb 07 |
jari |
735 |
} |
2 |
26 Feb 07 |
jari |
736 |
|
2 |
26 Feb 07 |
jari |
737 |
classificationVector = kcEditor.getClassification(); |
2 |
26 Feb 07 |
jari |
738 |
classIndices = new int[classificationVector[0].size()]; |
2 |
26 Feb 07 |
jari |
739 |
classes = new int[classificationVector[1].size()]; |
2 |
26 Feb 07 |
jari |
740 |
|
2 |
26 Feb 07 |
jari |
741 |
for (int i = 0; i < classIndices.length; i++) { |
2 |
26 Feb 07 |
jari |
742 |
classIndices[i] = ((Integer)(classificationVector[0].get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
743 |
classes[i] = ((Integer)(classificationVector[1].get(i))).intValue(); |
2 |
26 Feb 07 |
jari |
744 |
} |
2 |
26 Feb 07 |
jari |
745 |
|
2 |
26 Feb 07 |
jari |
746 |
boolean isHierarchicalTree = kvDialog.drawTrees(); |
2 |
26 Feb 07 |
jari |
747 |
|
2 |
26 Feb 07 |
jari |
748 |
|
2 |
26 Feb 07 |
jari |
749 |
IDistanceMenu menu = framework.getDistanceMenu(); |
2 |
26 Feb 07 |
jari |
750 |
int function = menu.getDistanceFunction(); |
2 |
26 Feb 07 |
jari |
751 |
if (function == Algorithm.DEFAULT) { |
2 |
26 Feb 07 |
jari |
752 |
function = Algorithm.EUCLIDEAN; |
2 |
26 Feb 07 |
jari |
753 |
} |
2 |
26 Feb 07 |
jari |
754 |
|
2 |
26 Feb 07 |
jari |
// hcl init |
2 |
26 Feb 07 |
jari |
756 |
int hcl_method = 0; |
2 |
26 Feb 07 |
jari |
757 |
boolean hcl_samples = false; |
2 |
26 Feb 07 |
jari |
758 |
boolean hcl_genes = false; |
2 |
26 Feb 07 |
jari |
759 |
int hcl_function = 4; |
2 |
26 Feb 07 |
jari |
760 |
boolean hcl_absolute = false; |
2 |
26 Feb 07 |
jari |
761 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
762 |
HCLInitDialog hcl_dialog = new HCLInitDialog(framework.getFrame(), menu.getFunctionName(function), menu.isAbsoluteDistance(), true); |
2 |
26 Feb 07 |
jari |
763 |
if (hcl_dialog.showModal() != JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
764 |
return null; |
2 |
26 Feb 07 |
jari |
765 |
} |
2 |
26 Feb 07 |
jari |
766 |
hcl_method = hcl_dialog.getMethod(); |
2 |
26 Feb 07 |
jari |
767 |
hcl_samples = hcl_dialog.isClusterExperiments(); |
2 |
26 Feb 07 |
jari |
768 |
hcl_genes = hcl_dialog.isClusterGenes(); |
2 |
26 Feb 07 |
jari |
769 |
hcl_function = hcl_dialog.getDistanceMetric(); |
2 |
26 Feb 07 |
jari |
770 |
hcl_absolute = hcl_dialog.getAbsoluteSelection(); |
2 |
26 Feb 07 |
jari |
771 |
} |
2 |
26 Feb 07 |
jari |
772 |
|
2 |
26 Feb 07 |
jari |
773 |
data.addParam("distance-factor", String.valueOf(1.0f)); |
2 |
26 Feb 07 |
jari |
774 |
data.addParam("distance-absolute", String.valueOf(menu.isAbsoluteDistance())); |
2 |
26 Feb 07 |
jari |
775 |
|
2 |
26 Feb 07 |
jari |
776 |
data.addParam("distance-function", String.valueOf(function)); |
2 |
26 Feb 07 |
jari |
777 |
|
2 |
26 Feb 07 |
jari |
778 |
data.addParam("validate", String.valueOf(validate)); |
2 |
26 Feb 07 |
jari |
779 |
data.addParam("classifyGenes", String.valueOf(classifyGenes)); |
2 |
26 Feb 07 |
jari |
780 |
|
2 |
26 Feb 07 |
jari |
//data.addParam("useVarianceFilter", String.valueOf(useVarianceFilter)); |
2 |
26 Feb 07 |
jari |
782 |
data.addParam("useCorrelFilter", String.valueOf(useCorrelFilter)); |
2 |
26 Feb 07 |
jari |
783 |
data.addParam("numClasses", String.valueOf(numClasses)); |
2 |
26 Feb 07 |
jari |
784 |
data.addParam("numNeighbors", String.valueOf(numNeighbors)); |
2 |
26 Feb 07 |
jari |
785 |
/* |
2 |
26 Feb 07 |
jari |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
data.addParam("numVarFilteredVectors", String.valueOf(numVarFilteredVectors)); |
2 |
26 Feb 07 |
jari |
788 |
} |
2 |
26 Feb 07 |
jari |
789 |
*/ |
2 |
26 Feb 07 |
jari |
790 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
791 |
data.addParam("correlPValue", String.valueOf((float)correlPValue)); |
2 |
26 Feb 07 |
jari |
792 |
data.addParam("numPerms", String.valueOf(numPerms)); |
2 |
26 Feb 07 |
jari |
793 |
} |
2 |
26 Feb 07 |
jari |
794 |
data.addIntArray("classIndices", classIndices); |
2 |
26 Feb 07 |
jari |
795 |
data.addIntArray("classes", classes); |
2 |
26 Feb 07 |
jari |
// hcl parameters |
2 |
26 Feb 07 |
jari |
797 |
|
2 |
26 Feb 07 |
jari |
798 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
799 |
data.addParam("hierarchical-tree", String.valueOf(true)); |
2 |
26 Feb 07 |
jari |
800 |
data.addParam("method-linkage", String.valueOf(hcl_method)); |
2 |
26 Feb 07 |
jari |
801 |
data.addParam("calculate-genes", String.valueOf(hcl_genes)); |
2 |
26 Feb 07 |
jari |
802 |
data.addParam("calculate-experiments", String.valueOf(hcl_samples)); |
2 |
26 Feb 07 |
jari |
803 |
data.addParam("hcl-distance-function", String.valueOf(hcl_function)); |
2 |
26 Feb 07 |
jari |
804 |
data.addParam("hcl-distance-absolute", String.valueOf(hcl_absolute)); |
2 |
26 Feb 07 |
jari |
805 |
} |
2 |
26 Feb 07 |
jari |
806 |
|
2 |
26 Feb 07 |
jari |
807 |
k = numClasses + 1; |
2 |
26 Feb 07 |
jari |
808 |
|
2 |
26 Feb 07 |
jari |
// alg name |
2 |
26 Feb 07 |
jari |
810 |
data.addParam("name", "KNNC"); |
2 |
26 Feb 07 |
jari |
811 |
|
2 |
26 Feb 07 |
jari |
// alg type |
2 |
26 Feb 07 |
jari |
813 |
if(classifyGenes) |
2 |
26 Feb 07 |
jari |
814 |
data.addParam("alg-type", "cluster-genes"); |
2 |
26 Feb 07 |
jari |
815 |
else |
2 |
26 Feb 07 |
jari |
816 |
data.addParam("alg-type", "cluster-experiments"); |
2 |
26 Feb 07 |
jari |
817 |
|
2 |
26 Feb 07 |
jari |
// output class |
2 |
26 Feb 07 |
jari |
819 |
data.addParam("output-class", "partition-output"); |
2 |
26 Feb 07 |
jari |
820 |
|
2 |
26 Feb 07 |
jari |
//output nodes |
2 |
26 Feb 07 |
jari |
822 |
String [] outputNodes = new String[numClasses+1]; |
2 |
26 Feb 07 |
jari |
823 |
|
2 |
26 Feb 07 |
jari |
824 |
for(int i = 0; i < numClasses; i++) { |
2 |
26 Feb 07 |
jari |
825 |
outputNodes[i] = "Training Class "+String.valueOf(i+1)+" "; |
2 |
26 Feb 07 |
jari |
826 |
} |
2 |
26 Feb 07 |
jari |
827 |
outputNodes[numClasses] = "Not in Training Set "; |
2 |
26 Feb 07 |
jari |
828 |
|
2 |
26 Feb 07 |
jari |
829 |
data.addStringArray("output-nodes", outputNodes); |
2 |
26 Feb 07 |
jari |
830 |
|
2 |
26 Feb 07 |
jari |
831 |
kStatDialog.dispose(); |
2 |
26 Feb 07 |
jari |
832 |
|
2 |
26 Feb 07 |
jari |
833 |
} |
2 |
26 Feb 07 |
jari |
834 |
return data; |
2 |
26 Feb 07 |
jari |
835 |
} |
2 |
26 Feb 07 |
jari |
836 |
|
2 |
26 Feb 07 |
jari |
837 |
|
2 |
26 Feb 07 |
jari |
838 |
|
2 |
26 Feb 07 |
jari |
839 |
|
2 |
26 Feb 07 |
jari |
840 |
|
2 |
26 Feb 07 |
jari |
841 |
|
2 |
26 Feb 07 |
jari |
842 |
public DefaultMutableTreeNode executeScript(IFramework framework, AlgorithmData algData, Experiment experiment) throws AlgorithmException { |
2 |
26 Feb 07 |
jari |
843 |
AlgorithmParameters params = algData.getParams(); |
2 |
26 Feb 07 |
jari |
844 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
845 |
|
2 |
26 Feb 07 |
jari |
846 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
847 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
848 |
this.classifyGenes = params.getBoolean("classifyGenes"); |
2 |
26 Feb 07 |
jari |
849 |
this.numClasses = params.getInt("numClasses"); |
2 |
26 Feb 07 |
jari |
850 |
this.numNeighbors = params.getInt("numNeighbors"); |
2 |
26 Feb 07 |
jari |
851 |
this.useCorrelFilter = params.getBoolean("useCorrelFilter"); |
2 |
26 Feb 07 |
jari |
852 |
this.validate = params.getBoolean("validate"); |
2 |
26 Feb 07 |
jari |
853 |
int number_of_samples = experiment.getNumberOfSamples(); |
2 |
26 Feb 07 |
jari |
854 |
int number_of_genes = experiment.getNumberOfGenes(); |
2 |
26 Feb 07 |
jari |
855 |
|
2 |
26 Feb 07 |
jari |
856 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
857 |
this.correlPValue = params.getFloat("correlPValue"); |
2 |
26 Feb 07 |
jari |
858 |
this.numPerms = params.getInt("numPerms"); |
2 |
26 Feb 07 |
jari |
859 |
} |
2 |
26 Feb 07 |
jari |
860 |
|
2 |
26 Feb 07 |
jari |
861 |
if (!validate) { |
2 |
26 Feb 07 |
jari |
862 |
|
2 |
26 Feb 07 |
jari |
863 |
this.useVarianceFilter = params.getBoolean("useVarianceFilter"); |
2 |
26 Feb 07 |
jari |
864 |
if(this.useVarianceFilter) |
2 |
26 Feb 07 |
jari |
865 |
this.numVarFilteredVectors = params.getInt("numVarFilteredVectors"); |
2 |
26 Feb 07 |
jari |
866 |
|
2 |
26 Feb 07 |
jari |
867 |
|
2 |
26 Feb 07 |
jari |
868 |
try { |
2 |
26 Feb 07 |
jari |
869 |
algorithm = framework.getAlgorithmFactory().getAlgorithm("KNNC"); |
2 |
26 Feb 07 |
jari |
870 |
algorithm.addAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
871 |
|
2 |
26 Feb 07 |
jari |
872 |
this.progress = new Progress(framework.getFrame(), "KNN classification", listener); |
2 |
26 Feb 07 |
jari |
873 |
this.progress.show(); |
2 |
26 Feb 07 |
jari |
874 |
|
2 |
26 Feb 07 |
jari |
875 |
if (classifyGenes) { |
2 |
26 Feb 07 |
jari |
876 |
algData.addMatrix("experiment", experiment.getMatrix()); |
2 |
26 Feb 07 |
jari |
877 |
} else { |
2 |
26 Feb 07 |
jari |
878 |
algData.addMatrix("experiment", experiment.getMatrix().transpose()); |
2 |
26 Feb 07 |
jari |
879 |
} |
2 |
26 Feb 07 |
jari |
880 |
|
2 |
26 Feb 07 |
jari |
881 |
long start = System.currentTimeMillis(); |
2 |
26 Feb 07 |
jari |
882 |
AlgorithmData result = algorithm.execute(algData); |
2 |
26 Feb 07 |
jari |
883 |
long time = System.currentTimeMillis() - start; |
2 |
26 Feb 07 |
jari |
// getting the results |
2 |
26 Feb 07 |
jari |
885 |
Cluster result_cluster = result.getCluster("cluster"); |
2 |
26 Feb 07 |
jari |
886 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
887 |
k = numClasses*4 + 1; |
2 |
26 Feb 07 |
jari |
888 |
this.clusters = new int[k][]; |
2 |
26 Feb 07 |
jari |
889 |
for (int i=0; i<k; i++) { |
2 |
26 Feb 07 |
jari |
890 |
clusters[i] = nodeList.getNode(i).getFeaturesIndexes(); |
2 |
26 Feb 07 |
jari |
891 |
} |
2 |
26 Feb 07 |
jari |
892 |
this.means = result.getMatrix("clusters_means"); |
2 |
26 Feb 07 |
jari |
893 |
this.variances = result.getMatrix("clusters_variances"); |
2 |
26 Feb 07 |
jari |
894 |
|
2 |
26 Feb 07 |
jari |
895 |
this.numberCorrectlyClassifiedByClass = result.getIntArray("numberCorrectlyClassifiedByClass"); |
2 |
26 Feb 07 |
jari |
896 |
this.numberIncorrectlyClassifiedByClass = result.getIntArray("numberIncorrectlyClassifiedByClass"); |
2 |
26 Feb 07 |
jari |
897 |
this.origNumInFiltTrgSetByClass = result.getIntArray("origNumInFiltTrgSetByClass"); |
2 |
26 Feb 07 |
jari |
898 |
|
2 |
26 Feb 07 |
jari |
899 |
GeneralInfo info = new GeneralInfo(); |
2 |
26 Feb 07 |
jari |
//info.clusters = k; |
2 |
26 Feb 07 |
jari |
901 |
info.time = time; |
2 |
26 Feb 07 |
jari |
902 |
info.hcl = params.getBoolean("hierarchical-tree"); |
2 |
26 Feb 07 |
jari |
903 |
info.hcl_genes = params.getBoolean("calculate-genes"); |
2 |
26 Feb 07 |
jari |
904 |
info.hcl_samples = params.getBoolean("calculate-experiments"); |
2 |
26 Feb 07 |
jari |
905 |
if(info.hcl) |
2 |
26 Feb 07 |
jari |
906 |
info.hcl_method = params.getInt("method-linkage"); |
2 |
26 Feb 07 |
jari |
907 |
info.numClasses = numClasses; |
2 |
26 Feb 07 |
jari |
908 |
info.numNeighbors = numNeighbors; |
2 |
26 Feb 07 |
jari |
909 |
info.usedVarFilter = useVarianceFilter; |
2 |
26 Feb 07 |
jari |
910 |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
911 |
info.numVarFiltered = this.numVarFilteredVectors; |
2 |
26 Feb 07 |
jari |
912 |
info.postVarDataSetSize = (result.getParams()).getInt("postVarDataSetSize"); |
2 |
26 Feb 07 |
jari |
913 |
info.postVarClassSetSize = (result.getParams()).getInt("postVarClassSetSize"); |
2 |
26 Feb 07 |
jari |
914 |
} |
2 |
26 Feb 07 |
jari |
915 |
info.usedCorrelFilter = this.useCorrelFilter; |
2 |
26 Feb 07 |
jari |
916 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
917 |
info.correlPvalue = this.correlPValue; |
2 |
26 Feb 07 |
jari |
918 |
info.numPerms = this.numPerms; |
2 |
26 Feb 07 |
jari |
919 |
info.postCorrDataSetSize = (result.getParams()).getInt("postCorrDataSetSize"); |
2 |
26 Feb 07 |
jari |
920 |
} |
2 |
26 Feb 07 |
jari |
921 |
info.usedNumNeibs = (result.getParams()).getInt("usedNumNeibs"); |
2 |
26 Feb 07 |
jari |
922 |
info.origDataSetSize = (result.getParams()).getInt("origDataSetSize"); |
2 |
26 Feb 07 |
jari |
923 |
info.origClassSetSize = (result.getParams()).getInt("origClassSetSize"); |
2 |
26 Feb 07 |
jari |
924 |
|
2 |
26 Feb 07 |
jari |
925 |
return createResultTree(result_cluster, info); |
2 |
26 Feb 07 |
jari |
926 |
|
2 |
26 Feb 07 |
jari |
927 |
} finally { |
2 |
26 Feb 07 |
jari |
928 |
|
2 |
26 Feb 07 |
jari |
929 |
if (algorithm != null) { |
2 |
26 Feb 07 |
jari |
930 |
algorithm.removeAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
931 |
} |
2 |
26 Feb 07 |
jari |
932 |
if (progress != null) { |
2 |
26 Feb 07 |
jari |
933 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
934 |
} |
2 |
26 Feb 07 |
jari |
935 |
} |
2 |
26 Feb 07 |
jari |
936 |
|
2 |
26 Feb 07 |
jari |
937 |
} else {// if (validate) |
2 |
26 Feb 07 |
jari |
938 |
|
2 |
26 Feb 07 |
jari |
939 |
try { |
2 |
26 Feb 07 |
jari |
//System.out.println("Proceeded to algorithm"); |
2 |
26 Feb 07 |
jari |
941 |
algorithm = framework.getAlgorithmFactory().getAlgorithm("KNNC"); |
2 |
26 Feb 07 |
jari |
942 |
algorithm.addAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
943 |
|
2 |
26 Feb 07 |
jari |
944 |
this.progress = new Progress(framework.getFrame(), "KNN classification", listener); |
2 |
26 Feb 07 |
jari |
945 |
this.progress.show(); |
2 |
26 Feb 07 |
jari |
946 |
|
2 |
26 Feb 07 |
jari |
947 |
if (classifyGenes) { |
2 |
26 Feb 07 |
jari |
948 |
algData.addMatrix("experiment", experiment.getMatrix()); |
2 |
26 Feb 07 |
jari |
949 |
} else { |
2 |
26 Feb 07 |
jari |
950 |
algData.addMatrix("experiment", experiment.getMatrix().transpose()); |
2 |
26 Feb 07 |
jari |
951 |
} |
2 |
26 Feb 07 |
jari |
952 |
|
2 |
26 Feb 07 |
jari |
953 |
long start = System.currentTimeMillis(); |
2 |
26 Feb 07 |
jari |
954 |
AlgorithmData result = algorithm.execute(algData); |
2 |
26 Feb 07 |
jari |
955 |
long time = System.currentTimeMillis() - start; |
2 |
26 Feb 07 |
jari |
// getting the results |
2 |
26 Feb 07 |
jari |
957 |
Cluster result_cluster = result.getCluster("cluster"); |
2 |
26 Feb 07 |
jari |
958 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
959 |
k = numClasses + 1; |
2 |
26 Feb 07 |
jari |
960 |
this.clusters = new int[k][]; |
2 |
26 Feb 07 |
jari |
961 |
for (int i=0; i<k; i++) { |
2 |
26 Feb 07 |
jari |
962 |
clusters[i] = nodeList.getNode(i).getFeaturesIndexes(); |
2 |
26 Feb 07 |
jari |
963 |
} |
2 |
26 Feb 07 |
jari |
964 |
this.means = result.getMatrix("clusters_means"); |
2 |
26 Feb 07 |
jari |
965 |
this.variances = result.getMatrix("clusters_variances"); |
2 |
26 Feb 07 |
jari |
966 |
|
2 |
26 Feb 07 |
jari |
967 |
this.numberCorrectlyClassifiedByClass = result.getIntArray("numberCorrectlyClassifiedByClass"); |
2 |
26 Feb 07 |
jari |
968 |
this.numberIncorrectlyClassifiedByClass = result.getIntArray("numberIncorrectlyClassifiedByClass"); |
2 |
26 Feb 07 |
jari |
969 |
this.origNumInFiltTrgSetByClass = result.getIntArray("origNumInFiltTrgSetByClass"); |
2 |
26 Feb 07 |
jari |
970 |
|
2 |
26 Feb 07 |
jari |
971 |
GeneralInfo info = new GeneralInfo(); |
2 |
26 Feb 07 |
jari |
//info.clusters = k; |
2 |
26 Feb 07 |
jari |
973 |
info.time = time; |
2 |
26 Feb 07 |
jari |
974 |
info.hcl = params.getBoolean("hierarchical-tree"); |
2 |
26 Feb 07 |
jari |
975 |
info.hcl_genes = params.getBoolean("calculate-genes"); |
2 |
26 Feb 07 |
jari |
976 |
info.hcl_samples = params.getBoolean("calculate-experiments"); |
2 |
26 Feb 07 |
jari |
977 |
if(info.hcl) |
2 |
26 Feb 07 |
jari |
978 |
info.hcl_method = params.getInt("method-linkage"); |
2 |
26 Feb 07 |
jari |
979 |
info.numClasses = numClasses; |
2 |
26 Feb 07 |
jari |
980 |
info.numNeighbors = numNeighbors; |
2 |
26 Feb 07 |
jari |
981 |
info.usedCorrelFilter = this.useCorrelFilter; |
2 |
26 Feb 07 |
jari |
982 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
983 |
info.correlPvalue = this.correlPValue; |
2 |
26 Feb 07 |
jari |
984 |
info.numPerms = this.numPerms; |
2 |
26 Feb 07 |
jari |
985 |
} |
2 |
26 Feb 07 |
jari |
986 |
info.usedNumNeibs = (result.getParams()).getInt("usedNumNeibs"); |
2 |
26 Feb 07 |
jari |
987 |
|
2 |
26 Feb 07 |
jari |
988 |
return createValidationResultTree(result_cluster, info); |
2 |
26 Feb 07 |
jari |
989 |
} finally { |
2 |
26 Feb 07 |
jari |
990 |
if (algorithm != null) { |
2 |
26 Feb 07 |
jari |
991 |
algorithm.removeAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
992 |
} |
2 |
26 Feb 07 |
jari |
993 |
if (progress != null) { |
2 |
26 Feb 07 |
jari |
994 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
995 |
} |
2 |
26 Feb 07 |
jari |
996 |
} |
2 |
26 Feb 07 |
jari |
997 |
} |
2 |
26 Feb 07 |
jari |
998 |
} |
2 |
26 Feb 07 |
jari |
999 |
|
2 |
26 Feb 07 |
jari |
1000 |
|
2 |
26 Feb 07 |
jari |
1001 |
|
2 |
26 Feb 07 |
jari |
1002 |
|
2 |
26 Feb 07 |
jari |
1003 |
|
2 |
26 Feb 07 |
jari |
1004 |
|
2 |
26 Feb 07 |
jari |
1005 |
private DefaultMutableTreeNode createValidationResultTree(Cluster result_cluster, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
1006 |
DefaultMutableTreeNode root; |
2 |
26 Feb 07 |
jari |
1007 |
if(classifyGenes) |
2 |
26 Feb 07 |
jari |
1008 |
root = new DefaultMutableTreeNode("KNNC Validation - genes"); |
2 |
26 Feb 07 |
jari |
1009 |
else |
2 |
26 Feb 07 |
jari |
1010 |
root = new DefaultMutableTreeNode("KNNC Validation - samples"); |
2 |
26 Feb 07 |
jari |
1011 |
addValidationExpressionImages(root); |
2 |
26 Feb 07 |
jari |
1012 |
addValidationHierarchicalTrees(root, result_cluster, info); |
2 |
26 Feb 07 |
jari |
1013 |
addValidationCentroidViews(root); |
2 |
26 Feb 07 |
jari |
1014 |
addValidationTableViews(root); |
2 |
26 Feb 07 |
jari |
1015 |
addValidationInfo(root); |
2 |
26 Feb 07 |
jari |
1016 |
addValidationGeneralInfo(root, info); |
2 |
26 Feb 07 |
jari |
1017 |
return root; |
2 |
26 Feb 07 |
jari |
1018 |
} |
2 |
26 Feb 07 |
jari |
1019 |
|
2 |
26 Feb 07 |
jari |
1020 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a result tree to be inserted into the framework analysis node. |
2 |
26 Feb 07 |
jari |
1022 |
*/ |
2 |
26 Feb 07 |
jari |
1023 |
private DefaultMutableTreeNode createResultTree(Cluster result_cluster, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
1024 |
DefaultMutableTreeNode root; |
2 |
26 Feb 07 |
jari |
1025 |
if(classifyGenes) |
2 |
26 Feb 07 |
jari |
1026 |
root = new DefaultMutableTreeNode("KNNC - genes"); |
2 |
26 Feb 07 |
jari |
1027 |
else |
2 |
26 Feb 07 |
jari |
1028 |
root = new DefaultMutableTreeNode("KNNC - samples"); |
2 |
26 Feb 07 |
jari |
1029 |
addResultNodes(root, result_cluster, info); |
2 |
26 Feb 07 |
jari |
1030 |
return root; |
2 |
26 Feb 07 |
jari |
1031 |
} |
2 |
26 Feb 07 |
jari |
1032 |
|
2 |
26 Feb 07 |
jari |
1033 |
/** |
2 |
26 Feb 07 |
jari |
* Adds result nodes into the tree root. |
2 |
26 Feb 07 |
jari |
1035 |
*/ |
2 |
26 Feb 07 |
jari |
1036 |
private void addResultNodes(DefaultMutableTreeNode root, Cluster result_cluster, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
1037 |
addExpressionImages(root); |
2 |
26 Feb 07 |
jari |
1038 |
addHierarchicalTrees(root, result_cluster, info); |
2 |
26 Feb 07 |
jari |
1039 |
addCentroidViews(root); |
2 |
26 Feb 07 |
jari |
1040 |
addTableViews(root); |
2 |
26 Feb 07 |
jari |
1041 |
addClusterInfo(root); |
2 |
26 Feb 07 |
jari |
1042 |
addValidationInfo(root); |
2 |
26 Feb 07 |
jari |
1043 |
addGeneralInfo(root, info); |
2 |
26 Feb 07 |
jari |
1044 |
} |
2 |
26 Feb 07 |
jari |
1045 |
|
2 |
26 Feb 07 |
jari |
1046 |
|
2 |
26 Feb 07 |
jari |
1047 |
private void addValidationTableViews(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
1048 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Table views"); |
2 |
26 Feb 07 |
jari |
1049 |
IViewer tabViewer; |
2 |
26 Feb 07 |
jari |
1050 |
if (classifyGenes) { |
2 |
26 Feb 07 |
jari |
1051 |
tabViewer = new ClusterTableViewer(this.experiment, this.clusters, this.data); |
2 |
26 Feb 07 |
jari |
1052 |
} else { |
2 |
26 Feb 07 |
jari |
1053 |
tabViewer = new ExperimentClusterTableViewer(this.experiment, this.clusters, this.data); |
2 |
26 Feb 07 |
jari |
1054 |
} |
2 |
26 Feb 07 |
jari |
1055 |
for (int i = 1; i < this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
1056 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Class " + String.valueOf(i), tabViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1057 |
} |
2 |
26 Feb 07 |
jari |
1058 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Not in training set ", tabViewer, new Integer(0)))); |
2 |
26 Feb 07 |
jari |
1059 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1060 |
} |
2 |
26 Feb 07 |
jari |
1061 |
|
2 |
26 Feb 07 |
jari |
1062 |
private void addTableViews(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
1063 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Table views"); |
2 |
26 Feb 07 |
jari |
1064 |
IViewer tabViewer; |
2 |
26 Feb 07 |
jari |
1065 |
DefaultMutableTreeNode[] nodeArray = new DefaultMutableTreeNode[4]; |
2 |
26 Feb 07 |
jari |
1066 |
nodeArray[0] = new DefaultMutableTreeNode("Used classifiers"); |
2 |
26 Feb 07 |
jari |
1067 |
nodeArray[1] = new DefaultMutableTreeNode("Unused classifiers"); |
2 |
26 Feb 07 |
jari |
1068 |
nodeArray[2] = new DefaultMutableTreeNode("Classified"); |
2 |
26 Feb 07 |
jari |
1069 |
nodeArray[3] = new DefaultMutableTreeNode("Used classifiers + classified"); |
2 |
26 Feb 07 |
jari |
//nodeArray[4] = new DefaultMutableTreeNode("Unclassified"); |
2 |
26 Feb 07 |
jari |
1071 |
if (classifyGenes) { |
2 |
26 Feb 07 |
jari |
1072 |
tabViewer = new ClusterTableViewer(this.experiment, this.clusters, this.data); |
2 |
26 Feb 07 |
jari |
1073 |
} else { |
2 |
26 Feb 07 |
jari |
1074 |
tabViewer = new ExperimentClusterTableViewer(this.experiment, this.clusters, this.data); |
2 |
26 Feb 07 |
jari |
//return; //placeholder for ExptClusterTableViewer |
2 |
26 Feb 07 |
jari |
//expViewer = new KNNCExperimentClusterViewer(this.experiment, this.clusters); |
2 |
26 Feb 07 |
jari |
1077 |
} |
2 |
26 Feb 07 |
jari |
1078 |
|
2 |
26 Feb 07 |
jari |
1079 |
for (int i =0; i < numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1080 |
nodeArray[0].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1), tabViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1081 |
} |
2 |
26 Feb 07 |
jari |
1082 |
for (int i = numClasses; i < 2*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1083 |
nodeArray[1].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - numClasses), tabViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1084 |
} |
2 |
26 Feb 07 |
jari |
1085 |
for (int i =2*numClasses; i < 3*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1086 |
nodeArray[2].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 2*numClasses), tabViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1087 |
} |
2 |
26 Feb 07 |
jari |
1088 |
for (int i =3*numClasses; i < 4*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1089 |
nodeArray[3].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 3*numClasses), tabViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1090 |
} |
2 |
26 Feb 07 |
jari |
1091 |
|
2 |
26 Feb 07 |
jari |
//nodeArray[4].add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", expViewer, new Integer(4*numClasses)))); |
2 |
26 Feb 07 |
jari |
1093 |
|
2 |
26 Feb 07 |
jari |
1094 |
for (int i = 0; i < nodeArray.length; i++) { |
2 |
26 Feb 07 |
jari |
1095 |
node.add(nodeArray[i]); |
2 |
26 Feb 07 |
jari |
1096 |
} |
2 |
26 Feb 07 |
jari |
1097 |
|
2 |
26 Feb 07 |
jari |
1098 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", tabViewer, new Integer(4*numClasses)))); |
2 |
26 Feb 07 |
jari |
1099 |
|
2 |
26 Feb 07 |
jari |
1100 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1101 |
} |
2 |
26 Feb 07 |
jari |
1102 |
|
2 |
26 Feb 07 |
jari |
1103 |
private void addValidationExpressionImages(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
1104 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Expression Images"); |
2 |
26 Feb 07 |
jari |
1105 |
IViewer expViewer; |
2 |
26 Feb 07 |
jari |
1106 |
if (classifyGenes) { |
2 |
26 Feb 07 |
jari |
1107 |
expViewer = new KNNCExperimentViewer(this.experiment, this.clusters); |
2 |
26 Feb 07 |
jari |
1108 |
} else { |
2 |
26 Feb 07 |
jari |
1109 |
expViewer = new KNNCExperimentClusterViewer(this.experiment, this.clusters); |
2 |
26 Feb 07 |
jari |
1110 |
} |
2 |
26 Feb 07 |
jari |
1111 |
|
2 |
26 Feb 07 |
jari |
1112 |
for (int i = 1; i < this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
1113 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Class " + String.valueOf(i), expViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1114 |
} |
2 |
26 Feb 07 |
jari |
1115 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Not in training set ", expViewer, new Integer(0)))); |
2 |
26 Feb 07 |
jari |
1116 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1117 |
} |
2 |
26 Feb 07 |
jari |
1118 |
|
2 |
26 Feb 07 |
jari |
1119 |
/** |
2 |
26 Feb 07 |
jari |
* Adds nodes to display clusters data. |
2 |
26 Feb 07 |
jari |
1121 |
*/ |
2 |
26 Feb 07 |
jari |
1122 |
private void addExpressionImages(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
1123 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Expression Images"); |
2 |
26 Feb 07 |
jari |
1124 |
IViewer expViewer; |
2 |
26 Feb 07 |
jari |
1125 |
DefaultMutableTreeNode[] nodeArray = new DefaultMutableTreeNode[4]; |
2 |
26 Feb 07 |
jari |
1126 |
nodeArray[0] = new DefaultMutableTreeNode("Used classifiers"); |
2 |
26 Feb 07 |
jari |
1127 |
nodeArray[1] = new DefaultMutableTreeNode("Unused classifiers"); |
2 |
26 Feb 07 |
jari |
1128 |
nodeArray[2] = new DefaultMutableTreeNode("Classified"); |
2 |
26 Feb 07 |
jari |
1129 |
nodeArray[3] = new DefaultMutableTreeNode("Used classifiers + classified"); |
2 |
26 Feb 07 |
jari |
//nodeArray[4] = new DefaultMutableTreeNode("Unclassified"); |
2 |
26 Feb 07 |
jari |
1131 |
if (classifyGenes) { |
2 |
26 Feb 07 |
jari |
1132 |
expViewer = new KNNCExperimentViewer(this.experiment, this.clusters); |
2 |
26 Feb 07 |
jari |
1133 |
} else { |
2 |
26 Feb 07 |
jari |
1134 |
expViewer = new KNNCExperimentClusterViewer(this.experiment, this.clusters); |
2 |
26 Feb 07 |
jari |
1135 |
} |
2 |
26 Feb 07 |
jari |
1136 |
|
2 |
26 Feb 07 |
jari |
1137 |
for (int i =0; i < numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1138 |
nodeArray[0].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1), expViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1139 |
} |
2 |
26 Feb 07 |
jari |
1140 |
for (int i = numClasses; i < 2*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1141 |
nodeArray[1].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - numClasses), expViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1142 |
} |
2 |
26 Feb 07 |
jari |
1143 |
for (int i =2*numClasses; i < 3*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1144 |
nodeArray[2].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 2*numClasses), expViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1145 |
} |
2 |
26 Feb 07 |
jari |
1146 |
for (int i =3*numClasses; i < 4*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1147 |
nodeArray[3].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 3*numClasses), expViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1148 |
} |
2 |
26 Feb 07 |
jari |
1149 |
|
2 |
26 Feb 07 |
jari |
//nodeArray[4].add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", expViewer, new Integer(4*numClasses)))); |
2 |
26 Feb 07 |
jari |
1151 |
|
2 |
26 Feb 07 |
jari |
1152 |
for (int i = 0; i < nodeArray.length; i++) { |
2 |
26 Feb 07 |
jari |
1153 |
node.add(nodeArray[i]); |
2 |
26 Feb 07 |
jari |
1154 |
} |
2 |
26 Feb 07 |
jari |
1155 |
|
2 |
26 Feb 07 |
jari |
1156 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", expViewer, new Integer(4*numClasses)))); |
2 |
26 Feb 07 |
jari |
1157 |
|
2 |
26 Feb 07 |
jari |
1158 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1159 |
} |
2 |
26 Feb 07 |
jari |
1160 |
|
2 |
26 Feb 07 |
jari |
1161 |
|
2 |
26 Feb 07 |
jari |
1162 |
private void addValidationHierarchicalTrees(DefaultMutableTreeNode root, Cluster result_cluster, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
1163 |
if (!info.hcl) { |
2 |
26 Feb 07 |
jari |
1164 |
return; |
2 |
26 Feb 07 |
jari |
1165 |
} |
2 |
26 Feb 07 |
jari |
1166 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Hierarchical Trees"); |
2 |
26 Feb 07 |
jari |
1167 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
1168 |
int [][] clusters = null; |
2 |
26 Feb 07 |
jari |
1169 |
|
2 |
26 Feb 07 |
jari |
1170 |
if(!this.classifyGenes){ |
2 |
26 Feb 07 |
jari |
1171 |
clusters = new int[k][]; |
2 |
26 Feb 07 |
jari |
1172 |
for (int i=0; i<k; i++) { |
2 |
26 Feb 07 |
jari |
1173 |
clusters[i] = nodeList.getNode(i).getFeaturesIndexes(); |
2 |
26 Feb 07 |
jari |
1174 |
} |
2 |
26 Feb 07 |
jari |
1175 |
if(info.hcl_samples) |
2 |
26 Feb 07 |
jari |
1176 |
clusters = getOrderedIndices(nodeList, clusters, info.hcl_genes); |
2 |
26 Feb 07 |
jari |
1177 |
} |
2 |
26 Feb 07 |
jari |
1178 |
for (int i=1; i<nodeList.getSize(); i++) { |
2 |
26 Feb 07 |
jari |
1179 |
if(this.classifyGenes) |
2 |
26 Feb 07 |
jari |
1180 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i), createHCLViewer(nodeList.getNode(i), info, null)))); |
2 |
26 Feb 07 |
jari |
1181 |
else |
2 |
26 Feb 07 |
jari |
1182 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i), createHCLViewer(nodeList.getNode(i), info, clusters), new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1183 |
} |
2 |
26 Feb 07 |
jari |
1184 |
if (this.classifyGenes) { |
2 |
26 Feb 07 |
jari |
1185 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Not in training set", createHCLViewer(nodeList.getNode(0), info, null)))); |
2 |
26 Feb 07 |
jari |
1186 |
} else |
2 |
26 Feb 07 |
jari |
1187 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Not in training set", createHCLViewer(nodeList.getNode(0), info, clusters), new Integer(0)))); |
2 |
26 Feb 07 |
jari |
1188 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1189 |
} |
2 |
26 Feb 07 |
jari |
1190 |
|
2 |
26 Feb 07 |
jari |
1191 |
/** |
2 |
26 Feb 07 |
jari |
* Adds nodes to display hierarchical trees. |
2 |
26 Feb 07 |
jari |
1193 |
*/ |
2 |
26 Feb 07 |
jari |
1194 |
private void addHierarchicalTrees(DefaultMutableTreeNode root, Cluster result_cluster, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
1195 |
if (!info.hcl) { |
2 |
26 Feb 07 |
jari |
1196 |
return; |
2 |
26 Feb 07 |
jari |
1197 |
} |
2 |
26 Feb 07 |
jari |
1198 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Hierarchical Trees"); |
2 |
26 Feb 07 |
jari |
1199 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
1200 |
int [][] clusters = null; |
2 |
26 Feb 07 |
jari |
1201 |
|
2 |
26 Feb 07 |
jari |
1202 |
DefaultMutableTreeNode[] nodeArray = new DefaultMutableTreeNode[4]; |
2 |
26 Feb 07 |
jari |
1203 |
nodeArray[0] = new DefaultMutableTreeNode("Used classifiers"); |
2 |
26 Feb 07 |
jari |
1204 |
nodeArray[1] = new DefaultMutableTreeNode("Unused classifiers"); |
2 |
26 Feb 07 |
jari |
1205 |
nodeArray[2] = new DefaultMutableTreeNode("Classified"); |
2 |
26 Feb 07 |
jari |
1206 |
nodeArray[3] = new DefaultMutableTreeNode("Used classifiers + classified"); |
2 |
26 Feb 07 |
jari |
//nodeArray[4] = new DefaultMutableTreeNode("Unclassified"); |
2 |
26 Feb 07 |
jari |
1208 |
|
2 |
26 Feb 07 |
jari |
1209 |
if(!this.classifyGenes){ |
2 |
26 Feb 07 |
jari |
1210 |
clusters = new int[k][]; |
2 |
26 Feb 07 |
jari |
1211 |
for (int i=0; i<k; i++) { |
2 |
26 Feb 07 |
jari |
1212 |
clusters[i] = nodeList.getNode(i).getFeaturesIndexes(); |
2 |
26 Feb 07 |
jari |
1213 |
} |
2 |
26 Feb 07 |
jari |
1214 |
if(info.hcl_samples) |
2 |
26 Feb 07 |
jari |
1215 |
clusters = getOrderedIndices(nodeList, clusters, info.hcl_genes); |
2 |
26 Feb 07 |
jari |
1216 |
} |
2 |
26 Feb 07 |
jari |
//for (int i=0; i<nodeList.getSize(); i++) { |
2 |
26 Feb 07 |
jari |
1218 |
if(this.classifyGenes) { |
2 |
26 Feb 07 |
jari |
1219 |
for (int i =0; i < numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1220 |
nodeArray[0].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1), createHCLViewer(nodeList.getNode(i), info, null)))); |
2 |
26 Feb 07 |
jari |
1221 |
} |
2 |
26 Feb 07 |
jari |
1222 |
for (int i = numClasses; i < 2*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1223 |
nodeArray[1].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - numClasses), createHCLViewer(nodeList.getNode(i), info, null)))); |
2 |
26 Feb 07 |
jari |
1224 |
} |
2 |
26 Feb 07 |
jari |
1225 |
for (int i =2*numClasses; i < 3*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1226 |
nodeArray[2].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 2*numClasses), createHCLViewer(nodeList.getNode(i), info, null)))); |
2 |
26 Feb 07 |
jari |
1227 |
} |
2 |
26 Feb 07 |
jari |
1228 |
for (int i =3*numClasses; i < 4*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1229 |
nodeArray[3].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 3*numClasses), createHCLViewer(nodeList.getNode(i), info, null)))); |
2 |
26 Feb 07 |
jari |
1230 |
} |
2 |
26 Feb 07 |
jari |
1231 |
for (int i = 0; i < nodeArray.length; i++) { |
2 |
26 Feb 07 |
jari |
1232 |
node.add(nodeArray[i]); |
2 |
26 Feb 07 |
jari |
1233 |
} |
2 |
26 Feb 07 |
jari |
//nodeArray[4].add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", createHCLViewer(nodeList.getNode(4*numClasses), info, null)))); |
2 |
26 Feb 07 |
jari |
1235 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", createHCLViewer(nodeList.getNode(4*numClasses), info, null)))); |
2 |
26 Feb 07 |
jari |
//node.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), createHCLViewer(nodeList.getNode(i), info, null)))); |
2 |
26 Feb 07 |
jari |
1237 |
} |
2 |
26 Feb 07 |
jari |
1238 |
else { |
2 |
26 Feb 07 |
jari |
1239 |
for (int i =0; i < numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1240 |
nodeArray[0].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1), createHCLViewer(nodeList.getNode(i), info, clusters), new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1241 |
} |
2 |
26 Feb 07 |
jari |
1242 |
for (int i = numClasses; i < 2*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1243 |
nodeArray[1].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - numClasses), createHCLViewer(nodeList.getNode(i), info, clusters), new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1244 |
} |
2 |
26 Feb 07 |
jari |
1245 |
for (int i =2*numClasses; i < 3*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1246 |
nodeArray[2].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 2*numClasses), createHCLViewer(nodeList.getNode(i), info, clusters), new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1247 |
} |
2 |
26 Feb 07 |
jari |
1248 |
for (int i =3*numClasses; i < 4*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1249 |
nodeArray[3].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 3*numClasses), createHCLViewer(nodeList.getNode(i), info, clusters), new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1250 |
} |
2 |
26 Feb 07 |
jari |
1251 |
for (int i = 0; i < nodeArray.length; i++) { |
2 |
26 Feb 07 |
jari |
1252 |
node.add(nodeArray[i]); |
2 |
26 Feb 07 |
jari |
1253 |
} |
2 |
26 Feb 07 |
jari |
1254 |
|
2 |
26 Feb 07 |
jari |
1255 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", createHCLViewer(nodeList.getNode(4*numClasses), info, clusters), new Integer(4*numClasses)))); |
2 |
26 Feb 07 |
jari |
//nodeArray[4].add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", createHCLViewer(nodeList.getNode(4*numClasses), info, clusters), new Integer(4*numClasses)))); |
2 |
26 Feb 07 |
jari |
1257 |
|
2 |
26 Feb 07 |
jari |
1258 |
|
2 |
26 Feb 07 |
jari |
//node.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), createHCLViewer(nodeList.getNode(i), info, clusters), new Integer(i)))); |
2 |
26 Feb 07 |
jari |
1260 |
} |
2 |
26 Feb 07 |
jari |
1261 |
/* |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < nodeArray.length; i++) { |
2 |
26 Feb 07 |
jari |
node.add(nodeArray[i]); |
2 |
26 Feb 07 |
jari |
1264 |
} |
2 |
26 Feb 07 |
jari |
1265 |
*/ |
2 |
26 Feb 07 |
jari |
1266 |
//} |
2 |
26 Feb 07 |
jari |
1267 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1268 |
} |
2 |
26 Feb 07 |
jari |
1269 |
|
2 |
26 Feb 07 |
jari |
1270 |
/** |
2 |
26 Feb 07 |
jari |
* Creates an <code>HCLViewer</code>. |
2 |
26 Feb 07 |
jari |
1272 |
*/ |
2 |
26 Feb 07 |
jari |
1273 |
private IViewer createHCLViewer(Node clusterNode, GeneralInfo info, int [][] sampleClusters) { |
2 |
26 Feb 07 |
jari |
1274 |
HCLTreeData genes_result = info.hcl_genes ? getResult(clusterNode, 0) : null; |
2 |
26 Feb 07 |
jari |
1275 |
HCLTreeData samples_result = info.hcl_samples ? getResult(clusterNode, info.hcl_genes ? 4 : 0) : null; |
2 |
26 Feb 07 |
jari |
1276 |
if(this.classifyGenes) |
2 |
26 Feb 07 |
jari |
1277 |
return new HCLViewer(this.experiment, clusterNode.getFeaturesIndexes(), genes_result, samples_result); |
2 |
26 Feb 07 |
jari |
1278 |
else |
2 |
26 Feb 07 |
jari |
1279 |
return new HCLViewer(this.experiment, clusterNode.getFeaturesIndexes(), genes_result, samples_result, sampleClusters, true); |
2 |
26 Feb 07 |
jari |
1280 |
} |
2 |
26 Feb 07 |
jari |
1281 |
|
2 |
26 Feb 07 |
jari |
1282 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a hcl tree data from the specified cluster node. |
2 |
26 Feb 07 |
jari |
1284 |
*/ |
2 |
26 Feb 07 |
jari |
1285 |
private HCLTreeData getResult(Node clusterNode, int pos) { |
2 |
26 Feb 07 |
jari |
1286 |
HCLTreeData data = new HCLTreeData(); |
2 |
26 Feb 07 |
jari |
1287 |
NodeValueList valueList = clusterNode.getValues(); |
2 |
26 Feb 07 |
jari |
1288 |
data.child_1_array = (int[])valueList.getNodeValue(pos).value; |
2 |
26 Feb 07 |
jari |
1289 |
data.child_2_array = (int[])valueList.getNodeValue(pos+1).value; |
2 |
26 Feb 07 |
jari |
1290 |
data.node_order = (int[])valueList.getNodeValue(pos+2).value; |
2 |
26 Feb 07 |
jari |
1291 |
data.height = (float[])valueList.getNodeValue(pos+3).value; |
2 |
26 Feb 07 |
jari |
1292 |
return data; |
2 |
26 Feb 07 |
jari |
1293 |
} |
2 |
26 Feb 07 |
jari |
1294 |
|
2 |
26 Feb 07 |
jari |
1295 |
/*************************************************************************************** |
2 |
26 Feb 07 |
jari |
* Code to order sample clustering results based on HCL runs. sampleClusters contain an array |
2 |
26 Feb 07 |
jari |
* of sample indices for each experiment cluster. Note that these indicies are ordered in |
2 |
26 Feb 07 |
jari |
* an order which matches HCL input matrix sample order so that HCL results (node-order) can |
2 |
26 Feb 07 |
jari |
* be used to order leaf indices to match HCL samples results |
2 |
26 Feb 07 |
jari |
1300 |
*/ |
2 |
26 Feb 07 |
jari |
1301 |
private int [][] getOrderedIndices(NodeList nodeList, int [][] sampleClusters, boolean calcGeneHCL){ |
2 |
26 Feb 07 |
jari |
1302 |
HCLTreeData result; |
2 |
26 Feb 07 |
jari |
1303 |
for(int i = 0; i < sampleClusters.length ; i++){ |
2 |
26 Feb 07 |
jari |
1304 |
if(sampleClusters[i].length > 0){ |
2 |
26 Feb 07 |
jari |
1305 |
result = getResult(nodeList.getNode(i), calcGeneHCL ? 4 : 0); //get sample Result |
2 |
26 Feb 07 |
jari |
1306 |
sampleClusters[i] = getSampleOrder(result, sampleClusters[i]); |
2 |
26 Feb 07 |
jari |
1307 |
} |
2 |
26 Feb 07 |
jari |
1308 |
} |
2 |
26 Feb 07 |
jari |
1309 |
return sampleClusters; |
2 |
26 Feb 07 |
jari |
1310 |
} |
2 |
26 Feb 07 |
jari |
1311 |
|
2 |
26 Feb 07 |
jari |
1312 |
private int[] getSampleOrder(HCLTreeData result, int[] indices) { |
2 |
26 Feb 07 |
jari |
1313 |
return getLeafOrder(result.node_order, result.child_1_array, result.child_2_array, indices); |
2 |
26 Feb 07 |
jari |
1314 |
} |
2 |
26 Feb 07 |
jari |
1315 |
|
2 |
26 Feb 07 |
jari |
1316 |
private int[] getLeafOrder(int[] nodeOrder, int[] child1, int[] child2, int[] indices) { |
2 |
26 Feb 07 |
jari |
1317 |
int[] leafOrder = new int[nodeOrder.length]; |
2 |
26 Feb 07 |
jari |
1318 |
Arrays.fill(leafOrder, -1); |
2 |
26 Feb 07 |
jari |
1319 |
fillLeafOrder(leafOrder, child1, child2, 0, child1.length-2, indices); |
2 |
26 Feb 07 |
jari |
1320 |
return leafOrder; |
2 |
26 Feb 07 |
jari |
1321 |
} |
2 |
26 Feb 07 |
jari |
1322 |
|
2 |
26 Feb 07 |
jari |
1323 |
private int fillLeafOrder(int[] leafOrder, int[] child1, int[] child2, int pos, int index, int[] indices) { |
2 |
26 Feb 07 |
jari |
1324 |
if (child1[index] != -1) { |
2 |
26 Feb 07 |
jari |
1325 |
pos = fillLeafOrder(leafOrder, child1, child2, pos, child1[index], indices); |
2 |
26 Feb 07 |
jari |
1326 |
} |
2 |
26 Feb 07 |
jari |
1327 |
if (child2[index] != -1) { |
2 |
26 Feb 07 |
jari |
1328 |
pos = fillLeafOrder(leafOrder, child1, child2, pos, child2[index], indices); |
2 |
26 Feb 07 |
jari |
1329 |
} else { |
2 |
26 Feb 07 |
jari |
1330 |
leafOrder[pos] = indices == null ? index : indices[index]; |
2 |
26 Feb 07 |
jari |
1331 |
pos++; |
2 |
26 Feb 07 |
jari |
1332 |
} |
2 |
26 Feb 07 |
jari |
1333 |
return pos; |
2 |
26 Feb 07 |
jari |
1334 |
} |
2 |
26 Feb 07 |
jari |
1335 |
|
2 |
26 Feb 07 |
jari |
1336 |
/**************************************************************************************** |
2 |
26 Feb 07 |
jari |
* End of Sample Cluster index ordering code |
2 |
26 Feb 07 |
jari |
1338 |
*/ |
2 |
26 Feb 07 |
jari |
1339 |
|
2 |
26 Feb 07 |
jari |
1340 |
/** |
2 |
26 Feb 07 |
jari |
* Adds node with cluster information. |
2 |
26 Feb 07 |
jari |
1342 |
*/ |
2 |
26 Feb 07 |
jari |
1343 |
|
2 |
26 Feb 07 |
jari |
1344 |
private void addClusterInfo(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
1345 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Cluster Information"); |
2 |
26 Feb 07 |
jari |
1346 |
if(this.classifyGenes) |
2 |
26 Feb 07 |
jari |
1347 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Genes in Classes (#,%)", new KNNCInfoViewer(this.clusters, this.experiment.getNumberOfGenes(), numClasses)))); |
2 |
26 Feb 07 |
jari |
1348 |
else |
2 |
26 Feb 07 |
jari |
1349 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Samples in Classes (#,%)", new KNNCInfoViewer(this.clusters, this.experiment.getNumberOfSamples(), false, numClasses)))); |
2 |
26 Feb 07 |
jari |
1350 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1351 |
} |
2 |
26 Feb 07 |
jari |
1352 |
|
2 |
26 Feb 07 |
jari |
1353 |
private void addValidationInfo(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
1354 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode(new LeafInfo("Validation Information", new KNNCValidationInfoViewer(origNumInFiltTrgSetByClass, numberCorrectlyClassifiedByClass, numberIncorrectlyClassifiedByClass))); |
2 |
26 Feb 07 |
jari |
1355 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1356 |
} |
2 |
26 Feb 07 |
jari |
1357 |
|
2 |
26 Feb 07 |
jari |
1358 |
|
2 |
26 Feb 07 |
jari |
1359 |
private void addValidationCentroidViews(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
1360 |
DefaultMutableTreeNode centroidNode = new DefaultMutableTreeNode("Centroid Graphs"); |
2 |
26 Feb 07 |
jari |
1361 |
DefaultMutableTreeNode expressionNode = new DefaultMutableTreeNode("Expression Graphs"); |
2 |
26 Feb 07 |
jari |
1362 |
|
2 |
26 Feb 07 |
jari |
1363 |
KNNCCentroidViewer centroidViewer; |
2 |
26 Feb 07 |
jari |
1364 |
ExperimentClusterCentroidViewer expCentroidViewer; |
2 |
26 Feb 07 |
jari |
1365 |
|
2 |
26 Feb 07 |
jari |
1366 |
|
2 |
26 Feb 07 |
jari |
1367 |
int[][] shuffledClusters = new int[clusters.length][]; |
2 |
26 Feb 07 |
jari |
1368 |
for (int i = 0; i < clusters.length - 1; i++) { |
2 |
26 Feb 07 |
jari |
1369 |
shuffledClusters[i] = clusters[i + 1]; |
2 |
26 Feb 07 |
jari |
1370 |
} |
2 |
26 Feb 07 |
jari |
1371 |
shuffledClusters[clusters.length - 1] = clusters[0]; |
2 |
26 Feb 07 |
jari |
1372 |
|
2 |
26 Feb 07 |
jari |
1373 |
FloatMatrix shuffledMeans = new FloatMatrix(means.getRowDimension(), means.getColumnDimension()); |
2 |
26 Feb 07 |
jari |
1374 |
FloatMatrix shuffledVariances = new FloatMatrix(variances.getRowDimension(), variances.getColumnDimension()); |
2 |
26 Feb 07 |
jari |
1375 |
|
2 |
26 Feb 07 |
jari |
1376 |
for (int i = 0; i < clusters.length - 1; i++) { |
2 |
26 Feb 07 |
jari |
1377 |
shuffledMeans.A[i] = means.A[i + 1]; |
2 |
26 Feb 07 |
jari |
1378 |
shuffledVariances.A[i] = variances.A[i + 1]; |
2 |
26 Feb 07 |
jari |
1379 |
} |
2 |
26 Feb 07 |
jari |
1380 |
|
2 |
26 Feb 07 |
jari |
1381 |
shuffledMeans.A[clusters.length - 1] = means.A[0]; |
2 |
26 Feb 07 |
jari |
1382 |
shuffledVariances.A[clusters.length - 1] = variances.A[0]; |
2 |
26 Feb 07 |
jari |
1383 |
|
2 |
26 Feb 07 |
jari |
1384 |
if(classifyGenes){ |
2 |
26 Feb 07 |
jari |
1385 |
centroidViewer = new KNNCCentroidViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1386 |
centroidViewer.setMeans(this.means.A); |
2 |
26 Feb 07 |
jari |
1387 |
centroidViewer.setVariances(this.variances.A); |
2 |
26 Feb 07 |
jari |
1388 |
for (int i=1; i<this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
1389 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1390 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1391 |
} |
2 |
26 Feb 07 |
jari |
1392 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Not in training set ", centroidViewer, new CentroidUserObject(0, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1393 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Not in training set ", centroidViewer, new CentroidUserObject(0, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1394 |
|
2 |
26 Feb 07 |
jari |
1395 |
|
2 |
26 Feb 07 |
jari |
1396 |
KNNCCentroidsViewer centroidsViewer = new KNNCCentroidsViewer(this.experiment, shuffledClusters); |
2 |
26 Feb 07 |
jari |
1397 |
centroidsViewer.setMeans(shuffledMeans.A); |
2 |
26 Feb 07 |
jari |
1398 |
centroidsViewer.setVariances(shuffledVariances.A); |
2 |
26 Feb 07 |
jari |
1399 |
|
2 |
26 Feb 07 |
jari |
1400 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", centroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1401 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", centroidsViewer, new Integer(CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1402 |
|
2 |
26 Feb 07 |
jari |
1403 |
} |
2 |
26 Feb 07 |
jari |
1404 |
else{ |
2 |
26 Feb 07 |
jari |
1405 |
expCentroidViewer = new KNNCExperimentCentroidViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1406 |
|
2 |
26 Feb 07 |
jari |
1407 |
expCentroidViewer.setMeans(this.means.A); |
2 |
26 Feb 07 |
jari |
1408 |
expCentroidViewer.setVariances(this.variances.A); |
2 |
26 Feb 07 |
jari |
1409 |
for (int i=1; i<this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
1410 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1411 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1412 |
} |
2 |
26 Feb 07 |
jari |
1413 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Not in training set ", expCentroidViewer, new CentroidUserObject(0, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1414 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Not in training set ", expCentroidViewer, new CentroidUserObject(0, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1415 |
|
2 |
26 Feb 07 |
jari |
1416 |
KNNCExperimentCentroidsViewer expCentroidsViewer = new KNNCExperimentCentroidsViewer(this.experiment, shuffledClusters); |
2 |
26 Feb 07 |
jari |
1417 |
expCentroidsViewer.setMeans(shuffledMeans.A); |
2 |
26 Feb 07 |
jari |
1418 |
expCentroidsViewer.setVariances(shuffledVariances.A); |
2 |
26 Feb 07 |
jari |
1419 |
|
2 |
26 Feb 07 |
jari |
1420 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", expCentroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1421 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All Clusters", expCentroidsViewer, new Integer(CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1422 |
|
2 |
26 Feb 07 |
jari |
1423 |
|
2 |
26 Feb 07 |
jari |
1424 |
} |
2 |
26 Feb 07 |
jari |
1425 |
root.add(centroidNode); |
2 |
26 Feb 07 |
jari |
1426 |
root.add(expressionNode); |
2 |
26 Feb 07 |
jari |
1427 |
} |
2 |
26 Feb 07 |
jari |
1428 |
|
2 |
26 Feb 07 |
jari |
1429 |
/** |
2 |
26 Feb 07 |
jari |
* Adds nodes to display centroid charts. |
2 |
26 Feb 07 |
jari |
1431 |
*/ |
2 |
26 Feb 07 |
jari |
1432 |
private void addCentroidViews(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
1433 |
DefaultMutableTreeNode centroidNode = new DefaultMutableTreeNode("Centroid Graphs"); |
2 |
26 Feb 07 |
jari |
1434 |
DefaultMutableTreeNode expressionNode = new DefaultMutableTreeNode("Expression Graphs"); |
2 |
26 Feb 07 |
jari |
1435 |
|
2 |
26 Feb 07 |
jari |
1436 |
KNNCCentroidViewer centroidViewer; |
2 |
26 Feb 07 |
jari |
1437 |
ExperimentClusterCentroidViewer expCentroidViewer; |
2 |
26 Feb 07 |
jari |
1438 |
|
2 |
26 Feb 07 |
jari |
1439 |
DefaultMutableTreeNode[] centroidNodeArray = new DefaultMutableTreeNode[4]; |
2 |
26 Feb 07 |
jari |
1440 |
DefaultMutableTreeNode[] expressionNodeArray = new DefaultMutableTreeNode[4]; |
2 |
26 Feb 07 |
jari |
1441 |
|
2 |
26 Feb 07 |
jari |
1442 |
centroidNodeArray[0] = new DefaultMutableTreeNode("Used classifiers"); |
2 |
26 Feb 07 |
jari |
1443 |
centroidNodeArray[1] = new DefaultMutableTreeNode("Unused classifiers"); |
2 |
26 Feb 07 |
jari |
1444 |
centroidNodeArray[2] = new DefaultMutableTreeNode("Classified"); |
2 |
26 Feb 07 |
jari |
1445 |
centroidNodeArray[3] = new DefaultMutableTreeNode("Used classifiers + classified"); |
2 |
26 Feb 07 |
jari |
//centroidNodeArray[4] = new DefaultMutableTreeNode("Unclassified"); |
2 |
26 Feb 07 |
jari |
//centroidNodeArray[5] = new DefaultMutableTreeNode("All"); |
2 |
26 Feb 07 |
jari |
1448 |
|
2 |
26 Feb 07 |
jari |
1449 |
expressionNodeArray[0] = new DefaultMutableTreeNode("Used classifiers"); |
2 |
26 Feb 07 |
jari |
1450 |
expressionNodeArray[1] = new DefaultMutableTreeNode("Unused classifiers"); |
2 |
26 Feb 07 |
jari |
1451 |
expressionNodeArray[2] = new DefaultMutableTreeNode("Classified"); |
2 |
26 Feb 07 |
jari |
1452 |
expressionNodeArray[3] = new DefaultMutableTreeNode("Used classifiers + classified"); |
2 |
26 Feb 07 |
jari |
//expressionNodeArray[4] = new DefaultMutableTreeNode("Unclassified"); |
2 |
26 Feb 07 |
jari |
//expressionNodeArray[5] = new DefaultMutableTreeNode("All"); |
2 |
26 Feb 07 |
jari |
1455 |
|
2 |
26 Feb 07 |
jari |
1456 |
if(classifyGenes){ |
2 |
26 Feb 07 |
jari |
1457 |
centroidViewer = new KNNCCentroidViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1458 |
centroidViewer.setMeans(this.means.A); |
2 |
26 Feb 07 |
jari |
1459 |
centroidViewer.setVariances(this.variances.A); |
2 |
26 Feb 07 |
jari |
1460 |
|
2 |
26 Feb 07 |
jari |
1461 |
for (int i =0; i < numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1462 |
centroidNodeArray[0].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1463 |
expressionNodeArray[0].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1464 |
} |
2 |
26 Feb 07 |
jari |
1465 |
for (int i = numClasses; i < 2*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1466 |
centroidNodeArray[1].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - numClasses), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1467 |
expressionNodeArray[1].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - numClasses), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1468 |
} |
2 |
26 Feb 07 |
jari |
1469 |
for (int i =2*numClasses; i < 3*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1470 |
centroidNodeArray[2].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 2*numClasses), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1471 |
expressionNodeArray[2].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 -2*numClasses), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1472 |
} |
2 |
26 Feb 07 |
jari |
1473 |
for (int i =3*numClasses; i < 4*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1474 |
centroidNodeArray[3].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 3*numClasses), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1475 |
expressionNodeArray[3].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 3*numClasses), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1476 |
} |
2 |
26 Feb 07 |
jari |
1477 |
|
2 |
26 Feb 07 |
jari |
//centroidNodeArray[4].add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", centroidViewer, new CentroidUserObject(4*numClasses, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
//expressionNodeArray[4].add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", centroidViewer, new CentroidUserObject(4*numClasses, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1480 |
/* |
2 |
26 Feb 07 |
jari |
for (int i=0; i<this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1484 |
} |
2 |
26 Feb 07 |
jari |
1485 |
*/ |
2 |
26 Feb 07 |
jari |
1486 |
|
2 |
26 Feb 07 |
jari |
1487 |
KNNCCentroidsViewer centroidsViewer = new KNNCCentroidsViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1488 |
centroidsViewer.setMeans(this.means.A); |
2 |
26 Feb 07 |
jari |
1489 |
centroidsViewer.setVariances(this.variances.A); |
2 |
26 Feb 07 |
jari |
1490 |
|
2 |
26 Feb 07 |
jari |
1491 |
for (int i = 0; i < centroidNodeArray.length; i++) { |
2 |
26 Feb 07 |
jari |
1492 |
centroidNode.add(centroidNodeArray[i]); |
2 |
26 Feb 07 |
jari |
1493 |
expressionNode.add(expressionNodeArray[i]); |
2 |
26 Feb 07 |
jari |
1494 |
} |
2 |
26 Feb 07 |
jari |
1495 |
|
2 |
26 Feb 07 |
jari |
1496 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", centroidViewer, new CentroidUserObject(4*numClasses, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1497 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", centroidViewer, new CentroidUserObject(4*numClasses, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1498 |
|
2 |
26 Feb 07 |
jari |
1499 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All ", centroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1500 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All ", centroidsViewer, new Integer(CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1501 |
|
2 |
26 Feb 07 |
jari |
1502 |
} |
2 |
26 Feb 07 |
jari |
1503 |
else{ |
2 |
26 Feb 07 |
jari |
1504 |
expCentroidViewer = new KNNCExperimentCentroidViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1505 |
|
2 |
26 Feb 07 |
jari |
1506 |
expCentroidViewer.setMeans(this.means.A); |
2 |
26 Feb 07 |
jari |
1507 |
expCentroidViewer.setVariances(this.variances.A); |
2 |
26 Feb 07 |
jari |
1508 |
for (int i =0; i < numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1509 |
centroidNodeArray[0].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1510 |
expressionNodeArray[0].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1511 |
} |
2 |
26 Feb 07 |
jari |
1512 |
for (int i = numClasses; i < 2*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1513 |
centroidNodeArray[1].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - numClasses), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1514 |
expressionNodeArray[1].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - numClasses), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1515 |
} |
2 |
26 Feb 07 |
jari |
1516 |
for (int i =2*numClasses; i < 3*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1517 |
centroidNodeArray[2].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 2*numClasses), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1518 |
expressionNodeArray[2].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 -2*numClasses), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1519 |
} |
2 |
26 Feb 07 |
jari |
1520 |
for (int i =3*numClasses; i < 4*numClasses; i++) { |
2 |
26 Feb 07 |
jari |
1521 |
centroidNodeArray[3].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 3*numClasses), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1522 |
expressionNodeArray[3].add(new DefaultMutableTreeNode(new LeafInfo("Class "+String.valueOf(i+1 - 3*numClasses), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1523 |
} |
2 |
26 Feb 07 |
jari |
1524 |
|
2 |
26 Feb 07 |
jari |
//centroidNodeArray[4].add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", expCentroidViewer, new CentroidUserObject(4*numClasses, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
//expressionNodeArray[4].add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", expCentroidViewer, new CentroidUserObject(4*numClasses, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1527 |
|
2 |
26 Feb 07 |
jari |
1528 |
/* |
2 |
26 Feb 07 |
jari |
for (int i=0; i<this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Cluster "+String.valueOf(i+1), expCentroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1532 |
} |
2 |
26 Feb 07 |
jari |
1533 |
*/ |
2 |
26 Feb 07 |
jari |
1534 |
KNNCExperimentCentroidsViewer expCentroidsViewer = new KNNCExperimentCentroidsViewer(this.experiment, clusters); |
2 |
26 Feb 07 |
jari |
1535 |
expCentroidsViewer.setMeans(this.means.A); |
2 |
26 Feb 07 |
jari |
1536 |
expCentroidsViewer.setVariances(this.variances.A); |
2 |
26 Feb 07 |
jari |
1537 |
|
2 |
26 Feb 07 |
jari |
1538 |
for (int i = 0; i < centroidNodeArray.length; i++) { |
2 |
26 Feb 07 |
jari |
1539 |
centroidNode.add(centroidNodeArray[i]); |
2 |
26 Feb 07 |
jari |
1540 |
expressionNode.add(expressionNodeArray[i]); |
2 |
26 Feb 07 |
jari |
1541 |
} |
2 |
26 Feb 07 |
jari |
1542 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", expCentroidViewer, new CentroidUserObject(4*numClasses, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1543 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("Unclassified ", expCentroidViewer, new CentroidUserObject(4*numClasses, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1544 |
|
2 |
26 Feb 07 |
jari |
1545 |
|
2 |
26 Feb 07 |
jari |
1546 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All ", expCentroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
1547 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All ", expCentroidsViewer, new Integer(CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
1548 |
|
2 |
26 Feb 07 |
jari |
1549 |
|
2 |
26 Feb 07 |
jari |
1550 |
} |
2 |
26 Feb 07 |
jari |
1551 |
/* |
2 |
26 Feb 07 |
jari |
for (int i = 0; i < centroidNodeArray.length; i++) { |
2 |
26 Feb 07 |
jari |
centroidNode.add(centroidNodeArray[i]); |
2 |
26 Feb 07 |
jari |
expressionNode.add(expressionNodeArray[i]); |
2 |
26 Feb 07 |
jari |
1555 |
} |
2 |
26 Feb 07 |
jari |
1556 |
*/ |
2 |
26 Feb 07 |
jari |
1557 |
root.add(centroidNode); |
2 |
26 Feb 07 |
jari |
1558 |
root.add(expressionNode); |
2 |
26 Feb 07 |
jari |
1559 |
} |
2 |
26 Feb 07 |
jari |
1560 |
|
2 |
26 Feb 07 |
jari |
1561 |
/** |
2 |
26 Feb 07 |
jari |
* Adds node with general iformation. |
2 |
26 Feb 07 |
jari |
1563 |
*/ |
2 |
26 Feb 07 |
jari |
1564 |
private void addGeneralInfo(DefaultMutableTreeNode root, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
1565 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("General Information"); |
2 |
26 Feb 07 |
jari |
1566 |
node.add(new DefaultMutableTreeNode("Original total data set size: " + info.origDataSetSize)); |
2 |
26 Feb 07 |
jari |
1567 |
node.add(new DefaultMutableTreeNode("Original training set size: " + info.origClassSetSize)); |
2 |
26 Feb 07 |
jari |
1568 |
|
2 |
26 Feb 07 |
jari |
1569 |
node.add(new DefaultMutableTreeNode("Used variance filter: " + info.usedVarFilter)); |
2 |
26 Feb 07 |
jari |
1570 |
if (useVarianceFilter) { |
2 |
26 Feb 07 |
jari |
1571 |
node.add(new DefaultMutableTreeNode("Total data set size after var. filtering: " + info.numVarFiltered)); |
2 |
26 Feb 07 |
jari |
1572 |
node.add(new DefaultMutableTreeNode("Var. filtered training set size: " + info.postVarClassSetSize)); |
2 |
26 Feb 07 |
jari |
1573 |
node.add(new DefaultMutableTreeNode("Size of set to classify after var. filtering: " + info.postVarDataSetSize)); |
2 |
26 Feb 07 |
jari |
1574 |
} |
2 |
26 Feb 07 |
jari |
1575 |
node.add(new DefaultMutableTreeNode("Used correlation filter: " + info.usedCorrelFilter)); |
2 |
26 Feb 07 |
jari |
1576 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
1577 |
node.add(new DefaultMutableTreeNode("Threshold p-value: " + info.correlPvalue)); |
2 |
26 Feb 07 |
jari |
1578 |
node.add(new DefaultMutableTreeNode("Number of permutations: " + info.numPerms)); |
2 |
26 Feb 07 |
jari |
1579 |
node.add(new DefaultMutableTreeNode("Size of set to classify after corr. filtering: " + info.postCorrDataSetSize)); |
2 |
26 Feb 07 |
jari |
1580 |
} |
2 |
26 Feb 07 |
jari |
1581 |
node.add(new DefaultMutableTreeNode("Num. classes: " + info.numClasses)); |
2 |
26 Feb 07 |
jari |
1582 |
node.add(new DefaultMutableTreeNode("Input num. neighbors: " + info.numNeighbors)); |
2 |
26 Feb 07 |
jari |
1583 |
node.add(new DefaultMutableTreeNode("Num. neighbors used: " + info.usedNumNeibs)); |
2 |
26 Feb 07 |
jari |
1584 |
node.add(new DefaultMutableTreeNode("HCL: "+info.getMethodName())); |
2 |
26 Feb 07 |
jari |
1585 |
node.add(new DefaultMutableTreeNode("Time: "+String.valueOf(info.time)+" ms")); |
2 |
26 Feb 07 |
jari |
//node.add(new DefaultMutableTreeNode(info.function)); |
2 |
26 Feb 07 |
jari |
1587 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1588 |
} |
2 |
26 Feb 07 |
jari |
1589 |
|
2 |
26 Feb 07 |
jari |
1590 |
private void addValidationGeneralInfo(DefaultMutableTreeNode root, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
1591 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("General Information"); |
2 |
26 Feb 07 |
jari |
1592 |
node.add(new DefaultMutableTreeNode("Used correlation filter: " + info.usedCorrelFilter)); |
2 |
26 Feb 07 |
jari |
1593 |
if (useCorrelFilter) { |
2 |
26 Feb 07 |
jari |
1594 |
node.add(new DefaultMutableTreeNode("Threshold p-value: " + info.correlPvalue)); |
2 |
26 Feb 07 |
jari |
1595 |
node.add(new DefaultMutableTreeNode("Number of permutations: " + info.numPerms)); |
2 |
26 Feb 07 |
jari |
//node.add(new DefaultMutableTreeNode("Size of set to classify after corr. filtering: " + info.postCorrDataSetSize)); |
2 |
26 Feb 07 |
jari |
1597 |
} |
2 |
26 Feb 07 |
jari |
1598 |
node.add(new DefaultMutableTreeNode("Num. classes: " + info.numClasses)); |
2 |
26 Feb 07 |
jari |
1599 |
node.add(new DefaultMutableTreeNode("Input num. neighbors: " + info.numNeighbors)); |
2 |
26 Feb 07 |
jari |
1600 |
node.add(new DefaultMutableTreeNode("Num. neighbors used: " + info.usedNumNeibs)); |
2 |
26 Feb 07 |
jari |
1601 |
node.add(new DefaultMutableTreeNode("HCL: "+info.getMethodName())); |
2 |
26 Feb 07 |
jari |
1602 |
node.add(new DefaultMutableTreeNode("Time: "+String.valueOf(info.time)+" ms")); |
2 |
26 Feb 07 |
jari |
//node.add(new DefaultMutableTreeNode(info.function)); |
2 |
26 Feb 07 |
jari |
1604 |
root.add(node); |
2 |
26 Feb 07 |
jari |
1605 |
} |
2 |
26 Feb 07 |
jari |
1606 |
|
2 |
26 Feb 07 |
jari |
1607 |
/** |
2 |
26 Feb 07 |
jari |
* The class to listen to progress, monitor and algorithms events. |
2 |
26 Feb 07 |
jari |
1609 |
*/ |
2 |
26 Feb 07 |
jari |
1610 |
private class Listener extends DialogListener implements AlgorithmListener { |
2 |
26 Feb 07 |
jari |
1611 |
|
2 |
26 Feb 07 |
jari |
1612 |
public void valueChanged(AlgorithmEvent event) { |
2 |
26 Feb 07 |
jari |
1613 |
switch (event.getId()) { |
2 |
26 Feb 07 |
jari |
1614 |
case AlgorithmEvent.SET_UNITS: |
2 |
26 Feb 07 |
jari |
1615 |
progress.setUnits(event.getIntValue()); |
2 |
26 Feb 07 |
jari |
1616 |
progress.setDescription(event.getDescription()); |
2 |
26 Feb 07 |
jari |
1617 |
break; |
2 |
26 Feb 07 |
jari |
1618 |
case AlgorithmEvent.PROGRESS_VALUE: |
2 |
26 Feb 07 |
jari |
1619 |
progress.setValue(event.getIntValue()); |
2 |
26 Feb 07 |
jari |
1620 |
progress.setDescription(event.getDescription()); |
2 |
26 Feb 07 |
jari |
1621 |
break; |
2 |
26 Feb 07 |
jari |
1622 |
case AlgorithmEvent.MONITOR_VALUE: |
2 |
26 Feb 07 |
jari |
1623 |
int value = event.getIntValue(); |
2 |
26 Feb 07 |
jari |
1624 |
if (value == -1) { |
2 |
26 Feb 07 |
jari |
//monitor.dispose(); |
2 |
26 Feb 07 |
jari |
1626 |
} else { |
2 |
26 Feb 07 |
jari |
//monitor.update(value); |
2 |
26 Feb 07 |
jari |
1628 |
} |
2 |
26 Feb 07 |
jari |
1629 |
break; |
2 |
26 Feb 07 |
jari |
1630 |
} |
2 |
26 Feb 07 |
jari |
1631 |
} |
2 |
26 Feb 07 |
jari |
1632 |
|
2 |
26 Feb 07 |
jari |
1633 |
public void actionPerformed(ActionEvent e) { |
2 |
26 Feb 07 |
jari |
1634 |
String command = e.getActionCommand(); |
2 |
26 Feb 07 |
jari |
1635 |
if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
1636 |
algorithm.abort(); |
2 |
26 Feb 07 |
jari |
1637 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
//monitor.dispose(); |
2 |
26 Feb 07 |
jari |
1639 |
} |
2 |
26 Feb 07 |
jari |
1640 |
} |
2 |
26 Feb 07 |
jari |
1641 |
|
2 |
26 Feb 07 |
jari |
1642 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
1643 |
algorithm.abort(); |
2 |
26 Feb 07 |
jari |
1644 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
//monitor.dispose(); |
2 |
26 Feb 07 |
jari |
1646 |
} |
2 |
26 Feb 07 |
jari |
1647 |
} |
2 |
26 Feb 07 |
jari |
1648 |
|
2 |
26 Feb 07 |
jari |
// the general info structure |
2 |
26 Feb 07 |
jari |
1650 |
private class GeneralInfo { |
2 |
26 Feb 07 |
jari |
1651 |
|
2 |
26 Feb 07 |
jari |
1652 |
public long time; |
2 |
26 Feb 07 |
jari |
1653 |
public String function; |
2 |
26 Feb 07 |
jari |
1654 |
|
2 |
26 Feb 07 |
jari |
1655 |
private boolean hcl; |
2 |
26 Feb 07 |
jari |
1656 |
private int hcl_method; |
2 |
26 Feb 07 |
jari |
1657 |
private boolean hcl_genes; |
2 |
26 Feb 07 |
jari |
1658 |
private boolean hcl_samples; |
2 |
26 Feb 07 |
jari |
1659 |
|
2 |
26 Feb 07 |
jari |
1660 |
private int numClasses, numNeighbors, numVarFiltered, numPerms, usedNumNeibs, postVarClassSetSize, postVarDataSetSize, postCorrDataSetSize; |
2 |
26 Feb 07 |
jari |
1661 |
private int origDataSetSize, origClassSetSize; |
2 |
26 Feb 07 |
jari |
1662 |
private boolean usedVarFilter, usedCorrelFilter; |
2 |
26 Feb 07 |
jari |
1663 |
private double correlPvalue; |
2 |
26 Feb 07 |
jari |
1664 |
|
2 |
26 Feb 07 |
jari |
1665 |
public String getMethodName() { |
2 |
26 Feb 07 |
jari |
1666 |
return hcl ? HCLGUI.GeneralInfo.getMethodName(hcl_method) : "no linkage"; |
2 |
26 Feb 07 |
jari |
1667 |
} |
2 |
26 Feb 07 |
jari |
1668 |
|
2 |
26 Feb 07 |
jari |
1669 |
} |
2 |
26 Feb 07 |
jari |
1670 |
|
2 |
26 Feb 07 |
jari |
1671 |
} |
2 |
26 Feb 07 |
jari |
1672 |
|
2 |
26 Feb 07 |
jari |
1673 |
|
2 |
26 Feb 07 |
jari |
1674 |
|
2 |
26 Feb 07 |
jari |
1675 |
|
2 |
26 Feb 07 |
jari |
1676 |
|
2 |
26 Feb 07 |
jari |
1677 |
|
2 |
26 Feb 07 |
jari |
1678 |
|
2 |
26 Feb 07 |
jari |
1679 |
|
2 |
26 Feb 07 |
jari |
1680 |
|
2 |
26 Feb 07 |
jari |
1681 |
|
2 |
26 Feb 07 |
jari |
1682 |
|
2 |
26 Feb 07 |
jari |
1683 |
|
2 |
26 Feb 07 |
jari |
1684 |
|
2 |
26 Feb 07 |
jari |
1685 |
|
2 |
26 Feb 07 |
jari |
1686 |
|
2 |
26 Feb 07 |
jari |
1687 |
|
2 |
26 Feb 07 |
jari |
1688 |
|
2 |
26 Feb 07 |
jari |
1689 |
|
2 |
26 Feb 07 |
jari |
1690 |
|
2 |
26 Feb 07 |
jari |
1691 |
|