2 |
26 Feb 07 |
jari |
1 |
|
2 |
26 Feb 07 |
jari |
2 |
/* |
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 |
5 |
*/ |
2 |
26 Feb 07 |
jari |
6 |
/* |
2 |
26 Feb 07 |
jari |
* $RCSfile: Adjustment.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.7 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/02/24 16:52:41 $ |
2 |
26 Feb 07 |
jari |
* $Author: wwang67 $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
12 |
*/ |
2 |
26 Feb 07 |
jari |
13 |
package org.tigr.microarray.util; |
2 |
26 Feb 07 |
jari |
14 |
|
2 |
26 Feb 07 |
jari |
15 |
import java.util.ArrayList; |
2 |
26 Feb 07 |
jari |
16 |
import java.util.Arrays; |
2 |
26 Feb 07 |
jari |
17 |
import java.util.Collections; |
2 |
26 Feb 07 |
jari |
18 |
|
2 |
26 Feb 07 |
jari |
19 |
import org.tigr.util.FloatMatrix; |
2 |
26 Feb 07 |
jari |
20 |
|
2 |
26 Feb 07 |
jari |
21 |
|
2 |
26 Feb 07 |
jari |
22 |
public class Adjustment { |
2 |
26 Feb 07 |
jari |
23 |
|
2 |
26 Feb 07 |
jari |
24 |
public static void log2Transform(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
25 |
float value; |
2 |
26 Feb 07 |
jari |
26 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
27 |
for (int j=0; j<matrix.getColumnDimension(); j++) { |
2 |
26 Feb 07 |
jari |
28 |
value=matrix.get(i,j); |
2 |
26 Feb 07 |
jari |
29 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
30 |
if (value>0) { |
2 |
26 Feb 07 |
jari |
31 |
matrix.set(i,j,(float)(Math.log(value)/0.69314718)); |
2 |
26 Feb 07 |
jari |
32 |
} else { |
2 |
26 Feb 07 |
jari |
33 |
matrix.set(i,j,Float.NaN); |
2 |
26 Feb 07 |
jari |
34 |
} |
2 |
26 Feb 07 |
jari |
35 |
} |
2 |
26 Feb 07 |
jari |
36 |
} |
2 |
26 Feb 07 |
jari |
37 |
} |
2 |
26 Feb 07 |
jari |
38 |
} |
2 |
26 Feb 07 |
jari |
39 |
|
2 |
26 Feb 07 |
jari |
40 |
public static void unlog2Transform(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
41 |
float value; |
2 |
26 Feb 07 |
jari |
42 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
43 |
for (int j=0; j<matrix.getColumnDimension(); j++) { |
2 |
26 Feb 07 |
jari |
44 |
value=matrix.get(i,j); |
2 |
26 Feb 07 |
jari |
45 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
46 |
matrix.set(i,j,(float)(Math.pow(2,value))); |
2 |
26 Feb 07 |
jari |
47 |
} |
2 |
26 Feb 07 |
jari |
48 |
} |
2 |
26 Feb 07 |
jari |
49 |
} |
2 |
26 Feb 07 |
jari |
50 |
} |
2 |
26 Feb 07 |
jari |
51 |
public static void normalizeSpots(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
52 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
53 |
normalizeGene(matrix, i); |
2 |
26 Feb 07 |
jari |
54 |
} |
2 |
26 Feb 07 |
jari |
55 |
} |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
public static void divideSpotsRMS(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
58 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
59 |
divideGeneByRMS(matrix, i); |
2 |
26 Feb 07 |
jari |
60 |
} |
2 |
26 Feb 07 |
jari |
61 |
} |
2 |
26 Feb 07 |
jari |
62 |
|
2 |
26 Feb 07 |
jari |
// pcahan -- affy-abs specific adjustments |
2 |
26 Feb 07 |
jari |
64 |
public static void divideGenesMedian(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
65 |
float median = 0f; |
2 |
26 Feb 07 |
jari |
66 |
float value = 0f; |
2 |
26 Feb 07 |
jari |
67 |
int num_samples = matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
68 |
int num_genes = matrix.getRowDimension(); |
2 |
26 Feb 07 |
jari |
69 |
|
2 |
26 Feb 07 |
jari |
70 |
ArrayList row = new ArrayList(num_genes); |
2 |
26 Feb 07 |
jari |
// foreach gene |
2 |
26 Feb 07 |
jari |
72 |
for (int gene = 0; gene < num_genes; gene++) { |
2 |
26 Feb 07 |
jari |
73 |
median = 0f; |
2 |
26 Feb 07 |
jari |
74 |
|
2 |
26 Feb 07 |
jari |
// get median |
2 |
26 Feb 07 |
jari |
76 |
for (int sample = 0; sample < num_samples; sample++) { |
2 |
26 Feb 07 |
jari |
77 |
row.add(sample, new Float(matrix.get(gene,sample))); |
2 |
26 Feb 07 |
jari |
78 |
} |
2 |
26 Feb 07 |
jari |
79 |
|
2 |
26 Feb 07 |
jari |
80 |
median = getGeneMedian(row); |
2 |
26 Feb 07 |
jari |
81 |
|
2 |
26 Feb 07 |
jari |
// set value = signal/median |
2 |
26 Feb 07 |
jari |
83 |
for (int sample = 0; sample < num_samples; sample++) { |
2 |
26 Feb 07 |
jari |
84 |
value = matrix.get(gene, sample); |
2 |
26 Feb 07 |
jari |
85 |
|
2 |
26 Feb 07 |
jari |
86 |
matrix.set(gene, sample, (float) (value / median)); |
2 |
26 Feb 07 |
jari |
87 |
} |
2 |
26 Feb 07 |
jari |
88 |
row.clear(); |
2 |
26 Feb 07 |
jari |
89 |
} |
2 |
26 Feb 07 |
jari |
90 |
} |
2 |
26 Feb 07 |
jari |
91 |
|
2 |
26 Feb 07 |
jari |
92 |
public static void divideGenesMean(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
93 |
|
2 |
26 Feb 07 |
jari |
94 |
for (int g=0; g<matrix.getRowDimension(); g++) { |
2 |
26 Feb 07 |
jari |
95 |
double Mean = 0.0; |
2 |
26 Feb 07 |
jari |
96 |
int i; |
2 |
26 Feb 07 |
jari |
97 |
int n = matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
98 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
99 |
|
2 |
26 Feb 07 |
jari |
100 |
float value; |
2 |
26 Feb 07 |
jari |
101 |
for (i = 0; i < n; i++) { |
2 |
26 Feb 07 |
jari |
102 |
value = matrix.get(g, i); |
2 |
26 Feb 07 |
jari |
103 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
104 |
Mean += value; |
2 |
26 Feb 07 |
jari |
105 |
validN++; |
2 |
26 Feb 07 |
jari |
106 |
} |
2 |
26 Feb 07 |
jari |
107 |
} |
2 |
26 Feb 07 |
jari |
108 |
|
2 |
26 Feb 07 |
jari |
109 |
if(validN > 0) |
2 |
26 Feb 07 |
jari |
110 |
Mean /= (double)validN; |
2 |
26 Feb 07 |
jari |
111 |
|
2 |
26 Feb 07 |
jari |
112 |
for (i = 0; i < n; i++) { |
2 |
26 Feb 07 |
jari |
113 |
value = matrix.get(g, i); |
2 |
26 Feb 07 |
jari |
114 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
115 |
matrix.set(g, i, (float) (value / Mean)); |
2 |
26 Feb 07 |
jari |
116 |
} |
2 |
26 Feb 07 |
jari |
117 |
} |
2 |
26 Feb 07 |
jari |
118 |
} |
2 |
26 Feb 07 |
jari |
119 |
} |
2 |
26 Feb 07 |
jari |
120 |
|
2 |
26 Feb 07 |
jari |
121 |
|
2 |
26 Feb 07 |
jari |
122 |
public static void divideSpotsSD(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
123 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
124 |
divideGeneBySD(matrix, i); |
2 |
26 Feb 07 |
jari |
125 |
} |
2 |
26 Feb 07 |
jari |
126 |
} |
2 |
26 Feb 07 |
jari |
127 |
|
2 |
26 Feb 07 |
jari |
128 |
public static void meanCenterSpots(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
129 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
130 |
meanCenterGene(matrix, i); |
2 |
26 Feb 07 |
jari |
131 |
} |
2 |
26 Feb 07 |
jari |
132 |
} |
2 |
26 Feb 07 |
jari |
133 |
|
2 |
26 Feb 07 |
jari |
134 |
public static void medianCenterSpots(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
135 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
136 |
medianCenterGene(matrix, i); |
2 |
26 Feb 07 |
jari |
137 |
} |
2 |
26 Feb 07 |
jari |
138 |
} |
2 |
26 Feb 07 |
jari |
139 |
|
2 |
26 Feb 07 |
jari |
140 |
public static void digitalSpots(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
141 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
142 |
makeDigitalGene(matrix, i); |
2 |
26 Feb 07 |
jari |
143 |
} |
2 |
26 Feb 07 |
jari |
144 |
} |
2 |
26 Feb 07 |
jari |
145 |
|
2 |
26 Feb 07 |
jari |
146 |
public static void normalizeExperiments(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
147 |
for (int i=0; i<matrix.getColumnDimension(); i++) { |
2 |
26 Feb 07 |
jari |
148 |
normalizeExperiment(matrix, i); |
2 |
26 Feb 07 |
jari |
149 |
} |
2 |
26 Feb 07 |
jari |
150 |
} |
2 |
26 Feb 07 |
jari |
151 |
|
2 |
26 Feb 07 |
jari |
152 |
public static void divideExperimentsRMS(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
153 |
for (int i=0; i<matrix.getColumnDimension(); i++) { |
2 |
26 Feb 07 |
jari |
154 |
divideExperimentByRMS(matrix, i); |
2 |
26 Feb 07 |
jari |
155 |
} |
2 |
26 Feb 07 |
jari |
156 |
} |
2 |
26 Feb 07 |
jari |
157 |
|
2 |
26 Feb 07 |
jari |
158 |
public static void divideExperimentsSD(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
159 |
for (int i=0; i<matrix.getColumnDimension(); i++) { |
2 |
26 Feb 07 |
jari |
160 |
divideExperimentBySD(matrix, i); |
2 |
26 Feb 07 |
jari |
161 |
} |
2 |
26 Feb 07 |
jari |
162 |
} |
2 |
26 Feb 07 |
jari |
163 |
|
2 |
26 Feb 07 |
jari |
164 |
public static void meanCenterExperiments(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
165 |
for (int i=0; i<matrix.getColumnDimension(); i++) { |
2 |
26 Feb 07 |
jari |
166 |
meanCenterExperiment(matrix, i); |
2 |
26 Feb 07 |
jari |
167 |
} |
2 |
26 Feb 07 |
jari |
168 |
} |
2 |
26 Feb 07 |
jari |
169 |
|
2 |
26 Feb 07 |
jari |
170 |
public static void medianCenterExperiments(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
171 |
for (int i=0; i<matrix.getColumnDimension(); i++) { |
2 |
26 Feb 07 |
jari |
172 |
medianCenterExperiment(matrix, i); |
2 |
26 Feb 07 |
jari |
173 |
} |
2 |
26 Feb 07 |
jari |
174 |
} |
2 |
26 Feb 07 |
jari |
175 |
|
2 |
26 Feb 07 |
jari |
176 |
public static void digitalExperiments(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
177 |
for (int i=0; i<matrix.getColumnDimension(); i++) { |
2 |
26 Feb 07 |
jari |
178 |
makeDigitalExperiment(matrix, i); |
2 |
26 Feb 07 |
jari |
179 |
} |
2 |
26 Feb 07 |
jari |
180 |
} |
2 |
26 Feb 07 |
jari |
181 |
|
2 |
26 Feb 07 |
jari |
182 |
public static void log10toLog2(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
183 |
float value; |
2 |
26 Feb 07 |
jari |
184 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
185 |
for (int j=0; j<matrix.getColumnDimension(); j++) { |
2 |
26 Feb 07 |
jari |
186 |
value=matrix.get(i,j); |
2 |
26 Feb 07 |
jari |
187 |
if (!Float.isNaN(value)) matrix.set(i,j,(float)(value/0.301029995)); |
2 |
26 Feb 07 |
jari |
188 |
} |
2 |
26 Feb 07 |
jari |
189 |
} |
2 |
26 Feb 07 |
jari |
190 |
} |
2 |
26 Feb 07 |
jari |
191 |
public static void log2toLog10(FloatMatrix matrix) { |
2 |
26 Feb 07 |
jari |
192 |
float value; |
2 |
26 Feb 07 |
jari |
193 |
for (int i=0; i<matrix.getRowDimension(); i++) { |
2 |
26 Feb 07 |
jari |
194 |
for (int j=0; j<matrix.getColumnDimension(); j++) { |
2 |
26 Feb 07 |
jari |
195 |
value=matrix.get(i,j); |
2 |
26 Feb 07 |
jari |
196 |
if (!Float.isNaN(value)) matrix.set(i,j,(float)(value*0.301029995)); |
2 |
26 Feb 07 |
jari |
197 |
} |
2 |
26 Feb 07 |
jari |
198 |
} |
2 |
26 Feb 07 |
jari |
199 |
} |
2 |
26 Feb 07 |
jari |
200 |
private static void normalizeGene(FloatMatrix matrix, int GeneNumber) { |
2 |
26 Feb 07 |
jari |
201 |
double Mean=0.0; |
2 |
26 Feb 07 |
jari |
202 |
double StandardDeviation=0.0; |
2 |
26 Feb 07 |
jari |
203 |
int i; |
2 |
26 Feb 07 |
jari |
204 |
int n=matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
205 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
206 |
float value; |
2 |
26 Feb 07 |
jari |
207 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
208 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
209 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
210 |
Mean += value; |
2 |
26 Feb 07 |
jari |
211 |
validN++; |
2 |
26 Feb 07 |
jari |
212 |
} |
2 |
26 Feb 07 |
jari |
213 |
} |
2 |
26 Feb 07 |
jari |
214 |
|
2 |
26 Feb 07 |
jari |
215 |
if(validN > 0) |
2 |
26 Feb 07 |
jari |
216 |
Mean /= (double)validN; |
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
219 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
220 |
if (!Float.isNaN(value)) StandardDeviation+=Math.pow((value-Mean),2); |
2 |
26 Feb 07 |
jari |
221 |
} |
2 |
26 Feb 07 |
jari |
222 |
|
2 |
26 Feb 07 |
jari |
223 |
if(validN > 1) |
2 |
26 Feb 07 |
jari |
224 |
StandardDeviation=Math.sqrt(StandardDeviation/(double)(validN-1)); |
2 |
26 Feb 07 |
jari |
225 |
else |
2 |
26 Feb 07 |
jari |
226 |
StandardDeviation=0.0d; |
2 |
26 Feb 07 |
jari |
227 |
|
2 |
26 Feb 07 |
jari |
228 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
229 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
230 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
231 |
if (StandardDeviation!=0) { |
2 |
26 Feb 07 |
jari |
232 |
matrix.set(GeneNumber,i,(float)((value-Mean)/StandardDeviation)); |
2 |
26 Feb 07 |
jari |
233 |
} else { |
2 |
26 Feb 07 |
jari |
234 |
matrix.set(GeneNumber,i,(float)((value-Mean)/Float.MIN_VALUE)); |
2 |
26 Feb 07 |
jari |
235 |
} |
2 |
26 Feb 07 |
jari |
236 |
} |
2 |
26 Feb 07 |
jari |
237 |
} |
2 |
26 Feb 07 |
jari |
238 |
} |
2 |
26 Feb 07 |
jari |
239 |
|
2 |
26 Feb 07 |
jari |
240 |
|
2 |
26 Feb 07 |
jari |
241 |
private static void divideGeneByRMS(FloatMatrix matrix, int GeneNumber) { |
2 |
26 Feb 07 |
jari |
242 |
double Mean=0.0; |
2 |
26 Feb 07 |
jari |
243 |
double RMS=0.0; |
2 |
26 Feb 07 |
jari |
244 |
float value=0.0f; |
2 |
26 Feb 07 |
jari |
245 |
int i; |
2 |
26 Feb 07 |
jari |
246 |
int n=matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
247 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
248 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
249 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
250 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
251 |
RMS+=Math.pow((value),2); |
2 |
26 Feb 07 |
jari |
252 |
validN++; |
2 |
26 Feb 07 |
jari |
253 |
} |
2 |
26 Feb 07 |
jari |
254 |
} |
2 |
26 Feb 07 |
jari |
255 |
if(validN > 1) |
2 |
26 Feb 07 |
jari |
256 |
RMS=Math.sqrt(RMS/(double)(validN-1)); |
2 |
26 Feb 07 |
jari |
257 |
else if(validN == 0) |
2 |
26 Feb 07 |
jari |
258 |
RMS=Math.sqrt(RMS); |
2 |
26 Feb 07 |
jari |
259 |
else |
2 |
26 Feb 07 |
jari |
260 |
RMS=0.0d; |
2 |
26 Feb 07 |
jari |
261 |
|
2 |
26 Feb 07 |
jari |
262 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
263 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
264 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
265 |
if (RMS!=0) { |
2 |
26 Feb 07 |
jari |
266 |
matrix.set(GeneNumber,i,(float)((value)/RMS)); |
2 |
26 Feb 07 |
jari |
267 |
} else { |
2 |
26 Feb 07 |
jari |
268 |
matrix.set(GeneNumber,i,(float)((value)/Float.MIN_VALUE)); |
2 |
26 Feb 07 |
jari |
269 |
} |
2 |
26 Feb 07 |
jari |
270 |
} |
2 |
26 Feb 07 |
jari |
271 |
} |
2 |
26 Feb 07 |
jari |
272 |
} |
2 |
26 Feb 07 |
jari |
273 |
|
2 |
26 Feb 07 |
jari |
274 |
private static void divideGeneBySD(FloatMatrix matrix, int GeneNumber) { |
2 |
26 Feb 07 |
jari |
275 |
double Mean=0.0; |
2 |
26 Feb 07 |
jari |
276 |
double StandardDeviation=0.0; |
2 |
26 Feb 07 |
jari |
277 |
int i; |
2 |
26 Feb 07 |
jari |
278 |
int n=matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
279 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
280 |
float value; |
2 |
26 Feb 07 |
jari |
281 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
282 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
283 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
284 |
Mean += value; |
2 |
26 Feb 07 |
jari |
285 |
validN++; |
2 |
26 Feb 07 |
jari |
286 |
} |
2 |
26 Feb 07 |
jari |
287 |
} |
2 |
26 Feb 07 |
jari |
288 |
|
2 |
26 Feb 07 |
jari |
289 |
if(validN > 0) |
2 |
26 Feb 07 |
jari |
290 |
Mean /= (double)validN; |
2 |
26 Feb 07 |
jari |
291 |
|
2 |
26 Feb 07 |
jari |
292 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
293 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
294 |
if (!Float.isNaN(value)) StandardDeviation+=Math.pow((value-Mean),2); |
2 |
26 Feb 07 |
jari |
295 |
} |
2 |
26 Feb 07 |
jari |
296 |
|
2 |
26 Feb 07 |
jari |
297 |
if(validN > 1) |
2 |
26 Feb 07 |
jari |
298 |
StandardDeviation=Math.sqrt(StandardDeviation/(double)(validN-1)); |
2 |
26 Feb 07 |
jari |
299 |
else |
2 |
26 Feb 07 |
jari |
300 |
StandardDeviation=0.0d; |
2 |
26 Feb 07 |
jari |
301 |
|
2 |
26 Feb 07 |
jari |
302 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
303 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
304 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
305 |
if (StandardDeviation!=0) { |
2 |
26 Feb 07 |
jari |
306 |
matrix.set(GeneNumber,i,(float)((value)/StandardDeviation)); |
2 |
26 Feb 07 |
jari |
307 |
} else { |
2 |
26 Feb 07 |
jari |
308 |
matrix.set(GeneNumber,i,(float)((value)/Float.MIN_VALUE)); |
2 |
26 Feb 07 |
jari |
309 |
} |
2 |
26 Feb 07 |
jari |
310 |
} |
2 |
26 Feb 07 |
jari |
311 |
} |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
|
2 |
26 Feb 07 |
jari |
314 |
public static void meanCenterGene(FloatMatrix matrix, int GeneNumber) { |
2 |
26 Feb 07 |
jari |
315 |
double Mean=0.0; |
2 |
26 Feb 07 |
jari |
316 |
int i; |
2 |
26 Feb 07 |
jari |
317 |
int n=matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
318 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
319 |
float value; |
2 |
26 Feb 07 |
jari |
320 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
321 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
322 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
323 |
Mean += value; |
2 |
26 Feb 07 |
jari |
324 |
validN++; |
2 |
26 Feb 07 |
jari |
325 |
} |
2 |
26 Feb 07 |
jari |
326 |
} |
2 |
26 Feb 07 |
jari |
327 |
|
2 |
26 Feb 07 |
jari |
328 |
if(validN > 0) |
2 |
26 Feb 07 |
jari |
329 |
Mean /= (double)validN; |
2 |
26 Feb 07 |
jari |
330 |
|
2 |
26 Feb 07 |
jari |
331 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
332 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
333 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
334 |
matrix.set(GeneNumber,i,(float)(value-Mean)); |
2 |
26 Feb 07 |
jari |
335 |
} |
2 |
26 Feb 07 |
jari |
336 |
} |
2 |
26 Feb 07 |
jari |
337 |
} |
2 |
26 Feb 07 |
jari |
338 |
|
2 |
26 Feb 07 |
jari |
339 |
private static void medianCenterGene(FloatMatrix matrix, int GeneNumber) { |
2 |
26 Feb 07 |
jari |
340 |
int i; |
2 |
26 Feb 07 |
jari |
341 |
int n=matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
342 |
float value; |
2 |
26 Feb 07 |
jari |
343 |
int k=0; |
2 |
26 Feb 07 |
jari |
344 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
345 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
346 |
if (!Float.isNaN(value)) k++; |
2 |
26 Feb 07 |
jari |
347 |
} |
2 |
26 Feb 07 |
jari |
348 |
float[] DummyArray=new float [k]; |
2 |
26 Feb 07 |
jari |
349 |
k=0; |
2 |
26 Feb 07 |
jari |
350 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
351 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
352 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
353 |
DummyArray[k]=value; |
2 |
26 Feb 07 |
jari |
354 |
k++; |
2 |
26 Feb 07 |
jari |
355 |
} |
2 |
26 Feb 07 |
jari |
356 |
} |
2 |
26 Feb 07 |
jari |
357 |
Arrays.sort(DummyArray); |
2 |
26 Feb 07 |
jari |
358 |
float Median=0.0f; |
2 |
26 Feb 07 |
jari |
359 |
if (k%2==0) { |
2 |
26 Feb 07 |
jari |
360 |
if (k>0) Median=(float)(0.5*(DummyArray[k/2-1]+DummyArray[(k/2)])); |
2 |
26 Feb 07 |
jari |
361 |
} else { |
2 |
26 Feb 07 |
jari |
362 |
Median=DummyArray[(k+1)/2-1]; |
2 |
26 Feb 07 |
jari |
363 |
} |
2 |
26 Feb 07 |
jari |
364 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
365 |
value=matrix.get(GeneNumber,i); |
2 |
26 Feb 07 |
jari |
366 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
367 |
matrix.set(GeneNumber,i,(float)(value-Median)); |
2 |
26 Feb 07 |
jari |
368 |
} |
2 |
26 Feb 07 |
jari |
369 |
} |
2 |
26 Feb 07 |
jari |
370 |
} |
2 |
26 Feb 07 |
jari |
371 |
|
2 |
26 Feb 07 |
jari |
372 |
private static void makeDigitalGene(FloatMatrix matrix, int Gene) { |
2 |
26 Feb 07 |
jari |
373 |
int n=matrix.getColumnDimension(); |
2 |
26 Feb 07 |
jari |
374 |
int NumberOfBins=(int)Math.floor(Math.log(n)/Math.log(2)); |
2 |
26 Feb 07 |
jari |
375 |
int Step=1000000/NumberOfBins; |
2 |
26 Feb 07 |
jari |
376 |
float Minimum=Float.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
377 |
float Maximum=0; |
2 |
26 Feb 07 |
jari |
378 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
379 |
if (matrix.get(Gene,i)<Minimum) Minimum=matrix.get(Gene,i); |
2 |
26 Feb 07 |
jari |
380 |
} |
2 |
26 Feb 07 |
jari |
381 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
382 |
matrix.set(Gene,i,matrix.get(Gene,i)-Minimum); |
2 |
26 Feb 07 |
jari |
383 |
} |
2 |
26 Feb 07 |
jari |
384 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
385 |
if (matrix.get(Gene,i)>Maximum) Maximum=matrix.get(Gene,i); |
2 |
26 Feb 07 |
jari |
386 |
} |
2 |
26 Feb 07 |
jari |
387 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
388 |
matrix.set(Gene,i,matrix.get(Gene,i)/Maximum); |
2 |
26 Feb 07 |
jari |
389 |
} |
2 |
26 Feb 07 |
jari |
390 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
391 |
if (matrix.get(Gene,i)==1.0) { |
2 |
26 Feb 07 |
jari |
392 |
matrix.set(Gene,i,(float)NumberOfBins); |
2 |
26 Feb 07 |
jari |
393 |
} else { |
2 |
26 Feb 07 |
jari |
394 |
matrix.set(Gene,i,(float)(Math.floor(matrix.get(Gene,i)*1000000/Step)+1)); |
2 |
26 Feb 07 |
jari |
395 |
} |
2 |
26 Feb 07 |
jari |
396 |
} |
2 |
26 Feb 07 |
jari |
397 |
} |
2 |
26 Feb 07 |
jari |
398 |
|
2 |
26 Feb 07 |
jari |
399 |
private static void normalizeExperiment(FloatMatrix matrix, int ExperimentNumber) { |
2 |
26 Feb 07 |
jari |
400 |
double Mean=0.0; |
2 |
26 Feb 07 |
jari |
401 |
double StandardDeviation=0.0; |
2 |
26 Feb 07 |
jari |
402 |
int i; |
2 |
26 Feb 07 |
jari |
403 |
int n=matrix.getRowDimension(); |
2 |
26 Feb 07 |
jari |
404 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
405 |
float value; |
2 |
26 Feb 07 |
jari |
406 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
407 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
408 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
409 |
Mean += value; |
2 |
26 Feb 07 |
jari |
410 |
validN++; |
2 |
26 Feb 07 |
jari |
411 |
} |
2 |
26 Feb 07 |
jari |
412 |
} |
2 |
26 Feb 07 |
jari |
413 |
|
2 |
26 Feb 07 |
jari |
414 |
if(validN > 0) |
2 |
26 Feb 07 |
jari |
415 |
Mean /= (double)validN; |
2 |
26 Feb 07 |
jari |
416 |
|
2 |
26 Feb 07 |
jari |
417 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
418 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
419 |
if (!Float.isNaN(value)) StandardDeviation+=Math.pow((value-Mean),2); |
2 |
26 Feb 07 |
jari |
420 |
} |
2 |
26 Feb 07 |
jari |
421 |
|
2 |
26 Feb 07 |
jari |
422 |
if(validN > 1) |
2 |
26 Feb 07 |
jari |
423 |
StandardDeviation=Math.sqrt(StandardDeviation/(double)(validN-1)); |
2 |
26 Feb 07 |
jari |
424 |
else |
2 |
26 Feb 07 |
jari |
425 |
StandardDeviation=0.0d; |
2 |
26 Feb 07 |
jari |
426 |
|
2 |
26 Feb 07 |
jari |
427 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
428 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
429 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
430 |
if (StandardDeviation!=0) { |
2 |
26 Feb 07 |
jari |
431 |
matrix.set(i,ExperimentNumber,(float)((value-Mean)/StandardDeviation)); |
2 |
26 Feb 07 |
jari |
432 |
} else { |
2 |
26 Feb 07 |
jari |
433 |
matrix.set(i,ExperimentNumber,(float)((value-Mean)/Float.MIN_VALUE)); |
2 |
26 Feb 07 |
jari |
434 |
} |
2 |
26 Feb 07 |
jari |
435 |
} |
2 |
26 Feb 07 |
jari |
436 |
} |
2 |
26 Feb 07 |
jari |
437 |
} |
2 |
26 Feb 07 |
jari |
438 |
|
2 |
26 Feb 07 |
jari |
439 |
private static void divideExperimentBySD(FloatMatrix matrix, int ExperimentNumber) { |
2 |
26 Feb 07 |
jari |
440 |
double Mean=0.0; |
2 |
26 Feb 07 |
jari |
441 |
double StandardDeviation=0.0; |
2 |
26 Feb 07 |
jari |
442 |
int i; |
2 |
26 Feb 07 |
jari |
443 |
int n=matrix.getRowDimension(); |
2 |
26 Feb 07 |
jari |
444 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
445 |
float value; |
2 |
26 Feb 07 |
jari |
446 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
447 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
448 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
449 |
Mean += value; |
2 |
26 Feb 07 |
jari |
450 |
validN++; |
2 |
26 Feb 07 |
jari |
451 |
} |
2 |
26 Feb 07 |
jari |
452 |
} |
2 |
26 Feb 07 |
jari |
453 |
|
2 |
26 Feb 07 |
jari |
454 |
if(validN > 0) |
2 |
26 Feb 07 |
jari |
455 |
Mean /= (double)validN; |
2 |
26 Feb 07 |
jari |
456 |
|
2 |
26 Feb 07 |
jari |
457 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
458 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
459 |
if (!Float.isNaN(value)) StandardDeviation+=Math.pow((value-Mean),2); |
2 |
26 Feb 07 |
jari |
460 |
} |
2 |
26 Feb 07 |
jari |
461 |
|
2 |
26 Feb 07 |
jari |
462 |
if(validN > 1) |
2 |
26 Feb 07 |
jari |
463 |
StandardDeviation=Math.sqrt(StandardDeviation/(double)(validN-1)); |
2 |
26 Feb 07 |
jari |
464 |
else |
2 |
26 Feb 07 |
jari |
465 |
StandardDeviation=0.0d; |
2 |
26 Feb 07 |
jari |
466 |
|
2 |
26 Feb 07 |
jari |
467 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
468 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
469 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
470 |
if (StandardDeviation!=0) { |
2 |
26 Feb 07 |
jari |
471 |
matrix.set(i,ExperimentNumber,(float)((value)/StandardDeviation)); |
2 |
26 Feb 07 |
jari |
472 |
} else { |
2 |
26 Feb 07 |
jari |
473 |
matrix.set(i,ExperimentNumber,(float)((value)/Float.MIN_VALUE)); |
2 |
26 Feb 07 |
jari |
474 |
} |
2 |
26 Feb 07 |
jari |
475 |
} |
2 |
26 Feb 07 |
jari |
476 |
} |
2 |
26 Feb 07 |
jari |
477 |
} |
2 |
26 Feb 07 |
jari |
478 |
|
2 |
26 Feb 07 |
jari |
479 |
private static void divideExperimentByRMS(FloatMatrix matrix, int ExperimentNumber) { |
2 |
26 Feb 07 |
jari |
480 |
double Mean=0.0; |
2 |
26 Feb 07 |
jari |
481 |
double RMS=0.0; |
2 |
26 Feb 07 |
jari |
482 |
float value; |
2 |
26 Feb 07 |
jari |
483 |
int i; |
2 |
26 Feb 07 |
jari |
484 |
int n=matrix.getRowDimension(); |
2 |
26 Feb 07 |
jari |
485 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
486 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
487 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
488 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
489 |
RMS+=Math.pow(value,2); |
2 |
26 Feb 07 |
jari |
490 |
validN++; |
2 |
26 Feb 07 |
jari |
491 |
} |
2 |
26 Feb 07 |
jari |
492 |
} |
2 |
26 Feb 07 |
jari |
493 |
if(validN > 0) |
2 |
26 Feb 07 |
jari |
494 |
RMS=Math.sqrt(RMS/(double)(validN)); |
2 |
26 Feb 07 |
jari |
495 |
|
2 |
26 Feb 07 |
jari |
496 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
497 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
498 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
499 |
if (RMS!=0) { |
2 |
26 Feb 07 |
jari |
500 |
matrix.set(i,ExperimentNumber,(float)((value)/RMS)); |
2 |
26 Feb 07 |
jari |
501 |
} else { |
2 |
26 Feb 07 |
jari |
502 |
matrix.set(i,ExperimentNumber,(float)((value)/Float.MIN_VALUE)); |
2 |
26 Feb 07 |
jari |
503 |
} |
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 |
private static void meanCenterExperiment(FloatMatrix matrix, int ExperimentNumber) { |
2 |
26 Feb 07 |
jari |
509 |
double Mean=0.0; |
2 |
26 Feb 07 |
jari |
510 |
int i; |
2 |
26 Feb 07 |
jari |
511 |
int n=matrix.getRowDimension(); |
2 |
26 Feb 07 |
jari |
512 |
int validN = 0; |
2 |
26 Feb 07 |
jari |
513 |
float value; |
2 |
26 Feb 07 |
jari |
514 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
515 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
516 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
517 |
Mean += value; |
2 |
26 Feb 07 |
jari |
518 |
validN++; |
2 |
26 Feb 07 |
jari |
519 |
} |
2 |
26 Feb 07 |
jari |
520 |
} |
2 |
26 Feb 07 |
jari |
521 |
|
2 |
26 Feb 07 |
jari |
522 |
if(validN > 0) |
2 |
26 Feb 07 |
jari |
523 |
Mean /= (double)validN; |
2 |
26 Feb 07 |
jari |
524 |
|
2 |
26 Feb 07 |
jari |
525 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
526 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
527 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
528 |
matrix.set(i,ExperimentNumber,(float)(value-Mean)); |
2 |
26 Feb 07 |
jari |
529 |
} |
2 |
26 Feb 07 |
jari |
530 |
} |
2 |
26 Feb 07 |
jari |
531 |
} |
2 |
26 Feb 07 |
jari |
532 |
|
2 |
26 Feb 07 |
jari |
533 |
private static void medianCenterExperiment(FloatMatrix matrix, int ExperimentNumber) { |
2 |
26 Feb 07 |
jari |
534 |
int i; |
2 |
26 Feb 07 |
jari |
535 |
int n=matrix.getRowDimension(); |
2 |
26 Feb 07 |
jari |
536 |
float value; |
2 |
26 Feb 07 |
jari |
537 |
int k=0; |
2 |
26 Feb 07 |
jari |
538 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
539 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
540 |
if (!Float.isNaN(value)) k++; |
2 |
26 Feb 07 |
jari |
541 |
} |
2 |
26 Feb 07 |
jari |
542 |
float[] DummyArray=new float [k]; |
2 |
26 Feb 07 |
jari |
543 |
k=0; |
2 |
26 Feb 07 |
jari |
544 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
545 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
546 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
547 |
DummyArray[k]=value; |
2 |
26 Feb 07 |
jari |
548 |
k++; |
2 |
26 Feb 07 |
jari |
549 |
} |
2 |
26 Feb 07 |
jari |
550 |
} |
2 |
26 Feb 07 |
jari |
551 |
Arrays.sort(DummyArray); |
2 |
26 Feb 07 |
jari |
552 |
float Median=0.0f; |
2 |
26 Feb 07 |
jari |
553 |
if (k%2==0) { |
2 |
26 Feb 07 |
jari |
554 |
if (k>0) Median=(float)(0.5*(DummyArray[k/2-1]+DummyArray[(k/2)])); |
2 |
26 Feb 07 |
jari |
555 |
} else { |
2 |
26 Feb 07 |
jari |
556 |
Median=DummyArray[(k+1)/2-1]; |
2 |
26 Feb 07 |
jari |
557 |
} |
2 |
26 Feb 07 |
jari |
558 |
for (i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
559 |
value=matrix.get(i,ExperimentNumber); |
2 |
26 Feb 07 |
jari |
560 |
if (!Float.isNaN(value)) { |
2 |
26 Feb 07 |
jari |
561 |
matrix.set(i,ExperimentNumber,(float)(value-Median)); |
2 |
26 Feb 07 |
jari |
562 |
} |
2 |
26 Feb 07 |
jari |
563 |
} |
2 |
26 Feb 07 |
jari |
564 |
} |
2 |
26 Feb 07 |
jari |
565 |
|
2 |
26 Feb 07 |
jari |
566 |
private static void makeDigitalExperiment(FloatMatrix matrix, int Experiment) { |
2 |
26 Feb 07 |
jari |
567 |
int n=matrix.getRowDimension(); |
2 |
26 Feb 07 |
jari |
568 |
int NumberOfBins=(int)Math.floor(Math.log(n)/Math.log(2)); |
2 |
26 Feb 07 |
jari |
569 |
int Step=1000000/NumberOfBins; |
2 |
26 Feb 07 |
jari |
570 |
float Minimum=Float.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
571 |
float Maximum=0; |
2 |
26 Feb 07 |
jari |
572 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
573 |
if (matrix.get(i,Experiment)<Minimum) Minimum=matrix.get(i,Experiment); |
2 |
26 Feb 07 |
jari |
574 |
} |
2 |
26 Feb 07 |
jari |
575 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
576 |
matrix.set(i,Experiment,matrix.get(i,Experiment)-Minimum); |
2 |
26 Feb 07 |
jari |
577 |
} |
2 |
26 Feb 07 |
jari |
578 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
579 |
if (matrix.get(i,Experiment)>Maximum) Maximum=matrix.get(i,Experiment); |
2 |
26 Feb 07 |
jari |
580 |
} |
2 |
26 Feb 07 |
jari |
581 |
if (Maximum!=0) { |
2 |
26 Feb 07 |
jari |
582 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
583 |
matrix.set(i,Experiment,matrix.get(i,Experiment)/Maximum); |
2 |
26 Feb 07 |
jari |
584 |
} |
2 |
26 Feb 07 |
jari |
585 |
} |
2 |
26 Feb 07 |
jari |
586 |
for (int i=0; i<n; i++) { |
2 |
26 Feb 07 |
jari |
587 |
if (matrix.get(i,Experiment)==1.0) { |
2 |
26 Feb 07 |
jari |
588 |
matrix.set(i,Experiment,(float)NumberOfBins); |
2 |
26 Feb 07 |
jari |
589 |
} else { |
2 |
26 Feb 07 |
jari |
590 |
matrix.set(i,Experiment,(float)(Math.floor(matrix.get(i,Experiment)*1000000/Step)+1)); |
2 |
26 Feb 07 |
jari |
591 |
} |
2 |
26 Feb 07 |
jari |
592 |
} |
2 |
26 Feb 07 |
jari |
593 |
} |
2 |
26 Feb 07 |
jari |
594 |
|
2 |
26 Feb 07 |
jari |
// pcahan |
2 |
26 Feb 07 |
jari |
596 |
public static float getGeneMedian( ArrayList float_array ) { |
2 |
26 Feb 07 |
jari |
597 |
|
2 |
26 Feb 07 |
jari |
598 |
Collections.sort(float_array); |
2 |
26 Feb 07 |
jari |
599 |
|
2 |
26 Feb 07 |
jari |
600 |
Float median; |
2 |
26 Feb 07 |
jari |
601 |
|
2 |
26 Feb 07 |
jari |
602 |
if (float_array.size() == 1){ |
2 |
26 Feb 07 |
jari |
603 |
return ( (Float) float_array.get(0)).floatValue(); |
2 |
26 Feb 07 |
jari |
604 |
} |
2 |
26 Feb 07 |
jari |
605 |
|
2 |
26 Feb 07 |
jari |
606 |
int center = float_array.size() / 2; |
2 |
26 Feb 07 |
jari |
607 |
|
2 |
26 Feb 07 |
jari |
608 |
if (float_array.size() % 2 == 0) { |
2 |
26 Feb 07 |
jari |
609 |
Float a, b; |
2 |
26 Feb 07 |
jari |
610 |
a = (Float) float_array.get(center); |
2 |
26 Feb 07 |
jari |
611 |
b = (Float) float_array.get(center - 1); |
2 |
26 Feb 07 |
jari |
612 |
median = new Float(( a.floatValue() + b.floatValue() )/2); |
2 |
26 Feb 07 |
jari |
613 |
} |
2 |
26 Feb 07 |
jari |
614 |
else { |
2 |
26 Feb 07 |
jari |
615 |
median = (Float)float_array.get( center ); |
2 |
26 Feb 07 |
jari |
616 |
} |
2 |
26 Feb 07 |
jari |
617 |
return median.floatValue(); |
2 |
26 Feb 07 |
jari |
618 |
} |
2 |
26 Feb 07 |
jari |
619 |
} |
2 |
26 Feb 07 |
jari |
620 |
|