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 |
* TFAGUI.java |
2 |
26 Feb 07 |
jari |
7 |
* |
2 |
26 Feb 07 |
jari |
* Created on February 12, 2004, 10:44 AM |
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.tfa; |
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.util.Vector; |
2 |
26 Feb 07 |
jari |
16 |
|
2 |
26 Feb 07 |
jari |
17 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
18 |
import javax.swing.JOptionPane; |
2 |
26 Feb 07 |
jari |
19 |
import javax.swing.tree.DefaultMutableTreeNode; |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
import org.tigr.microarray.mev.cluster.Cluster; |
2 |
26 Feb 07 |
jari |
22 |
import org.tigr.microarray.mev.cluster.Node; |
2 |
26 Feb 07 |
jari |
23 |
import org.tigr.microarray.mev.cluster.NodeList; |
2 |
26 Feb 07 |
jari |
24 |
import org.tigr.microarray.mev.cluster.NodeValueList; |
2 |
26 Feb 07 |
jari |
25 |
import org.tigr.microarray.mev.cluster.algorithm.AbortException; |
2 |
26 Feb 07 |
jari |
26 |
import org.tigr.microarray.mev.cluster.algorithm.Algorithm; |
2 |
26 Feb 07 |
jari |
27 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmData; |
2 |
26 Feb 07 |
jari |
28 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmEvent; |
2 |
26 Feb 07 |
jari |
29 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmException; |
2 |
26 Feb 07 |
jari |
30 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmListener; |
2 |
26 Feb 07 |
jari |
31 |
import org.tigr.microarray.mev.cluster.algorithm.AlgorithmParameters; |
2 |
26 Feb 07 |
jari |
32 |
import org.tigr.microarray.mev.cluster.gui.Experiment; |
2 |
26 Feb 07 |
jari |
33 |
import org.tigr.microarray.mev.cluster.gui.IClusterGUI; |
2 |
26 Feb 07 |
jari |
34 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
35 |
import org.tigr.microarray.mev.cluster.gui.IDistanceMenu; |
2 |
26 Feb 07 |
jari |
36 |
import org.tigr.microarray.mev.cluster.gui.IFramework; |
2 |
26 Feb 07 |
jari |
37 |
import org.tigr.microarray.mev.cluster.gui.IViewer; |
2 |
26 Feb 07 |
jari |
38 |
import org.tigr.microarray.mev.cluster.gui.LeafInfo; |
2 |
26 Feb 07 |
jari |
39 |
import org.tigr.microarray.mev.cluster.gui.helpers.CentroidUserObject; |
2 |
26 Feb 07 |
jari |
40 |
import org.tigr.microarray.mev.cluster.gui.helpers.ClusterTableViewer; |
2 |
26 Feb 07 |
jari |
41 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.DialogListener; |
2 |
26 Feb 07 |
jari |
42 |
import org.tigr.microarray.mev.cluster.gui.impl.dialogs.Progress; |
2 |
26 Feb 07 |
jari |
43 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLGUI; |
2 |
26 Feb 07 |
jari |
44 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLInitDialog; |
2 |
26 Feb 07 |
jari |
45 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLTreeData; |
2 |
26 Feb 07 |
jari |
46 |
import org.tigr.microarray.mev.cluster.gui.impl.hcl.HCLViewer; |
2 |
26 Feb 07 |
jari |
47 |
import org.tigr.microarray.mev.script.scriptGUI.IScriptGUI; |
2 |
26 Feb 07 |
jari |
48 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
49 |
|
2 |
26 Feb 07 |
jari |
50 |
/** |
2 |
26 Feb 07 |
jari |
51 |
* |
2 |
26 Feb 07 |
jari |
* @author nbhagaba |
2 |
26 Feb 07 |
jari |
53 |
*/ |
2 |
26 Feb 07 |
jari |
54 |
public class TFAGUI implements IClusterGUI, IScriptGUI { |
2 |
26 Feb 07 |
jari |
55 |
|
2 |
26 Feb 07 |
jari |
56 |
public static final int JUST_ALPHA = 4; |
2 |
26 Feb 07 |
jari |
57 |
public static final int STD_BONFERRONI = 5; |
2 |
26 Feb 07 |
jari |
58 |
public static final int ADJ_BONFERRONI = 6; |
2 |
26 Feb 07 |
jari |
59 |
public static final int MAX_T = 9; |
2 |
26 Feb 07 |
jari |
60 |
public static final int MIN_P = 10; |
2 |
26 Feb 07 |
jari |
61 |
|
2 |
26 Feb 07 |
jari |
62 |
private Algorithm algorithm; |
2 |
26 Feb 07 |
jari |
63 |
private Progress progress; |
2 |
26 Feb 07 |
jari |
64 |
private Experiment experiment; |
2 |
26 Feb 07 |
jari |
65 |
private IData data; |
2 |
26 Feb 07 |
jari |
66 |
private int[][] clusters; |
2 |
26 Feb 07 |
jari |
67 |
private FloatMatrix means; |
2 |
26 Feb 07 |
jari |
68 |
private FloatMatrix variances; |
2 |
26 Feb 07 |
jari |
69 |
|
2 |
26 Feb 07 |
jari |
70 |
Vector exptNamesVector; |
2 |
26 Feb 07 |
jari |
71 |
String[] factorNames; |
2 |
26 Feb 07 |
jari |
72 |
int[] numFactorLevels; |
2 |
26 Feb 07 |
jari |
73 |
int[] factorAAssignments, factorBAssignments; |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
75 |
private Object[][] auxData; |
2 |
26 Feb 07 |
jari |
76 |
private String[] auxTitles; |
2 |
26 Feb 07 |
jari |
77 |
String[] clusterLabels; |
2 |
26 Feb 07 |
jari |
78 |
private boolean usePerms, drawSigTreesOnly; |
2 |
26 Feb 07 |
jari |
79 |
|
2 |
26 Feb 07 |
jari |
/** Creates a new instance of TFAGUI */ |
2 |
26 Feb 07 |
jari |
81 |
public TFAGUI() { |
2 |
26 Feb 07 |
jari |
82 |
} |
2 |
26 Feb 07 |
jari |
83 |
|
2 |
26 Feb 07 |
jari |
84 |
/** |
2 |
26 Feb 07 |
jari |
* This method should return a tree with calculation results or |
2 |
26 Feb 07 |
jari |
86 |
* |
2 |
26 Feb 07 |
jari |
* null, if analysis start was canceled. |
2 |
26 Feb 07 |
jari |
88 |
* |
2 |
26 Feb 07 |
jari |
89 |
* |
2 |
26 Feb 07 |
jari |
90 |
* |
2 |
26 Feb 07 |
jari |
* @param framework the reference to <code>IFramework</code> implementation, |
2 |
26 Feb 07 |
jari |
92 |
* |
2 |
26 Feb 07 |
jari |
* which is used to obtain an initial analysis data and parameters. |
2 |
26 Feb 07 |
jari |
94 |
* |
2 |
26 Feb 07 |
jari |
* @throws AlgorithmException if calculation was failed. |
2 |
26 Feb 07 |
jari |
96 |
* |
2 |
26 Feb 07 |
jari |
* @throws AbortException if calculation was canceled. |
2 |
26 Feb 07 |
jari |
98 |
* |
2 |
26 Feb 07 |
jari |
* @see IFramework |
2 |
26 Feb 07 |
jari |
100 |
* |
2 |
26 Feb 07 |
jari |
101 |
*/ |
2 |
26 Feb 07 |
jari |
102 |
public DefaultMutableTreeNode execute(IFramework framework) throws AlgorithmException { |
2 |
26 Feb 07 |
jari |
103 |
this.experiment = framework.getData().getExperiment(); |
2 |
26 Feb 07 |
jari |
104 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
105 |
|
2 |
26 Feb 07 |
jari |
106 |
int number_of_samples = experiment.getNumberOfSamples(); |
2 |
26 Feb 07 |
jari |
107 |
int number_of_genes = experiment.getNumberOfGenes(); |
2 |
26 Feb 07 |
jari |
108 |
|
2 |
26 Feb 07 |
jari |
109 |
exptNamesVector = new Vector(); |
2 |
26 Feb 07 |
jari |
110 |
for (int i = 0; i < number_of_samples; i++) { |
2 |
26 Feb 07 |
jari |
111 |
exptNamesVector.add(framework.getData().getFullSampleName(experiment.getSampleIndex(i))); |
2 |
26 Feb 07 |
jari |
112 |
} |
2 |
26 Feb 07 |
jari |
113 |
|
2 |
26 Feb 07 |
jari |
114 |
TFAInitBox1 t1Box = new TFAInitBox1((JFrame)framework.getFrame(), true); |
2 |
26 Feb 07 |
jari |
115 |
t1Box.setVisible(true); |
2 |
26 Feb 07 |
jari |
116 |
if (!t1Box.isOkPressed()) return null; |
2 |
26 Feb 07 |
jari |
117 |
|
2 |
26 Feb 07 |
jari |
118 |
factorNames = new String[2]; |
2 |
26 Feb 07 |
jari |
119 |
numFactorLevels = new int[2]; |
2 |
26 Feb 07 |
jari |
120 |
|
2 |
26 Feb 07 |
jari |
121 |
factorNames[0] = t1Box.getFactorAName(); |
2 |
26 Feb 07 |
jari |
122 |
factorNames[1] = t1Box.getFactorBName(); |
2 |
26 Feb 07 |
jari |
123 |
|
2 |
26 Feb 07 |
jari |
124 |
String[] localClustNames = {factorNames[0] + " significant", factorNames[1] + " significant", "Interaction signficant", factorNames[0] + " non-significant", factorNames[1] + " non-significant", "Interaction non-signficant", "Non-significant for all effects"}; |
2 |
26 Feb 07 |
jari |
125 |
clusterLabels = new String[localClustNames.length]; |
2 |
26 Feb 07 |
jari |
126 |
|
2 |
26 Feb 07 |
jari |
127 |
for (int i = 0; i < clusterLabels.length; i++) { |
2 |
26 Feb 07 |
jari |
128 |
clusterLabels[i] = localClustNames[i]; |
2 |
26 Feb 07 |
jari |
129 |
} |
2 |
26 Feb 07 |
jari |
130 |
|
2 |
26 Feb 07 |
jari |
131 |
numFactorLevels[0] = t1Box.getNumFactorALevels(); |
2 |
26 Feb 07 |
jari |
132 |
numFactorLevels[1] = t1Box.getNumFactorBLevels(); |
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
134 |
TFAInitBox2 t2Box = new TFAInitBox2((JFrame)framework.getFrame(), true, exptNamesVector, factorNames, numFactorLevels); |
2 |
26 Feb 07 |
jari |
135 |
t2Box.setVisible(true); |
2 |
26 Feb 07 |
jari |
136 |
|
2 |
26 Feb 07 |
jari |
137 |
if (!t2Box.isOkPressed()) return null; |
2 |
26 Feb 07 |
jari |
138 |
|
2 |
26 Feb 07 |
jari |
139 |
boolean allCellsHaveOneSample = t2Box.allCellsHaveOneSample(); |
2 |
26 Feb 07 |
jari |
140 |
boolean isHierarchicalTree = t2Box.drawTrees(); |
2 |
26 Feb 07 |
jari |
141 |
drawSigTreesOnly = true; |
2 |
26 Feb 07 |
jari |
142 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
143 |
drawSigTreesOnly = t2Box.drawSigTreesOnly(); |
2 |
26 Feb 07 |
jari |
144 |
} |
2 |
26 Feb 07 |
jari |
145 |
int adjustmentMethod = t2Box.getAdjustmentMethod(); |
2 |
26 Feb 07 |
jari |
146 |
float alpha = t2Box.getAlpha(); |
2 |
26 Feb 07 |
jari |
147 |
factorAAssignments = t2Box.getFactorAAssignments(); |
2 |
26 Feb 07 |
jari |
148 |
factorBAssignments = t2Box.getFactorBAssignments(); |
2 |
26 Feb 07 |
jari |
149 |
Vector[][] bothFactorAssignments = t2Box.getBothFactorAssignments(); |
2 |
26 Feb 07 |
jari |
150 |
boolean isBalancedDesign = false; |
2 |
26 Feb 07 |
jari |
151 |
if (!allCellsHaveOneSample) { |
2 |
26 Feb 07 |
jari |
152 |
isBalancedDesign = t2Box.isBalancedDesign(); |
2 |
26 Feb 07 |
jari |
153 |
} |
2 |
26 Feb 07 |
jari |
154 |
usePerms = t2Box.usePerms(); |
2 |
26 Feb 07 |
jari |
155 |
int numPerms = 0; |
2 |
26 Feb 07 |
jari |
156 |
if (usePerms) { |
2 |
26 Feb 07 |
jari |
157 |
numPerms = t2Box.getNumPerms(); |
2 |
26 Feb 07 |
jari |
158 |
} |
2 |
26 Feb 07 |
jari |
159 |
|
2 |
26 Feb 07 |
jari |
160 |
IDistanceMenu menu = framework.getDistanceMenu(); |
2 |
26 Feb 07 |
jari |
161 |
int function = menu.getDistanceFunction(); |
2 |
26 Feb 07 |
jari |
162 |
if (function == Algorithm.DEFAULT) { |
2 |
26 Feb 07 |
jari |
163 |
function = Algorithm.EUCLIDEAN; |
2 |
26 Feb 07 |
jari |
164 |
} |
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
// hcl init |
2 |
26 Feb 07 |
jari |
167 |
int hcl_method = 0; |
2 |
26 Feb 07 |
jari |
168 |
boolean hcl_samples = false; |
2 |
26 Feb 07 |
jari |
169 |
boolean hcl_genes = false; |
2 |
26 Feb 07 |
jari |
170 |
int hcl_function = 4; |
2 |
26 Feb 07 |
jari |
171 |
boolean hcl_absolute = false; |
2 |
26 Feb 07 |
jari |
172 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
173 |
HCLInitDialog hcl_dialog = new HCLInitDialog(framework.getFrame(), menu.getFunctionName(function), menu.isAbsoluteDistance(), true); |
2 |
26 Feb 07 |
jari |
174 |
if (hcl_dialog.showModal() != JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
175 |
return null; |
2 |
26 Feb 07 |
jari |
176 |
} |
2 |
26 Feb 07 |
jari |
177 |
hcl_method = hcl_dialog.getMethod(); |
2 |
26 Feb 07 |
jari |
178 |
hcl_samples = hcl_dialog.isClusterExperiments(); |
2 |
26 Feb 07 |
jari |
179 |
hcl_genes = hcl_dialog.isClusterGenes(); |
2 |
26 Feb 07 |
jari |
180 |
hcl_function = hcl_dialog.getDistanceMetric(); |
2 |
26 Feb 07 |
jari |
181 |
hcl_absolute = hcl_dialog.getAbsoluteSelection(); |
2 |
26 Feb 07 |
jari |
182 |
} |
2 |
26 Feb 07 |
jari |
183 |
|
2 |
26 Feb 07 |
jari |
184 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
185 |
|
2 |
26 Feb 07 |
jari |
186 |
try { |
2 |
26 Feb 07 |
jari |
187 |
algorithm = framework.getAlgorithmFactory().getAlgorithm("TFA"); |
2 |
26 Feb 07 |
jari |
188 |
algorithm.addAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
189 |
|
2 |
26 Feb 07 |
jari |
190 |
int genes = experiment.getNumberOfGenes(); |
2 |
26 Feb 07 |
jari |
191 |
|
2 |
26 Feb 07 |
jari |
192 |
this.progress = new Progress(framework.getFrame(), "Finding significant genes", listener); |
2 |
26 Feb 07 |
jari |
193 |
this.progress.show(); |
2 |
26 Feb 07 |
jari |
194 |
|
2 |
26 Feb 07 |
jari |
195 |
AlgorithmData data = new AlgorithmData(); |
2 |
26 Feb 07 |
jari |
196 |
|
2 |
26 Feb 07 |
jari |
197 |
data.addMatrix("experiment", experiment.getMatrix()); |
2 |
26 Feb 07 |
jari |
198 |
data.addParam("distance-factor", String.valueOf(1.0f)); |
2 |
26 Feb 07 |
jari |
199 |
data.addParam("distance-absolute", String.valueOf(menu.isAbsoluteDistance())); |
2 |
26 Feb 07 |
jari |
200 |
|
2 |
26 Feb 07 |
jari |
201 |
data.addParam("distance-function", String.valueOf(function)); |
2 |
26 Feb 07 |
jari |
202 |
data.addIntArray("numFactorLevels", numFactorLevels); |
2 |
26 Feb 07 |
jari |
203 |
data.addParam("allCellsHaveOneSample", String.valueOf(allCellsHaveOneSample)); |
2 |
26 Feb 07 |
jari |
204 |
data.addParam("adjustmentMethod", String.valueOf(adjustmentMethod)); |
2 |
26 Feb 07 |
jari |
205 |
data.addParam("alpha", String.valueOf(alpha)); |
2 |
26 Feb 07 |
jari |
206 |
data.addIntArray("factorAAssignments", factorAAssignments); |
2 |
26 Feb 07 |
jari |
207 |
data.addIntArray("factorBAssignments", factorBAssignments); |
2 |
26 Feb 07 |
jari |
208 |
data.addObjectMatrix("bothFactorAssignments", bothFactorAssignments); |
2 |
26 Feb 07 |
jari |
209 |
data.addParam("isBalancedDesign", String.valueOf(isBalancedDesign)); |
2 |
26 Feb 07 |
jari |
210 |
data.addParam("usePerms", String.valueOf(usePerms)); |
2 |
26 Feb 07 |
jari |
211 |
data.addParam("numPerms", String.valueOf(numPerms)); |
2 |
26 Feb 07 |
jari |
// hcl parameters |
2 |
26 Feb 07 |
jari |
213 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
214 |
data.addParam("hierarchical-tree", String.valueOf(true)); |
2 |
26 Feb 07 |
jari |
215 |
data.addParam("draw-sig-trees-only", String.valueOf(drawSigTreesOnly)); |
2 |
26 Feb 07 |
jari |
216 |
data.addParam("method-linkage", String.valueOf(hcl_method)); |
2 |
26 Feb 07 |
jari |
217 |
data.addParam("calculate-genes", String.valueOf(hcl_genes)); |
2 |
26 Feb 07 |
jari |
218 |
data.addParam("calculate-experiments", String.valueOf(hcl_samples)); |
2 |
26 Feb 07 |
jari |
219 |
data.addParam("hcl-distance-function", String.valueOf(hcl_function)); |
2 |
26 Feb 07 |
jari |
220 |
data.addParam("hcl-distance-absolute", String.valueOf(hcl_absolute)); |
2 |
26 Feb 07 |
jari |
221 |
} |
2 |
26 Feb 07 |
jari |
222 |
|
2 |
26 Feb 07 |
jari |
223 |
long start = System.currentTimeMillis(); |
2 |
26 Feb 07 |
jari |
224 |
AlgorithmData result = algorithm.execute(data); |
2 |
26 Feb 07 |
jari |
225 |
long time = System.currentTimeMillis() - start; |
2 |
26 Feb 07 |
jari |
226 |
|
2 |
26 Feb 07 |
jari |
// getting the results |
2 |
26 Feb 07 |
jari |
228 |
Cluster result_cluster = result.getCluster("cluster"); |
2 |
26 Feb 07 |
jari |
229 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
//AlgorithmParameters resultMap = result.getParams(); |
2 |
26 Feb 07 |
jari |
231 |
int k = 7; //resultMap.getInt("number-of-clusters"); // NEED THIS TO GET THE VALUE OF NUMBER-OF-CLUSTERS |
2 |
26 Feb 07 |
jari |
232 |
|
2 |
26 Feb 07 |
jari |
233 |
this.clusters = new int[k][]; |
2 |
26 Feb 07 |
jari |
234 |
for (int i=0; i<k; i++) { |
2 |
26 Feb 07 |
jari |
235 |
clusters[i] = nodeList.getNode(i).getFeaturesIndexes(); |
2 |
26 Feb 07 |
jari |
236 |
} |
2 |
26 Feb 07 |
jari |
237 |
this.means = result.getMatrix("clusters_means"); |
2 |
26 Feb 07 |
jari |
238 |
this.variances = result.getMatrix("clusters_variances"); |
2 |
26 Feb 07 |
jari |
239 |
FloatMatrix factorAFValuesMatrix = result.getMatrix("factorAFValuesMatrix"); |
2 |
26 Feb 07 |
jari |
240 |
FloatMatrix factorBFValuesMatrix = result.getMatrix("factorBFValuesMatrix"); |
2 |
26 Feb 07 |
jari |
241 |
FloatMatrix interactionFValuesMatrix = result.getMatrix("interactionFValuesMatrix"); |
2 |
26 Feb 07 |
jari |
242 |
|
2 |
26 Feb 07 |
jari |
243 |
FloatMatrix factorADfValuesMatrix = result.getMatrix("factorADfValuesMatrix"); |
2 |
26 Feb 07 |
jari |
244 |
FloatMatrix factorBDfValuesMatrix = result.getMatrix("factorBDfValuesMatrix"); |
2 |
26 Feb 07 |
jari |
245 |
FloatMatrix interactionDfValuesMatrix = result.getMatrix("interactionDfValuesMatrix"); |
2 |
26 Feb 07 |
jari |
246 |
FloatMatrix errorDfValuesMatrix = result.getMatrix("errorDfValuesMatrix"); |
2 |
26 Feb 07 |
jari |
247 |
|
2 |
26 Feb 07 |
jari |
248 |
FloatMatrix origFactorAPValuesMatrix = result.getMatrix("origFactorAPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
249 |
FloatMatrix origFactorBPValuesMatrix = result.getMatrix("origFactorBPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
250 |
FloatMatrix origInteractionPValuesMatrix = result.getMatrix("origInteractionPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
251 |
|
2 |
26 Feb 07 |
jari |
252 |
FloatMatrix adjFactorAPValuesMatrix = result.getMatrix("adjFactorAPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
253 |
FloatMatrix adjFactorBPValuesMatrix = result.getMatrix("adjFactorBPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
254 |
FloatMatrix adjInteractionPValuesMatrix = result.getMatrix("adjInteractionPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
255 |
|
2 |
26 Feb 07 |
jari |
256 |
auxTitles = new String[13]; |
2 |
26 Feb 07 |
jari |
//auxTitles = {"Adj. p-values (" + factorNames[0] + ")", "Adj. p-values (" + factorNames[1] + ")", "Adj. p-values (interaction)", factorName[0] + " Orig. p-values", factorNames[0] + " F-ratio", factorNames[1] + "F-Ratio", "Interaction F-Ratio" }; |
2 |
26 Feb 07 |
jari |
258 |
auxTitles[0] = "Adj. p-values (" + factorNames[0] + ")"; |
2 |
26 Feb 07 |
jari |
259 |
auxTitles[1] = "Adj. p-values (" + factorNames[1] + ")"; |
2 |
26 Feb 07 |
jari |
260 |
auxTitles[2] = "Adj. p-values (interaction)"; |
2 |
26 Feb 07 |
jari |
261 |
auxTitles[3] = "Orig. p-values (" + factorNames[0] + ")"; |
2 |
26 Feb 07 |
jari |
262 |
auxTitles[4] = "Orig. p-values (" + factorNames[1] + ")"; |
2 |
26 Feb 07 |
jari |
263 |
auxTitles[5] = "Orig. p-values (interaction)"; |
2 |
26 Feb 07 |
jari |
264 |
auxTitles[6] = "F-ratio (" + factorNames[0] + ")"; |
2 |
26 Feb 07 |
jari |
265 |
auxTitles[7] = "F-ratio (" + factorNames[1] + ")"; |
2 |
26 Feb 07 |
jari |
266 |
auxTitles[8] = "F-ratio (interaction)"; |
2 |
26 Feb 07 |
jari |
267 |
auxTitles[9] = "df (" + factorNames[0] + ")"; |
2 |
26 Feb 07 |
jari |
268 |
auxTitles[10] = "df (" + factorNames[1] + ")"; |
2 |
26 Feb 07 |
jari |
269 |
auxTitles[11] = "df (interaction)"; |
2 |
26 Feb 07 |
jari |
270 |
auxTitles[12] = "df (error)"; |
2 |
26 Feb 07 |
jari |
271 |
|
2 |
26 Feb 07 |
jari |
272 |
auxData = new Object[factorAFValuesMatrix.A.length][13]; |
2 |
26 Feb 07 |
jari |
273 |
|
2 |
26 Feb 07 |
jari |
274 |
for (int i = 0; i < auxData.length; i++) { |
2 |
26 Feb 07 |
jari |
275 |
auxData[i][0] = new Float(adjFactorAPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
276 |
auxData[i][1] = new Float(adjFactorBPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
277 |
auxData[i][2] = new Float(adjInteractionPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
278 |
auxData[i][3] = new Float(origFactorAPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
279 |
auxData[i][4] = new Float(origFactorBPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
280 |
auxData[i][5] = new Float(origInteractionPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
281 |
auxData[i][6] = new Float(factorAFValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
282 |
auxData[i][7] = new Float(factorBFValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
283 |
auxData[i][8] = new Float(interactionFValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
284 |
auxData[i][9] = new Integer((int)(factorADfValuesMatrix.A[i][0])); |
2 |
26 Feb 07 |
jari |
285 |
auxData[i][10] = new Integer((int)(factorBDfValuesMatrix.A[i][0])); |
2 |
26 Feb 07 |
jari |
286 |
auxData[i][11] = new Integer((int)(interactionDfValuesMatrix.A[i][0])); |
2 |
26 Feb 07 |
jari |
287 |
auxData[i][12] = new Integer((int)(errorDfValuesMatrix.A[i][0])); |
2 |
26 Feb 07 |
jari |
288 |
} |
2 |
26 Feb 07 |
jari |
289 |
|
2 |
26 Feb 07 |
jari |
290 |
|
2 |
26 Feb 07 |
jari |
291 |
|
2 |
26 Feb 07 |
jari |
292 |
GeneralInfo info = new GeneralInfo(); |
2 |
26 Feb 07 |
jari |
293 |
info.time = time; |
2 |
26 Feb 07 |
jari |
//ADD MORE INFO PARAMETERS HERE |
2 |
26 Feb 07 |
jari |
295 |
info.alpha = alpha; |
2 |
26 Feb 07 |
jari |
296 |
info.adjMethod = getAdjMethod(adjustmentMethod); |
2 |
26 Feb 07 |
jari |
297 |
info.pValueBasedOn = getPValueBasedOn(usePerms); |
2 |
26 Feb 07 |
jari |
298 |
if (usePerms) { |
2 |
26 Feb 07 |
jari |
//info.useAllCombs = useAllCombs; |
2 |
26 Feb 07 |
jari |
300 |
info.numPerms = numPerms; |
2 |
26 Feb 07 |
jari |
301 |
} |
2 |
26 Feb 07 |
jari |
302 |
info.function = menu.getFunctionName(function); |
2 |
26 Feb 07 |
jari |
303 |
info.hcl = isHierarchicalTree; |
2 |
26 Feb 07 |
jari |
304 |
info.hcl_genes = hcl_genes; |
2 |
26 Feb 07 |
jari |
305 |
info.hcl_samples = hcl_samples; |
2 |
26 Feb 07 |
jari |
306 |
info.hcl_method = hcl_method; |
2 |
26 Feb 07 |
jari |
307 |
return createResultTree(result_cluster, info); |
2 |
26 Feb 07 |
jari |
308 |
|
2 |
26 Feb 07 |
jari |
309 |
} finally { |
2 |
26 Feb 07 |
jari |
310 |
if (algorithm != null) { |
2 |
26 Feb 07 |
jari |
311 |
algorithm.removeAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
if (progress != null) { |
2 |
26 Feb 07 |
jari |
314 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
315 |
} |
2 |
26 Feb 07 |
jari |
316 |
/* |
2 |
26 Feb 07 |
jari |
if (monitor != null) { |
2 |
26 Feb 07 |
jari |
monitor.dispose(); |
2 |
26 Feb 07 |
jari |
319 |
} |
2 |
26 Feb 07 |
jari |
320 |
*/ |
2 |
26 Feb 07 |
jari |
321 |
} |
2 |
26 Feb 07 |
jari |
322 |
|
2 |
26 Feb 07 |
jari |
//return null; // for now |
2 |
26 Feb 07 |
jari |
324 |
} |
2 |
26 Feb 07 |
jari |
325 |
|
2 |
26 Feb 07 |
jari |
326 |
|
2 |
26 Feb 07 |
jari |
327 |
|
2 |
26 Feb 07 |
jari |
328 |
public AlgorithmData getScriptParameters(IFramework framework) { |
2 |
26 Feb 07 |
jari |
329 |
this.experiment = framework.getData().getExperiment(); |
2 |
26 Feb 07 |
jari |
330 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
331 |
|
2 |
26 Feb 07 |
jari |
332 |
int number_of_samples = experiment.getNumberOfSamples(); |
2 |
26 Feb 07 |
jari |
333 |
int number_of_genes = experiment.getNumberOfGenes(); |
2 |
26 Feb 07 |
jari |
334 |
|
2 |
26 Feb 07 |
jari |
335 |
exptNamesVector = new Vector(); |
2 |
26 Feb 07 |
jari |
336 |
for (int i = 0; i < number_of_samples; i++) { |
2 |
26 Feb 07 |
jari |
337 |
exptNamesVector.add(framework.getData().getFullSampleName(experiment.getSampleIndex(i))); |
2 |
26 Feb 07 |
jari |
338 |
} |
2 |
26 Feb 07 |
jari |
339 |
|
2 |
26 Feb 07 |
jari |
340 |
TFAInitBox1 t1Box = new TFAInitBox1((JFrame)framework.getFrame(), true); |
2 |
26 Feb 07 |
jari |
341 |
t1Box.setVisible(true); |
2 |
26 Feb 07 |
jari |
342 |
if (!t1Box.isOkPressed()) return null; |
2 |
26 Feb 07 |
jari |
343 |
|
2 |
26 Feb 07 |
jari |
344 |
factorNames = new String[2]; |
2 |
26 Feb 07 |
jari |
345 |
numFactorLevels = new int[2]; |
2 |
26 Feb 07 |
jari |
346 |
|
2 |
26 Feb 07 |
jari |
347 |
factorNames[0] = t1Box.getFactorAName(); |
2 |
26 Feb 07 |
jari |
348 |
factorNames[1] = t1Box.getFactorBName(); |
2 |
26 Feb 07 |
jari |
349 |
|
2 |
26 Feb 07 |
jari |
350 |
String[] localClustNames = {factorNames[0] + " significant", factorNames[1] + " significant", "Interaction signficant", factorNames[0] + " non-significant", factorNames[1] + " non-significant", "Interaction non-signficant", "Non-significant for all effects"}; |
2 |
26 Feb 07 |
jari |
351 |
clusterLabels = new String[localClustNames.length]; |
2 |
26 Feb 07 |
jari |
352 |
|
2 |
26 Feb 07 |
jari |
353 |
for (int i = 0; i < clusterLabels.length; i++) { |
2 |
26 Feb 07 |
jari |
354 |
clusterLabels[i] = localClustNames[i]; |
2 |
26 Feb 07 |
jari |
355 |
} |
2 |
26 Feb 07 |
jari |
356 |
|
2 |
26 Feb 07 |
jari |
357 |
numFactorLevels[0] = t1Box.getNumFactorALevels(); |
2 |
26 Feb 07 |
jari |
358 |
numFactorLevels[1] = t1Box.getNumFactorBLevels(); |
2 |
26 Feb 07 |
jari |
359 |
|
2 |
26 Feb 07 |
jari |
360 |
TFAInitBox2 t2Box = new TFAInitBox2((JFrame)framework.getFrame(), true, exptNamesVector, factorNames, numFactorLevels); |
2 |
26 Feb 07 |
jari |
361 |
t2Box.setVisible(true); |
2 |
26 Feb 07 |
jari |
362 |
|
2 |
26 Feb 07 |
jari |
363 |
if (!t2Box.isOkPressed()) return null; |
2 |
26 Feb 07 |
jari |
364 |
|
2 |
26 Feb 07 |
jari |
365 |
boolean allCellsHaveOneSample = t2Box.allCellsHaveOneSample(); |
2 |
26 Feb 07 |
jari |
366 |
boolean isHierarchicalTree = t2Box.drawTrees(); |
2 |
26 Feb 07 |
jari |
367 |
drawSigTreesOnly = true; |
2 |
26 Feb 07 |
jari |
368 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
369 |
drawSigTreesOnly = t2Box.drawSigTreesOnly(); |
2 |
26 Feb 07 |
jari |
370 |
} |
2 |
26 Feb 07 |
jari |
371 |
|
2 |
26 Feb 07 |
jari |
372 |
int adjustmentMethod = t2Box.getAdjustmentMethod(); |
2 |
26 Feb 07 |
jari |
373 |
float alpha = t2Box.getAlpha(); |
2 |
26 Feb 07 |
jari |
374 |
factorAAssignments = t2Box.getFactorAAssignments(); |
2 |
26 Feb 07 |
jari |
375 |
factorBAssignments = t2Box.getFactorBAssignments(); |
2 |
26 Feb 07 |
jari |
376 |
Vector[][] bothFactorAssignments = t2Box.getBothFactorAssignments(); |
2 |
26 Feb 07 |
jari |
377 |
boolean isBalancedDesign = false; |
2 |
26 Feb 07 |
jari |
378 |
if (!allCellsHaveOneSample) { |
2 |
26 Feb 07 |
jari |
379 |
isBalancedDesign = t2Box.isBalancedDesign(); |
2 |
26 Feb 07 |
jari |
380 |
} |
2 |
26 Feb 07 |
jari |
381 |
usePerms = t2Box.usePerms(); |
2 |
26 Feb 07 |
jari |
382 |
int numPerms = 0; |
2 |
26 Feb 07 |
jari |
383 |
if (usePerms) { |
2 |
26 Feb 07 |
jari |
384 |
numPerms = t2Box.getNumPerms(); |
2 |
26 Feb 07 |
jari |
385 |
} |
2 |
26 Feb 07 |
jari |
386 |
|
2 |
26 Feb 07 |
jari |
387 |
IDistanceMenu menu = framework.getDistanceMenu(); |
2 |
26 Feb 07 |
jari |
388 |
int function = menu.getDistanceFunction(); |
2 |
26 Feb 07 |
jari |
389 |
if (function == Algorithm.DEFAULT) { |
2 |
26 Feb 07 |
jari |
390 |
function = Algorithm.EUCLIDEAN; |
2 |
26 Feb 07 |
jari |
391 |
} |
2 |
26 Feb 07 |
jari |
392 |
|
2 |
26 Feb 07 |
jari |
// hcl init |
2 |
26 Feb 07 |
jari |
394 |
int hcl_method = 0; |
2 |
26 Feb 07 |
jari |
395 |
boolean hcl_samples = false; |
2 |
26 Feb 07 |
jari |
396 |
boolean hcl_genes = false; |
2 |
26 Feb 07 |
jari |
397 |
int hcl_function = 4; |
2 |
26 Feb 07 |
jari |
398 |
boolean hcl_absolute = false; |
2 |
26 Feb 07 |
jari |
399 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
400 |
HCLInitDialog hcl_dialog = new HCLInitDialog(framework.getFrame(), menu.getFunctionName(function), menu.isAbsoluteDistance(), true); |
2 |
26 Feb 07 |
jari |
401 |
if (hcl_dialog.showModal() != JOptionPane.OK_OPTION) { |
2 |
26 Feb 07 |
jari |
402 |
return null; |
2 |
26 Feb 07 |
jari |
403 |
} |
2 |
26 Feb 07 |
jari |
404 |
hcl_method = hcl_dialog.getMethod(); |
2 |
26 Feb 07 |
jari |
405 |
hcl_samples = hcl_dialog.isClusterExperiments(); |
2 |
26 Feb 07 |
jari |
406 |
hcl_genes = hcl_dialog.isClusterGenes(); |
2 |
26 Feb 07 |
jari |
407 |
hcl_function = hcl_dialog.getDistanceMetric(); |
2 |
26 Feb 07 |
jari |
408 |
hcl_absolute = hcl_dialog.getAbsoluteSelection(); |
2 |
26 Feb 07 |
jari |
409 |
} |
2 |
26 Feb 07 |
jari |
410 |
|
2 |
26 Feb 07 |
jari |
411 |
int genes = experiment.getNumberOfGenes(); |
2 |
26 Feb 07 |
jari |
412 |
|
2 |
26 Feb 07 |
jari |
413 |
AlgorithmData data = new AlgorithmData(); |
2 |
26 Feb 07 |
jari |
414 |
data.addStringArray("cluster-labels", this.clusterLabels); |
2 |
26 Feb 07 |
jari |
415 |
data.addStringArray("factor-names", this.factorNames); |
2 |
26 Feb 07 |
jari |
416 |
data.addParam("distance-factor", String.valueOf(1.0f)); |
2 |
26 Feb 07 |
jari |
417 |
|
2 |
26 Feb 07 |
jari |
418 |
data.addParam("distance-absolute", String.valueOf(menu.isAbsoluteDistance())); |
2 |
26 Feb 07 |
jari |
419 |
|
2 |
26 Feb 07 |
jari |
420 |
data.addParam("distance-function", String.valueOf(function)); |
2 |
26 Feb 07 |
jari |
421 |
data.addIntArray("numFactorLevels", numFactorLevels); |
2 |
26 Feb 07 |
jari |
422 |
data.addParam("allCellsHaveOneSample", String.valueOf(allCellsHaveOneSample)); |
2 |
26 Feb 07 |
jari |
423 |
data.addParam("adjustmentMethod", String.valueOf(adjustmentMethod)); |
2 |
26 Feb 07 |
jari |
424 |
data.addParam("alpha", String.valueOf(alpha)); |
2 |
26 Feb 07 |
jari |
425 |
data.addIntArray("factorAAssignments", factorAAssignments); |
2 |
26 Feb 07 |
jari |
426 |
data.addIntArray("factorBAssignments", factorBAssignments); |
2 |
26 Feb 07 |
jari |
427 |
data.addObjectMatrix("bothFactorAssignments", bothFactorAssignments); |
2 |
26 Feb 07 |
jari |
428 |
data.addParam("isBalancedDesign", String.valueOf(isBalancedDesign)); |
2 |
26 Feb 07 |
jari |
429 |
data.addParam("usePerms", String.valueOf(usePerms)); |
2 |
26 Feb 07 |
jari |
430 |
data.addParam("numPerms", String.valueOf(numPerms)); |
2 |
26 Feb 07 |
jari |
// hcl parameters |
2 |
26 Feb 07 |
jari |
432 |
if (isHierarchicalTree) { |
2 |
26 Feb 07 |
jari |
433 |
data.addParam("hierarchical-tree", String.valueOf(true)); |
2 |
26 Feb 07 |
jari |
434 |
data.addParam("draw-sig-trees-only", String.valueOf(drawSigTreesOnly)); |
2 |
26 Feb 07 |
jari |
435 |
data.addParam("method-linkage", String.valueOf(hcl_method)); |
2 |
26 Feb 07 |
jari |
436 |
data.addParam("calculate-genes", String.valueOf(hcl_genes)); |
2 |
26 Feb 07 |
jari |
437 |
data.addParam("calculate-experiments", String.valueOf(hcl_samples)); |
2 |
26 Feb 07 |
jari |
438 |
data.addParam("hcl-distance-function", String.valueOf(hcl_function)); |
2 |
26 Feb 07 |
jari |
439 |
data.addParam("hcl-distance-absolute", String.valueOf(hcl_absolute)); |
2 |
26 Feb 07 |
jari |
440 |
} |
2 |
26 Feb 07 |
jari |
441 |
|
2 |
26 Feb 07 |
jari |
// alg name |
2 |
26 Feb 07 |
jari |
443 |
data.addParam("name", "2 Fact. ANOVA"); |
2 |
26 Feb 07 |
jari |
444 |
|
2 |
26 Feb 07 |
jari |
// alg type |
2 |
26 Feb 07 |
jari |
446 |
data.addParam("alg-type", "cluster-genes"); |
2 |
26 Feb 07 |
jari |
447 |
|
2 |
26 Feb 07 |
jari |
// output class |
2 |
26 Feb 07 |
jari |
449 |
data.addParam("output-class", "partition-output"); |
2 |
26 Feb 07 |
jari |
450 |
|
2 |
26 Feb 07 |
jari |
//output nodes |
2 |
26 Feb 07 |
jari |
452 |
data.addStringArray("output-nodes", clusterLabels); |
2 |
26 Feb 07 |
jari |
453 |
return data; |
2 |
26 Feb 07 |
jari |
454 |
} |
2 |
26 Feb 07 |
jari |
455 |
|
2 |
26 Feb 07 |
jari |
456 |
|
2 |
26 Feb 07 |
jari |
457 |
public DefaultMutableTreeNode executeScript(IFramework framework, AlgorithmData algData, Experiment experiment) throws AlgorithmException { |
2 |
26 Feb 07 |
jari |
458 |
this.experiment = experiment; |
2 |
26 Feb 07 |
jari |
459 |
this.data = framework.getData(); |
2 |
26 Feb 07 |
jari |
460 |
exptNamesVector = new Vector(); |
2 |
26 Feb 07 |
jari |
461 |
for (int i = 0; i < data.getFeaturesCount(); i++) { |
2 |
26 Feb 07 |
jari |
462 |
exptNamesVector.add(framework.getData().getFullSampleName(i)); |
2 |
26 Feb 07 |
jari |
463 |
} |
2 |
26 Feb 07 |
jari |
464 |
this.clusterLabels = algData.getStringArray("cluster-labels"); |
2 |
26 Feb 07 |
jari |
465 |
this.factorNames = algData.getStringArray("factor-names"); |
2 |
26 Feb 07 |
jari |
466 |
this.factorAAssignments = algData.getIntArray("factorAAssignments"); |
2 |
26 Feb 07 |
jari |
467 |
this.factorBAssignments = algData.getIntArray("factorBAssignments"); |
2 |
26 Feb 07 |
jari |
468 |
this.drawSigTreesOnly = algData.getParams().getBoolean("draw-sig-trees-only"); |
2 |
26 Feb 07 |
jari |
469 |
algData.addMatrix("experiment", experiment.getMatrix()); |
2 |
26 Feb 07 |
jari |
470 |
Listener listener = new Listener(); |
2 |
26 Feb 07 |
jari |
471 |
|
2 |
26 Feb 07 |
jari |
472 |
try { |
2 |
26 Feb 07 |
jari |
473 |
algorithm = framework.getAlgorithmFactory().getAlgorithm("TFA"); |
2 |
26 Feb 07 |
jari |
474 |
algorithm.addAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
475 |
|
2 |
26 Feb 07 |
jari |
476 |
int genes = experiment.getNumberOfGenes(); |
2 |
26 Feb 07 |
jari |
477 |
|
2 |
26 Feb 07 |
jari |
478 |
this.progress = new Progress(framework.getFrame(), "Finding significant genes", listener); |
2 |
26 Feb 07 |
jari |
479 |
this.progress.show(); |
2 |
26 Feb 07 |
jari |
480 |
|
2 |
26 Feb 07 |
jari |
481 |
long start = System.currentTimeMillis(); |
2 |
26 Feb 07 |
jari |
482 |
AlgorithmData result = algorithm.execute(algData); |
2 |
26 Feb 07 |
jari |
483 |
long time = System.currentTimeMillis() - start; |
2 |
26 Feb 07 |
jari |
484 |
|
2 |
26 Feb 07 |
jari |
// getting the results |
2 |
26 Feb 07 |
jari |
486 |
Cluster result_cluster = result.getCluster("cluster"); |
2 |
26 Feb 07 |
jari |
487 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
//AlgorithmParameters resultMap = result.getParams(); |
2 |
26 Feb 07 |
jari |
489 |
int k = 7; //resultMap.getInt("number-of-clusters"); // NEED THIS TO GET THE VALUE OF NUMBER-OF-CLUSTERS |
2 |
26 Feb 07 |
jari |
490 |
|
2 |
26 Feb 07 |
jari |
491 |
this.clusters = new int[k][]; |
2 |
26 Feb 07 |
jari |
492 |
for (int i=0; i<k; i++) { |
2 |
26 Feb 07 |
jari |
493 |
clusters[i] = nodeList.getNode(i).getFeaturesIndexes(); |
2 |
26 Feb 07 |
jari |
494 |
} |
2 |
26 Feb 07 |
jari |
495 |
this.means = result.getMatrix("clusters_means"); |
2 |
26 Feb 07 |
jari |
496 |
this.variances = result.getMatrix("clusters_variances"); |
2 |
26 Feb 07 |
jari |
497 |
FloatMatrix factorAFValuesMatrix = result.getMatrix("factorAFValuesMatrix"); |
2 |
26 Feb 07 |
jari |
498 |
FloatMatrix factorBFValuesMatrix = result.getMatrix("factorBFValuesMatrix"); |
2 |
26 Feb 07 |
jari |
499 |
FloatMatrix interactionFValuesMatrix = result.getMatrix("interactionFValuesMatrix"); |
2 |
26 Feb 07 |
jari |
500 |
|
2 |
26 Feb 07 |
jari |
501 |
FloatMatrix factorADfValuesMatrix = result.getMatrix("factorADfValuesMatrix"); |
2 |
26 Feb 07 |
jari |
502 |
FloatMatrix factorBDfValuesMatrix = result.getMatrix("factorBDfValuesMatrix"); |
2 |
26 Feb 07 |
jari |
503 |
FloatMatrix interactionDfValuesMatrix = result.getMatrix("interactionDfValuesMatrix"); |
2 |
26 Feb 07 |
jari |
504 |
FloatMatrix errorDfValuesMatrix = result.getMatrix("errorDfValuesMatrix"); |
2 |
26 Feb 07 |
jari |
505 |
|
2 |
26 Feb 07 |
jari |
506 |
FloatMatrix origFactorAPValuesMatrix = result.getMatrix("origFactorAPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
507 |
FloatMatrix origFactorBPValuesMatrix = result.getMatrix("origFactorBPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
508 |
FloatMatrix origInteractionPValuesMatrix = result.getMatrix("origInteractionPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
509 |
|
2 |
26 Feb 07 |
jari |
510 |
FloatMatrix adjFactorAPValuesMatrix = result.getMatrix("adjFactorAPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
511 |
FloatMatrix adjFactorBPValuesMatrix = result.getMatrix("adjFactorBPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
512 |
FloatMatrix adjInteractionPValuesMatrix = result.getMatrix("adjInteractionPValuesMatrix"); |
2 |
26 Feb 07 |
jari |
513 |
|
2 |
26 Feb 07 |
jari |
514 |
auxTitles = new String[13]; |
2 |
26 Feb 07 |
jari |
//auxTitles = {"Adj. p-values (" + factorNames[0] + ")", "Adj. p-values (" + factorNames[1] + ")", "Adj. p-values (interaction)", factorName[0] + " Orig. p-values", factorNames[0] + " F-ratio", factorNames[1] + "F-Ratio", "Interaction F-Ratio" }; |
2 |
26 Feb 07 |
jari |
516 |
auxTitles[0] = "Adj. p-values (" + factorNames[0] + ")"; |
2 |
26 Feb 07 |
jari |
517 |
auxTitles[1] = "Adj. p-values (" + factorNames[1] + ")"; |
2 |
26 Feb 07 |
jari |
518 |
auxTitles[2] = "Adj. p-values (interaction)"; |
2 |
26 Feb 07 |
jari |
519 |
auxTitles[3] = "Orig. p-values (" + factorNames[0] + ")"; |
2 |
26 Feb 07 |
jari |
520 |
auxTitles[4] = "Orig. p-values (" + factorNames[1] + ")"; |
2 |
26 Feb 07 |
jari |
521 |
auxTitles[5] = "Orig. p-values (interaction)"; |
2 |
26 Feb 07 |
jari |
522 |
auxTitles[6] = "F-ratio (" + factorNames[0] + ")"; |
2 |
26 Feb 07 |
jari |
523 |
auxTitles[7] = "F-ratio (" + factorNames[1] + ")"; |
2 |
26 Feb 07 |
jari |
524 |
auxTitles[8] = "F-ratio (interaction)"; |
2 |
26 Feb 07 |
jari |
525 |
auxTitles[9] = "df (" + factorNames[0] + ")"; |
2 |
26 Feb 07 |
jari |
526 |
auxTitles[10] = "df (" + factorNames[1] + ")"; |
2 |
26 Feb 07 |
jari |
527 |
auxTitles[11] = "df (interaction)"; |
2 |
26 Feb 07 |
jari |
528 |
auxTitles[12] = "df (error)"; |
2 |
26 Feb 07 |
jari |
529 |
|
2 |
26 Feb 07 |
jari |
530 |
auxData = new Object[factorAFValuesMatrix.A.length][13]; |
2 |
26 Feb 07 |
jari |
531 |
|
2 |
26 Feb 07 |
jari |
532 |
for (int i = 0; i < auxData.length; i++) { |
2 |
26 Feb 07 |
jari |
533 |
auxData[i][0] = new Float(adjFactorAPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
534 |
auxData[i][1] = new Float(adjFactorBPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
535 |
auxData[i][2] = new Float(adjInteractionPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
536 |
auxData[i][3] = new Float(origFactorAPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
537 |
auxData[i][4] = new Float(origFactorBPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
538 |
auxData[i][5] = new Float(origInteractionPValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
539 |
auxData[i][6] = new Float(factorAFValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
540 |
auxData[i][7] = new Float(factorBFValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
541 |
auxData[i][8] = new Float(interactionFValuesMatrix.A[i][0]); |
2 |
26 Feb 07 |
jari |
542 |
auxData[i][9] = new Integer((int)(factorADfValuesMatrix.A[i][0])); |
2 |
26 Feb 07 |
jari |
543 |
auxData[i][10] = new Integer((int)(factorBDfValuesMatrix.A[i][0])); |
2 |
26 Feb 07 |
jari |
544 |
auxData[i][11] = new Integer((int)(interactionDfValuesMatrix.A[i][0])); |
2 |
26 Feb 07 |
jari |
545 |
auxData[i][12] = new Integer((int)(errorDfValuesMatrix.A[i][0])); |
2 |
26 Feb 07 |
jari |
546 |
} |
2 |
26 Feb 07 |
jari |
547 |
|
2 |
26 Feb 07 |
jari |
548 |
AlgorithmParameters params = algData.getParams(); |
2 |
26 Feb 07 |
jari |
549 |
|
2 |
26 Feb 07 |
jari |
550 |
|
2 |
26 Feb 07 |
jari |
551 |
GeneralInfo info = new GeneralInfo(); |
2 |
26 Feb 07 |
jari |
552 |
info.time = time; |
2 |
26 Feb 07 |
jari |
//ADD MORE INFO PARAMETERS HERE |
2 |
26 Feb 07 |
jari |
554 |
info.alpha = params.getFloat("alpha"); |
2 |
26 Feb 07 |
jari |
555 |
info.adjMethod = this.getAdjMethod(params.getInt("adjustmentMethod")); |
2 |
26 Feb 07 |
jari |
556 |
info.pValueBasedOn = getPValueBasedOn(params.getBoolean("usePerms")); |
2 |
26 Feb 07 |
jari |
557 |
if (usePerms) { |
2 |
26 Feb 07 |
jari |
//info.useAllCombs = useAllCombs; |
2 |
26 Feb 07 |
jari |
559 |
info.numPerms = params.getInt("numPerms"); |
2 |
26 Feb 07 |
jari |
560 |
} |
2 |
26 Feb 07 |
jari |
561 |
int function = params.getInt("distance-function"); |
2 |
26 Feb 07 |
jari |
562 |
info.function = framework.getDistanceMenu().getFunctionName(function); |
2 |
26 Feb 07 |
jari |
563 |
info.hcl = params.getBoolean("hierarchical-tree"); |
2 |
26 Feb 07 |
jari |
564 |
info.hcl_genes = params.getBoolean("calculate-genes"); |
2 |
26 Feb 07 |
jari |
565 |
info.hcl_samples = params.getBoolean("calculate-experiments"); |
2 |
26 Feb 07 |
jari |
566 |
if(info.hcl) |
2 |
26 Feb 07 |
jari |
567 |
info.hcl_method = params.getInt("method-linkage"); |
2 |
26 Feb 07 |
jari |
568 |
return createResultTree(result_cluster, info); |
2 |
26 Feb 07 |
jari |
569 |
|
2 |
26 Feb 07 |
jari |
570 |
} finally { |
2 |
26 Feb 07 |
jari |
571 |
if (algorithm != null) { |
2 |
26 Feb 07 |
jari |
572 |
algorithm.removeAlgorithmListener(listener); |
2 |
26 Feb 07 |
jari |
573 |
} |
2 |
26 Feb 07 |
jari |
574 |
if (progress != null) { |
2 |
26 Feb 07 |
jari |
575 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
576 |
} |
2 |
26 Feb 07 |
jari |
577 |
} |
2 |
26 Feb 07 |
jari |
578 |
} |
2 |
26 Feb 07 |
jari |
579 |
|
2 |
26 Feb 07 |
jari |
580 |
|
2 |
26 Feb 07 |
jari |
581 |
private String getPValueBasedOn(boolean isPerm) { |
2 |
26 Feb 07 |
jari |
582 |
String str = ""; |
2 |
26 Feb 07 |
jari |
583 |
if (isPerm) { |
2 |
26 Feb 07 |
jari |
584 |
str = "permutation"; |
2 |
26 Feb 07 |
jari |
585 |
} else { |
2 |
26 Feb 07 |
jari |
586 |
str = "F-distribution"; |
2 |
26 Feb 07 |
jari |
587 |
} |
2 |
26 Feb 07 |
jari |
588 |
|
2 |
26 Feb 07 |
jari |
589 |
return str; |
2 |
26 Feb 07 |
jari |
590 |
} |
2 |
26 Feb 07 |
jari |
591 |
|
2 |
26 Feb 07 |
jari |
592 |
private String getAdjMethod(int adjMethod) { |
2 |
26 Feb 07 |
jari |
593 |
String methodName = ""; |
2 |
26 Feb 07 |
jari |
594 |
|
2 |
26 Feb 07 |
jari |
595 |
if (adjMethod == JUST_ALPHA) { |
2 |
26 Feb 07 |
jari |
596 |
methodName = "None"; |
2 |
26 Feb 07 |
jari |
597 |
} else if (adjMethod == STD_BONFERRONI) { |
2 |
26 Feb 07 |
jari |
598 |
methodName = "Standard Bonferroni correction"; |
2 |
26 Feb 07 |
jari |
599 |
} else if (adjMethod == ADJ_BONFERRONI) { |
2 |
26 Feb 07 |
jari |
600 |
methodName = "Adjusted Bonferroni correction"; |
2 |
26 Feb 07 |
jari |
601 |
} else if (adjMethod == MIN_P) { |
2 |
26 Feb 07 |
jari |
602 |
methodName = "Step-down Westfall Young: Min P"; |
2 |
26 Feb 07 |
jari |
603 |
} else if (adjMethod == MAX_T) { |
2 |
26 Feb 07 |
jari |
604 |
methodName = "Step-down Westfall Young: Max T"; |
2 |
26 Feb 07 |
jari |
605 |
} |
2 |
26 Feb 07 |
jari |
606 |
|
2 |
26 Feb 07 |
jari |
607 |
return methodName; |
2 |
26 Feb 07 |
jari |
608 |
} |
2 |
26 Feb 07 |
jari |
609 |
|
2 |
26 Feb 07 |
jari |
610 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a result tree to be inserted into the framework analysis node. |
2 |
26 Feb 07 |
jari |
612 |
*/ |
2 |
26 Feb 07 |
jari |
613 |
private DefaultMutableTreeNode createResultTree(Cluster result_cluster, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
614 |
DefaultMutableTreeNode root = new DefaultMutableTreeNode("Two-factor ANOVA"); |
2 |
26 Feb 07 |
jari |
615 |
addResultNodes(root, result_cluster, info); |
2 |
26 Feb 07 |
jari |
616 |
return root; |
2 |
26 Feb 07 |
jari |
617 |
} |
2 |
26 Feb 07 |
jari |
618 |
|
2 |
26 Feb 07 |
jari |
619 |
/** |
2 |
26 Feb 07 |
jari |
* Adds result nodes into the tree root. |
2 |
26 Feb 07 |
jari |
621 |
*/ |
2 |
26 Feb 07 |
jari |
622 |
private void addResultNodes(DefaultMutableTreeNode root, Cluster result_cluster, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
623 |
addExpressionImages(root); |
2 |
26 Feb 07 |
jari |
624 |
addHierarchicalTrees(root, result_cluster, info); |
2 |
26 Feb 07 |
jari |
625 |
addCentroidViews(root); |
2 |
26 Feb 07 |
jari |
626 |
addClusterInfo(root); |
2 |
26 Feb 07 |
jari |
627 |
addTableViews(root); |
2 |
26 Feb 07 |
jari |
628 |
addGeneralInfo(root, info); |
2 |
26 Feb 07 |
jari |
629 |
} |
2 |
26 Feb 07 |
jari |
630 |
|
2 |
26 Feb 07 |
jari |
631 |
/** |
2 |
26 Feb 07 |
jari |
* Adds nodes to display clusters data. |
2 |
26 Feb 07 |
jari |
633 |
*/ |
2 |
26 Feb 07 |
jari |
634 |
private void addExpressionImages(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
635 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Expression Images"); |
2 |
26 Feb 07 |
jari |
636 |
IViewer expViewer = new TFAExperimentViewer(this.experiment, this.clusters, auxTitles, auxData); |
2 |
26 Feb 07 |
jari |
637 |
for (int i=0; i<this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
638 |
node.add(new DefaultMutableTreeNode(new LeafInfo(clusterLabels[i], expViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
639 |
} |
2 |
26 Feb 07 |
jari |
640 |
root.add(node); |
2 |
26 Feb 07 |
jari |
641 |
} |
2 |
26 Feb 07 |
jari |
642 |
|
2 |
26 Feb 07 |
jari |
643 |
private void addTableViews(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
644 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Table views"); |
2 |
26 Feb 07 |
jari |
645 |
IViewer tableViewer = new ClusterTableViewer(this.experiment, this.clusters, data, auxTitles, auxData); |
2 |
26 Feb 07 |
jari |
//IViewer tableViewer = new ClusterTableViewer(this.experiment, this.clusters, data); |
2 |
26 Feb 07 |
jari |
647 |
for (int i=0; i<this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
648 |
node.add(new DefaultMutableTreeNode(new LeafInfo(clusterLabels[i], tableViewer, new Integer(i)))); |
2 |
26 Feb 07 |
jari |
649 |
} |
2 |
26 Feb 07 |
jari |
650 |
root.add(node); |
2 |
26 Feb 07 |
jari |
651 |
} |
2 |
26 Feb 07 |
jari |
652 |
|
2 |
26 Feb 07 |
jari |
653 |
/** |
2 |
26 Feb 07 |
jari |
* Adds nodes to display hierarchical trees. |
2 |
26 Feb 07 |
jari |
655 |
*/ |
2 |
26 Feb 07 |
jari |
656 |
private void addHierarchicalTrees(DefaultMutableTreeNode root, Cluster result_cluster, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
657 |
if (!info.hcl) { |
2 |
26 Feb 07 |
jari |
658 |
return; |
2 |
26 Feb 07 |
jari |
659 |
} |
2 |
26 Feb 07 |
jari |
660 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Hierarchical Trees"); |
2 |
26 Feb 07 |
jari |
661 |
NodeList nodeList = result_cluster.getNodeList(); |
2 |
26 Feb 07 |
jari |
662 |
|
2 |
26 Feb 07 |
jari |
663 |
if (!drawSigTreesOnly) { |
2 |
26 Feb 07 |
jari |
664 |
for (int i=0; i<nodeList.getSize(); i++) { |
2 |
26 Feb 07 |
jari |
665 |
node.add(new DefaultMutableTreeNode(new LeafInfo(clusterLabels[i], createHCLViewer(nodeList.getNode(i), info)))); |
2 |
26 Feb 07 |
jari |
666 |
} |
2 |
26 Feb 07 |
jari |
667 |
} else { |
2 |
26 Feb 07 |
jari |
668 |
for (int i=0; i<nodeList.getSize(); i++) { |
2 |
26 Feb 07 |
jari |
669 |
if (i <= 2) { |
2 |
26 Feb 07 |
jari |
670 |
node.add(new DefaultMutableTreeNode(new LeafInfo(clusterLabels[i], createHCLViewer(nodeList.getNode(i), info)))); |
2 |
26 Feb 07 |
jari |
671 |
} |
2 |
26 Feb 07 |
jari |
672 |
} |
2 |
26 Feb 07 |
jari |
673 |
} |
2 |
26 Feb 07 |
jari |
674 |
root.add(node); |
2 |
26 Feb 07 |
jari |
675 |
} |
2 |
26 Feb 07 |
jari |
676 |
|
2 |
26 Feb 07 |
jari |
677 |
/** |
2 |
26 Feb 07 |
jari |
* Creates an <code>HCLViewer</code>. |
2 |
26 Feb 07 |
jari |
679 |
*/ |
2 |
26 Feb 07 |
jari |
680 |
private IViewer createHCLViewer(Node clusterNode, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
681 |
HCLTreeData genes_result = info.hcl_genes ? getResult(clusterNode, 0) : null; |
2 |
26 Feb 07 |
jari |
682 |
HCLTreeData samples_result = info.hcl_samples ? getResult(clusterNode, info.hcl_genes ? 4 : 0) : null; |
2 |
26 Feb 07 |
jari |
683 |
return new HCLViewer(this.experiment, clusterNode.getFeaturesIndexes(), genes_result, samples_result); |
2 |
26 Feb 07 |
jari |
684 |
} |
2 |
26 Feb 07 |
jari |
685 |
|
2 |
26 Feb 07 |
jari |
686 |
/** |
2 |
26 Feb 07 |
jari |
* Adds nodes to display centroid charts. |
2 |
26 Feb 07 |
jari |
688 |
*/ |
2 |
26 Feb 07 |
jari |
689 |
private void addCentroidViews(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
690 |
DefaultMutableTreeNode centroidNode = new DefaultMutableTreeNode("Centroid Graphs"); |
2 |
26 Feb 07 |
jari |
691 |
DefaultMutableTreeNode expressionNode = new DefaultMutableTreeNode("Expression Graphs"); |
2 |
26 Feb 07 |
jari |
692 |
TFACentroidViewer centroidViewer = new TFACentroidViewer(this.experiment, clusters, auxTitles, auxData); |
2 |
26 Feb 07 |
jari |
693 |
centroidViewer.setMeans(this.means.A); |
2 |
26 Feb 07 |
jari |
694 |
centroidViewer.setVariances(this.variances.A); |
2 |
26 Feb 07 |
jari |
695 |
for (int i=0; i<this.clusters.length; i++) { |
2 |
26 Feb 07 |
jari |
696 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo(clusterLabels[i], centroidViewer, new CentroidUserObject(i, CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
697 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo(clusterLabels[i], centroidViewer, new CentroidUserObject(i, CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
698 |
} |
2 |
26 Feb 07 |
jari |
699 |
|
2 |
26 Feb 07 |
jari |
700 |
TFACentroidsViewer centroidsViewer = new TFACentroidsViewer(this.experiment, clusters, auxTitles, auxData); |
2 |
26 Feb 07 |
jari |
701 |
centroidsViewer.setMeans(this.means.A); |
2 |
26 Feb 07 |
jari |
702 |
centroidsViewer.setVariances(this.variances.A); |
2 |
26 Feb 07 |
jari |
703 |
|
2 |
26 Feb 07 |
jari |
704 |
centroidNode.add(new DefaultMutableTreeNode(new LeafInfo("All Genes", centroidsViewer, new Integer(CentroidUserObject.VARIANCES_MODE)))); |
2 |
26 Feb 07 |
jari |
705 |
expressionNode.add(new DefaultMutableTreeNode(new LeafInfo("All Genes", centroidsViewer, new Integer(CentroidUserObject.VALUES_MODE)))); |
2 |
26 Feb 07 |
jari |
706 |
|
2 |
26 Feb 07 |
jari |
707 |
root.add(centroidNode); |
2 |
26 Feb 07 |
jari |
708 |
root.add(expressionNode); |
2 |
26 Feb 07 |
jari |
709 |
} |
2 |
26 Feb 07 |
jari |
710 |
|
2 |
26 Feb 07 |
jari |
711 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a hcl tree data from the specified cluster node. |
2 |
26 Feb 07 |
jari |
713 |
*/ |
2 |
26 Feb 07 |
jari |
714 |
private HCLTreeData getResult(Node clusterNode, int pos) { |
2 |
26 Feb 07 |
jari |
715 |
HCLTreeData data = new HCLTreeData(); |
2 |
26 Feb 07 |
jari |
716 |
NodeValueList valueList = clusterNode.getValues(); |
2 |
26 Feb 07 |
jari |
717 |
data.child_1_array = (int[])valueList.getNodeValue(pos).value; |
2 |
26 Feb 07 |
jari |
718 |
data.child_2_array = (int[])valueList.getNodeValue(pos+1).value; |
2 |
26 Feb 07 |
jari |
719 |
data.node_order = (int[])valueList.getNodeValue(pos+2).value; |
2 |
26 Feb 07 |
jari |
720 |
data.height = (float[])valueList.getNodeValue(pos+3).value; |
2 |
26 Feb 07 |
jari |
721 |
return data; |
2 |
26 Feb 07 |
jari |
722 |
} |
2 |
26 Feb 07 |
jari |
723 |
|
2 |
26 Feb 07 |
jari |
724 |
/** |
2 |
26 Feb 07 |
jari |
* Adds node with cluster information. |
2 |
26 Feb 07 |
jari |
726 |
*/ |
2 |
26 Feb 07 |
jari |
727 |
private void addClusterInfo(DefaultMutableTreeNode root) { |
2 |
26 Feb 07 |
jari |
728 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("Cluster Information"); |
2 |
26 Feb 07 |
jari |
729 |
node.add(new DefaultMutableTreeNode(new LeafInfo("Results (#,%)", new TFAInfoViewer(this.clusters, this.experiment.getNumberOfGenes(), factorNames)))); |
2 |
26 Feb 07 |
jari |
730 |
root.add(node); |
2 |
26 Feb 07 |
jari |
731 |
} |
2 |
26 Feb 07 |
jari |
732 |
|
2 |
26 Feb 07 |
jari |
733 |
/** |
2 |
26 Feb 07 |
jari |
* Adds node with general iformation. |
2 |
26 Feb 07 |
jari |
735 |
*/ |
2 |
26 Feb 07 |
jari |
736 |
private void addGeneralInfo(DefaultMutableTreeNode root, GeneralInfo info) { |
2 |
26 Feb 07 |
jari |
737 |
DefaultMutableTreeNode node = new DefaultMutableTreeNode("General Information"); |
2 |
26 Feb 07 |
jari |
//node.add(new DefaultMutableTreeNode("Test design: " + info.getTestDesign())); |
2 |
26 Feb 07 |
jari |
739 |
node.add(getGroupAssignmentInfo()); |
2 |
26 Feb 07 |
jari |
740 |
|
2 |
26 Feb 07 |
jari |
741 |
node.add(new DefaultMutableTreeNode("Alpha (overall threshold p-value): "+info.alpha)); |
2 |
26 Feb 07 |
jari |
742 |
node.add(new DefaultMutableTreeNode("P-values based on: "+info.pValueBasedOn)); |
2 |
26 Feb 07 |
jari |
743 |
if (usePerms) { |
2 |
26 Feb 07 |
jari |
744 |
node.add(new DefaultMutableTreeNode("Number of permutations per gene: " + info.numPerms)); |
2 |
26 Feb 07 |
jari |
745 |
} |
2 |
26 Feb 07 |
jari |
746 |
node.add(new DefaultMutableTreeNode("P-value adjustment: "+info.adjMethod)); |
2 |
26 Feb 07 |
jari |
747 |
node.add(new DefaultMutableTreeNode("HCL: "+info.getMethodName())); |
2 |
26 Feb 07 |
jari |
748 |
node.add(new DefaultMutableTreeNode("Time: "+String.valueOf(info.time)+" ms")); |
2 |
26 Feb 07 |
jari |
749 |
node.add(new DefaultMutableTreeNode(info.function)); |
2 |
26 Feb 07 |
jari |
750 |
root.add(node); |
2 |
26 Feb 07 |
jari |
751 |
} |
2 |
26 Feb 07 |
jari |
752 |
|
2 |
26 Feb 07 |
jari |
753 |
private DefaultMutableTreeNode getGroupAssignmentInfo() { |
2 |
26 Feb 07 |
jari |
754 |
DefaultMutableTreeNode groupAssignmentInfo = new DefaultMutableTreeNode("Factor Assignments"); |
2 |
26 Feb 07 |
jari |
755 |
DefaultMutableTreeNode factorANode = new DefaultMutableTreeNode(factorNames[0]); |
2 |
26 Feb 07 |
jari |
756 |
DefaultMutableTreeNode factorBNode = new DefaultMutableTreeNode(factorNames[1]); |
2 |
26 Feb 07 |
jari |
757 |
for (int i = 0; i < exptNamesVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
758 |
if (factorAAssignments[i] != 0) { |
2 |
26 Feb 07 |
jari |
759 |
factorANode.add(new DefaultMutableTreeNode((String)(exptNamesVector.get(i)) + ": Group " + factorAAssignments[i])); |
2 |
26 Feb 07 |
jari |
760 |
} else { |
2 |
26 Feb 07 |
jari |
761 |
factorANode.add(new DefaultMutableTreeNode((String)(exptNamesVector.get(i)) + ": Unassigned")); |
2 |
26 Feb 07 |
jari |
762 |
} |
2 |
26 Feb 07 |
jari |
763 |
if (factorBAssignments[i] != 0) { |
2 |
26 Feb 07 |
jari |
764 |
factorBNode.add(new DefaultMutableTreeNode((String)(exptNamesVector.get(i)) + ": Group " + factorBAssignments[i])); |
2 |
26 Feb 07 |
jari |
765 |
} else { |
2 |
26 Feb 07 |
jari |
766 |
factorBNode.add(new DefaultMutableTreeNode((String)(exptNamesVector.get(i)) + ": Unassigned")); |
2 |
26 Feb 07 |
jari |
767 |
} |
2 |
26 Feb 07 |
jari |
768 |
} |
2 |
26 Feb 07 |
jari |
769 |
groupAssignmentInfo.add(factorANode); |
2 |
26 Feb 07 |
jari |
770 |
groupAssignmentInfo.add(factorBNode); |
2 |
26 Feb 07 |
jari |
771 |
|
2 |
26 Feb 07 |
jari |
772 |
return groupAssignmentInfo; |
2 |
26 Feb 07 |
jari |
773 |
} |
2 |
26 Feb 07 |
jari |
774 |
|
2 |
26 Feb 07 |
jari |
775 |
|
2 |
26 Feb 07 |
jari |
776 |
|
2 |
26 Feb 07 |
jari |
777 |
/** |
2 |
26 Feb 07 |
jari |
* The class to listen to progress, monitor and algorithms events. |
2 |
26 Feb 07 |
jari |
779 |
*/ |
2 |
26 Feb 07 |
jari |
780 |
private class Listener extends DialogListener implements AlgorithmListener { |
2 |
26 Feb 07 |
jari |
781 |
|
2 |
26 Feb 07 |
jari |
782 |
public void valueChanged(AlgorithmEvent event) { |
2 |
26 Feb 07 |
jari |
783 |
switch (event.getId()) { |
2 |
26 Feb 07 |
jari |
784 |
case AlgorithmEvent.SET_UNITS: |
2 |
26 Feb 07 |
jari |
785 |
progress.setUnits(event.getIntValue()); |
2 |
26 Feb 07 |
jari |
786 |
progress.setDescription(event.getDescription()); |
2 |
26 Feb 07 |
jari |
787 |
break; |
2 |
26 Feb 07 |
jari |
788 |
case AlgorithmEvent.PROGRESS_VALUE: |
2 |
26 Feb 07 |
jari |
789 |
progress.setValue(event.getIntValue()); |
2 |
26 Feb 07 |
jari |
790 |
progress.setDescription(event.getDescription()); |
2 |
26 Feb 07 |
jari |
791 |
break; |
2 |
26 Feb 07 |
jari |
792 |
case AlgorithmEvent.MONITOR_VALUE: |
2 |
26 Feb 07 |
jari |
793 |
int value = event.getIntValue(); |
2 |
26 Feb 07 |
jari |
794 |
if (value == -1) { |
2 |
26 Feb 07 |
jari |
//monitor.dispose(); |
2 |
26 Feb 07 |
jari |
796 |
} else { |
2 |
26 Feb 07 |
jari |
//monitor.update(value); |
2 |
26 Feb 07 |
jari |
798 |
} |
2 |
26 Feb 07 |
jari |
799 |
break; |
2 |
26 Feb 07 |
jari |
800 |
} |
2 |
26 Feb 07 |
jari |
801 |
} |
2 |
26 Feb 07 |
jari |
802 |
|
2 |
26 Feb 07 |
jari |
803 |
public void actionPerformed(ActionEvent e) { |
2 |
26 Feb 07 |
jari |
804 |
String command = e.getActionCommand(); |
2 |
26 Feb 07 |
jari |
805 |
if (command.equals("cancel-command")) { |
2 |
26 Feb 07 |
jari |
806 |
algorithm.abort(); |
2 |
26 Feb 07 |
jari |
807 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
//monitor.dispose(); |
2 |
26 Feb 07 |
jari |
809 |
} |
2 |
26 Feb 07 |
jari |
810 |
} |
2 |
26 Feb 07 |
jari |
811 |
|
2 |
26 Feb 07 |
jari |
812 |
public void windowClosing(WindowEvent e) { |
2 |
26 Feb 07 |
jari |
813 |
algorithm.abort(); |
2 |
26 Feb 07 |
jari |
814 |
progress.dispose(); |
2 |
26 Feb 07 |
jari |
//monitor.dispose(); |
2 |
26 Feb 07 |
jari |
816 |
} |
2 |
26 Feb 07 |
jari |
817 |
} |
2 |
26 Feb 07 |
jari |
818 |
|
2 |
26 Feb 07 |
jari |
819 |
private class GeneralInfo { |
2 |
26 Feb 07 |
jari |
820 |
public int clusters; |
2 |
26 Feb 07 |
jari |
821 |
public String adjMethod; |
2 |
26 Feb 07 |
jari |
822 |
public String pValueBasedOn; |
2 |
26 Feb 07 |
jari |
823 |
public float alpha; |
2 |
26 Feb 07 |
jari |
824 |
public int numPerms; |
2 |
26 Feb 07 |
jari |
825 |
public long time; |
2 |
26 Feb 07 |
jari |
826 |
public String function; |
2 |
26 Feb 07 |
jari |
827 |
|
2 |
26 Feb 07 |
jari |
828 |
private boolean hcl; |
2 |
26 Feb 07 |
jari |
829 |
private int hcl_method; |
2 |
26 Feb 07 |
jari |
830 |
private boolean hcl_genes; |
2 |
26 Feb 07 |
jari |
831 |
private boolean hcl_samples; |
2 |
26 Feb 07 |
jari |
832 |
|
2 |
26 Feb 07 |
jari |
833 |
public String getMethodName() { |
2 |
26 Feb 07 |
jari |
834 |
return hcl ? HCLGUI.GeneralInfo.getMethodName(hcl_method) : "no linkage"; |
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 |
} |