2 |
26 Feb 07 |
jari |
1 |
/* |
2 |
26 Feb 07 |
jari |
Copyright @ 1999-2003, 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 |
* $RCSfile: SlideData.java,v $ |
2 |
26 Feb 07 |
jari |
* $Revision: 1.17 $ |
2 |
26 Feb 07 |
jari |
* $Date: 2006/05/02 16:56:56 $ |
2 |
26 Feb 07 |
jari |
* $Author: eleanorahowe $ |
2 |
26 Feb 07 |
jari |
* $State: Exp $ |
2 |
26 Feb 07 |
jari |
11 |
*/ |
2 |
26 Feb 07 |
jari |
12 |
package org.tigr.microarray.mev; |
2 |
26 Feb 07 |
jari |
13 |
|
2 |
26 Feb 07 |
jari |
14 |
import java.util.Hashtable; |
2 |
26 Feb 07 |
jari |
15 |
import java.util.Properties; |
2 |
26 Feb 07 |
jari |
16 |
import java.util.Vector; |
2 |
26 Feb 07 |
jari |
17 |
|
2 |
26 Feb 07 |
jari |
18 |
import org.tigr.microarray.mev.cluster.gui.IData; |
2 |
26 Feb 07 |
jari |
19 |
import org.tigr.midas.engine.IterativeLinReg; |
2 |
26 Feb 07 |
jari |
20 |
import org.tigr.midas.engine.IterativeLogMean; |
2 |
26 Feb 07 |
jari |
21 |
import org.tigr.midas.engine.RatioStats; |
2 |
26 Feb 07 |
jari |
22 |
import org.tigr.midas.engine.TotInt; |
2 |
26 Feb 07 |
jari |
23 |
import org.tigr.midas.util.ColumnWorker; |
2 |
26 Feb 07 |
jari |
24 |
import org.tigr.util.Xcon; |
2 |
26 Feb 07 |
jari |
25 |
import org.tigr.util.math.LinearEquation; |
2 |
26 Feb 07 |
jari |
26 |
|
2 |
26 Feb 07 |
jari |
//EH state-saving additions |
2 |
26 Feb 07 |
jari |
28 |
import org.tigr.microarray.mev.persistence.StateSavingProgressPanel; |
2 |
26 Feb 07 |
jari |
29 |
import javax.swing.JFrame; |
2 |
26 Feb 07 |
jari |
30 |
import java.io.DataInputStream; |
2 |
26 Feb 07 |
jari |
31 |
import java.io.DataOutputStream; |
2 |
26 Feb 07 |
jari |
32 |
import java.io.File; |
2 |
26 Feb 07 |
jari |
33 |
import java.io.FileInputStream; |
2 |
26 Feb 07 |
jari |
34 |
import java.io.FileNotFoundException; |
2 |
26 Feb 07 |
jari |
35 |
import java.io.IOException; |
2 |
26 Feb 07 |
jari |
36 |
|
2 |
26 Feb 07 |
jari |
37 |
|
2 |
26 Feb 07 |
jari |
38 |
public class SlideData implements ISlideData, ISlideMetaData { |
2 |
26 Feb 07 |
jari |
//EH |
2 |
26 Feb 07 |
jari |
40 |
private Vector allSlideDataElements; |
2 |
26 Feb 07 |
jari |
41 |
private String slideDataName; |
2 |
26 Feb 07 |
jari |
42 |
private String slideFileName; |
2 |
26 Feb 07 |
jari |
43 |
private SpotInformationData spotInfoData; |
2 |
26 Feb 07 |
jari |
44 |
private int normalizedState = 0; |
2 |
26 Feb 07 |
jari |
45 |
private int sortState = 0; |
2 |
26 Feb 07 |
jari |
46 |
private int rows, columns; |
2 |
26 Feb 07 |
jari |
47 |
private boolean isNonZero = true; |
2 |
26 Feb 07 |
jari |
48 |
private boolean abbrName = false; |
2 |
26 Feb 07 |
jari |
49 |
private int dataType = IData.DATA_TYPE_TWO_INTENSITY; |
2 |
26 Feb 07 |
jari |
50 |
private String[] fieldNames; //EH added so fieldNames are no longer in TMEV.java |
2 |
26 Feb 07 |
jari |
51 |
|
2 |
26 Feb 07 |
jari |
//Support multiple sample labels |
2 |
26 Feb 07 |
jari |
53 |
private String sampleLabelKey = "Default Slide Name"; |
2 |
26 Feb 07 |
jari |
54 |
private Hashtable sampleLabels; |
2 |
26 Feb 07 |
jari |
55 |
private Vector sampleLabelKeys; |
2 |
26 Feb 07 |
jari |
56 |
|
2 |
26 Feb 07 |
jari |
57 |
|
2 |
26 Feb 07 |
jari |
58 |
/** |
2 |
26 Feb 07 |
jari |
* Raktim Oct 31, 2005 |
2 |
26 Feb 07 |
jari |
* CGH FlankingRegions, and Slide Constants |
2 |
26 Feb 07 |
jari |
* Vector of vectors of FlankingRegions corresponding to flanking regions |
2 |
26 Feb 07 |
jari |
* for each chromosome |
2 |
26 Feb 07 |
jari |
63 |
*/ |
2 |
26 Feb 07 |
jari |
64 |
private Vector[] flankingRegions; |
2 |
26 Feb 07 |
jari |
65 |
|
2 |
26 Feb 07 |
jari |
66 |
public boolean isCGHData(){return allSlideDataElements.get(0) instanceof CGHSlideDataElement;} |
2 |
26 Feb 07 |
jari |
67 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>SlideData</code> which is a copy of specified original. |
2 |
26 Feb 07 |
jari |
69 |
*/ |
2 |
26 Feb 07 |
jari |
70 |
public SlideData(ISlideData original) { |
2 |
26 Feb 07 |
jari |
71 |
super(); |
2 |
26 Feb 07 |
jari |
72 |
this.rows = original.getSlideMetaData().getRows(); |
2 |
26 Feb 07 |
jari |
73 |
this.columns = original.getSlideMetaData().getColumns(); |
2 |
26 Feb 07 |
jari |
74 |
this.sortState = original.getSortState(); |
2 |
26 Feb 07 |
jari |
75 |
this.normalizedState = original.getNormalizedState(); |
2 |
26 Feb 07 |
jari |
76 |
this.slideDataName = original.getSlideDataName(); |
2 |
26 Feb 07 |
jari |
77 |
|
2 |
26 Feb 07 |
jari |
78 |
for (int i = 0; i < original.getSize(); i++) { |
2 |
26 Feb 07 |
jari |
79 |
addElement(original.getSlideDataElement(i).copy()); |
2 |
26 Feb 07 |
jari |
80 |
} |
2 |
26 Feb 07 |
jari |
81 |
sampleLabelKey = "Default Slide Name"; |
2 |
26 Feb 07 |
jari |
82 |
sampleLabelKeys = original.getSlideDataKeys(); |
2 |
26 Feb 07 |
jari |
83 |
sampleLabels = original.getSlideDataLabels(); |
2 |
26 Feb 07 |
jari |
84 |
if(this.fieldNames == null) |
2 |
26 Feb 07 |
jari |
85 |
this.fieldNames = new String[0]; |
2 |
26 Feb 07 |
jari |
86 |
} |
2 |
26 Feb 07 |
jari |
87 |
|
2 |
26 Feb 07 |
jari |
88 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>SlideData</code> with specified dimension. |
2 |
26 Feb 07 |
jari |
90 |
*/ |
2 |
26 Feb 07 |
jari |
91 |
public SlideData(int rows, int columns) { |
2 |
26 Feb 07 |
jari |
92 |
allSlideDataElements = new Vector(rows * columns); |
2 |
26 Feb 07 |
jari |
93 |
this.rows = rows; |
2 |
26 Feb 07 |
jari |
94 |
this.columns = columns; |
2 |
26 Feb 07 |
jari |
95 |
sampleLabelKey = "Default Slide Name"; |
2 |
26 Feb 07 |
jari |
96 |
sampleLabelKeys = new Vector(); |
2 |
26 Feb 07 |
jari |
97 |
sampleLabels = new Hashtable(); |
2 |
26 Feb 07 |
jari |
98 |
if(this.fieldNames == null) |
2 |
26 Feb 07 |
jari |
99 |
this.fieldNames = new String[0]; |
2 |
26 Feb 07 |
jari |
100 |
} |
2 |
26 Feb 07 |
jari |
101 |
|
2 |
26 Feb 07 |
jari |
102 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>SlideData</code> with specified size. |
2 |
26 Feb 07 |
jari |
104 |
*/ |
2 |
26 Feb 07 |
jari |
105 |
public SlideData(int size) { |
2 |
26 Feb 07 |
jari |
106 |
allSlideDataElements = new Vector(size); |
2 |
26 Feb 07 |
jari |
107 |
rows = -1; |
2 |
26 Feb 07 |
jari |
108 |
columns = -1; |
2 |
26 Feb 07 |
jari |
109 |
sampleLabelKey = "Default Slide Name"; |
2 |
26 Feb 07 |
jari |
110 |
sampleLabelKeys = new Vector(); |
2 |
26 Feb 07 |
jari |
111 |
sampleLabels = new Hashtable(); |
2 |
26 Feb 07 |
jari |
112 |
if(this.fieldNames == null) |
2 |
26 Feb 07 |
jari |
113 |
this.fieldNames = new String[0]; |
2 |
26 Feb 07 |
jari |
114 |
} |
2 |
26 Feb 07 |
jari |
115 |
|
2 |
26 Feb 07 |
jari |
116 |
/** |
2 |
26 Feb 07 |
jari |
* Constructs a <code>SlideData</code> instance. |
2 |
26 Feb 07 |
jari |
118 |
*/ |
2 |
26 Feb 07 |
jari |
119 |
public SlideData() { |
2 |
26 Feb 07 |
jari |
120 |
allSlideDataElements = new Vector(); |
2 |
26 Feb 07 |
jari |
121 |
if(this.fieldNames == null) |
2 |
26 Feb 07 |
jari |
122 |
this.fieldNames = new String[0]; |
2 |
26 Feb 07 |
jari |
123 |
} |
2 |
26 Feb 07 |
jari |
124 |
|
2 |
26 Feb 07 |
jari |
125 |
// |
2 |
26 Feb 07 |
jari |
//EH begin classes added for state-saving update |
2 |
26 Feb 07 |
jari |
127 |
// |
2 |
26 Feb 07 |
jari |
128 |
/** |
2 |
26 Feb 07 |
jari |
* This constructor is designed to re-create a previously built SlideData |
2 |
26 Feb 07 |
jari |
* from parameters stored in an XML file (this file is written by the MultipleArrayViewer.saveState() method). |
2 |
26 Feb 07 |
jari |
* The String[] returned by the method FloatSlideData.getPersistenceDelegateArgs() |
2 |
26 Feb 07 |
jari |
* should reflect the names and order of the values passed to this constructor. |
2 |
26 Feb 07 |
jari |
133 |
* |
2 |
26 Feb 07 |
jari |
134 |
*/ |
2 |
26 Feb 07 |
jari |
135 |
public SlideData(String slideDataName, Vector sampleLabelKeys, String sampleLabelKey, |
2 |
26 Feb 07 |
jari |
136 |
Hashtable sampleLabels, String slideFileName, Boolean isNonZero, Integer rows, Integer columns, |
2 |
26 Feb 07 |
jari |
137 |
Integer normalizedState, Integer sortState, SpotInformationData spotInfoData, |
2 |
26 Feb 07 |
jari |
138 |
String[] fieldNames, Integer dataType/*, String annotationFileName, String inputFileName*/) throws IOException { |
2 |
26 Feb 07 |
jari |
139 |
this(); |
2 |
26 Feb 07 |
jari |
140 |
this.rows = rows.intValue(); |
2 |
26 Feb 07 |
jari |
141 |
this.columns = columns.intValue(); |
2 |
26 Feb 07 |
jari |
142 |
this.slideDataName = slideDataName; |
2 |
26 Feb 07 |
jari |
143 |
this.sampleLabelKeys = sampleLabelKeys; |
2 |
26 Feb 07 |
jari |
144 |
this.sampleLabelKey = sampleLabelKey; |
2 |
26 Feb 07 |
jari |
145 |
this.sampleLabels = sampleLabels; |
2 |
26 Feb 07 |
jari |
146 |
this.slideFileName = slideFileName; |
2 |
26 Feb 07 |
jari |
147 |
this.normalizedState = normalizedState.intValue(); |
2 |
26 Feb 07 |
jari |
148 |
this.sortState = sortState.intValue(); |
2 |
26 Feb 07 |
jari |
149 |
this.spotInfoData = spotInfoData; |
2 |
26 Feb 07 |
jari |
150 |
this.isNonZero = isNonZero.booleanValue(); |
2 |
26 Feb 07 |
jari |
151 |
this.fieldNames = fieldNames; |
2 |
26 Feb 07 |
jari |
152 |
this.dataType = dataType.intValue(); |
2 |
26 Feb 07 |
jari |
//loadAnnotation(new DataInputStream(new FileInputStream(System.getProperty("java.io.tmpdir") + MultipleArrayViewer.CURRENT_TEMP_DIR + System.getProperty("file.separator") + annotationFileName))); |
2 |
26 Feb 07 |
jari |
//readDataFromInputFile(inputFileName); |
2 |
26 Feb 07 |
jari |
155 |
} |
2 |
26 Feb 07 |
jari |
156 |
|
2 |
26 Feb 07 |
jari |
157 |
|
2 |
26 Feb 07 |
jari |
158 |
|
2 |
26 Feb 07 |
jari |
159 |
public String getSampleLabelKey() {return sampleLabelKey;} |
2 |
26 Feb 07 |
jari |
160 |
|
2 |
26 Feb 07 |
jari |
161 |
|
2 |
26 Feb 07 |
jari |
162 |
public Vector getAllElements() { |
2 |
26 Feb 07 |
jari |
163 |
return allSlideDataElements; |
2 |
26 Feb 07 |
jari |
164 |
} |
2 |
26 Feb 07 |
jari |
165 |
|
2 |
26 Feb 07 |
jari |
166 |
public void setAllElements(Vector v){ |
2 |
26 Feb 07 |
jari |
167 |
this.allSlideDataElements = v; |
2 |
26 Feb 07 |
jari |
168 |
} |
2 |
26 Feb 07 |
jari |
169 |
public void add(SlideDataElement newElement) { |
2 |
26 Feb 07 |
jari |
170 |
this.allSlideDataElements.add(newElement); |
2 |
26 Feb 07 |
jari |
171 |
} |
2 |
26 Feb 07 |
jari |
172 |
|
2 |
26 Feb 07 |
jari |
173 |
public int size() { |
2 |
26 Feb 07 |
jari |
174 |
return allSlideDataElements.size(); |
2 |
26 Feb 07 |
jari |
175 |
} |
2 |
26 Feb 07 |
jari |
176 |
public Object elementAt(int i){ |
2 |
26 Feb 07 |
jari |
177 |
return allSlideDataElements.elementAt(i); |
2 |
26 Feb 07 |
jari |
178 |
} |
2 |
26 Feb 07 |
jari |
179 |
public void addElement(Object o){ |
2 |
26 Feb 07 |
jari |
180 |
allSlideDataElements.addElement(o); |
2 |
26 Feb 07 |
jari |
181 |
} |
2 |
26 Feb 07 |
jari |
182 |
public void add(Object o){ |
2 |
26 Feb 07 |
jari |
183 |
allSlideDataElements.add(o); |
2 |
26 Feb 07 |
jari |
184 |
} |
2 |
26 Feb 07 |
jari |
185 |
public Object set(int index, Object element){ |
2 |
26 Feb 07 |
jari |
186 |
return allSlideDataElements.set(index, element); |
2 |
26 Feb 07 |
jari |
187 |
} |
2 |
26 Feb 07 |
jari |
188 |
public void setElementAt(Object element, int index){ |
2 |
26 Feb 07 |
jari |
189 |
allSlideDataElements.setElementAt(element, index); |
2 |
26 Feb 07 |
jari |
190 |
} |
2 |
26 Feb 07 |
jari |
191 |
public void insertElementAt(Object o, int i){ |
2 |
26 Feb 07 |
jari |
192 |
allSlideDataElements.insertElementAt(o, i); |
2 |
26 Feb 07 |
jari |
193 |
} |
2 |
26 Feb 07 |
jari |
194 |
// |
2 |
26 Feb 07 |
jari |
// EH - end methods added for state-saving update |
2 |
26 Feb 07 |
jari |
196 |
// |
2 |
26 Feb 07 |
jari |
// begin methods brought in from TMEV.java |
2 |
26 Feb 07 |
jari |
198 |
public void setFieldNames(String [] fieldNames){ |
2 |
26 Feb 07 |
jari |
199 |
this.fieldNames = fieldNames; |
2 |
26 Feb 07 |
jari |
200 |
} |
2 |
26 Feb 07 |
jari |
201 |
public void appendFieldNames(String [] fieldNames){ |
2 |
26 Feb 07 |
jari |
202 |
if(this.fieldNames == null || fieldNames == null) //trying to set to null or initial set |
2 |
26 Feb 07 |
jari |
203 |
this.fieldNames = fieldNames; |
2 |
26 Feb 07 |
jari |
204 |
else { //names exist and new names exist, APPEND (ie. mev format, extra ann load) |
2 |
26 Feb 07 |
jari |
205 |
String [] newNames = new String[this.fieldNames.length+fieldNames.length]; |
2 |
26 Feb 07 |
jari |
206 |
System.arraycopy(this.fieldNames, 0, newNames, 0, this.fieldNames.length); |
2 |
26 Feb 07 |
jari |
207 |
System.arraycopy(fieldNames, 0, newNames, this.fieldNames.length, fieldNames.length); |
2 |
26 Feb 07 |
jari |
208 |
this.fieldNames = newNames; |
2 |
26 Feb 07 |
jari |
209 |
} |
2 |
26 Feb 07 |
jari |
210 |
} |
2 |
26 Feb 07 |
jari |
211 |
public void clearFieldNames(){ |
2 |
26 Feb 07 |
jari |
212 |
this.fieldNames = null; |
2 |
26 Feb 07 |
jari |
213 |
} |
2 |
26 Feb 07 |
jari |
// end methods brought in from TMEV |
2 |
26 Feb 07 |
jari |
215 |
|
2 |
26 Feb 07 |
jari |
216 |
|
2 |
26 Feb 07 |
jari |
217 |
|
2 |
26 Feb 07 |
jari |
218 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the data type attribute see static type variables in <code>IData</code> |
2 |
26 Feb 07 |
jari |
220 |
*/ |
2 |
26 Feb 07 |
jari |
221 |
public void setDataType(int type){ |
2 |
26 Feb 07 |
jari |
222 |
this.dataType = type; |
2 |
26 Feb 07 |
jari |
223 |
} |
2 |
26 Feb 07 |
jari |
224 |
|
2 |
26 Feb 07 |
jari |
225 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the data type attribute |
2 |
26 Feb 07 |
jari |
227 |
*/ |
2 |
26 Feb 07 |
jari |
228 |
public int getDataType(){ |
2 |
26 Feb 07 |
jari |
229 |
return this.dataType; |
2 |
26 Feb 07 |
jari |
230 |
} |
2 |
26 Feb 07 |
jari |
231 |
|
2 |
26 Feb 07 |
jari |
232 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the spot information data and associated column headers. |
2 |
26 Feb 07 |
jari |
234 |
*/ |
2 |
26 Feb 07 |
jari |
235 |
public void setSpotInformationData(String [] columnHeaders, String [][] spotInfoData){ |
2 |
26 Feb 07 |
jari |
236 |
this.spotInfoData = new SpotInformationData(columnHeaders, spotInfoData); |
2 |
26 Feb 07 |
jari |
237 |
} |
2 |
26 Feb 07 |
jari |
238 |
|
2 |
26 Feb 07 |
jari |
239 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the spot information data and associated column headers. |
2 |
26 Feb 07 |
jari |
241 |
*/ |
2 |
26 Feb 07 |
jari |
242 |
public void setSpotInformationData(SpotInformationData spotInfoData){ |
2 |
26 Feb 07 |
jari |
243 |
this.spotInfoData = spotInfoData; |
2 |
26 Feb 07 |
jari |
244 |
} |
2 |
26 Feb 07 |
jari |
245 |
|
2 |
26 Feb 07 |
jari |
246 |
public String[] getFieldNames() { |
2 |
26 Feb 07 |
jari |
247 |
return fieldNames; |
2 |
26 Feb 07 |
jari |
248 |
} |
2 |
26 Feb 07 |
jari |
249 |
|
2 |
26 Feb 07 |
jari |
250 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the <code>SpotInformationData</code> object. |
2 |
26 Feb 07 |
jari |
252 |
*/ |
2 |
26 Feb 07 |
jari |
253 |
public SpotInformationData getSpotInformationData(){ |
2 |
26 Feb 07 |
jari |
254 |
return this.spotInfoData; |
2 |
26 Feb 07 |
jari |
255 |
} |
2 |
26 Feb 07 |
jari |
256 |
|
2 |
26 Feb 07 |
jari |
257 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an <code>ISlideDataElement</code> by specified index. |
2 |
26 Feb 07 |
jari |
259 |
*/ |
2 |
26 Feb 07 |
jari |
260 |
public ISlideDataElement getSlideDataElement(int index) { |
2 |
26 Feb 07 |
jari |
261 |
return(ISlideDataElement)elementAt(index); |
2 |
26 Feb 07 |
jari |
262 |
} |
2 |
26 Feb 07 |
jari |
263 |
|
2 |
26 Feb 07 |
jari |
264 |
/** |
2 |
26 Feb 07 |
jari |
* Returns non-zero attribute of an element with specified index. |
2 |
26 Feb 07 |
jari |
266 |
*/ |
2 |
26 Feb 07 |
jari |
267 |
public boolean hasNoZeros(int index) { |
2 |
26 Feb 07 |
jari |
268 |
ISlideDataElement sde = (ISlideDataElement)elementAt(index); |
2 |
26 Feb 07 |
jari |
269 |
return sde.hasNoZeros(); |
2 |
26 Feb 07 |
jari |
270 |
} |
2 |
26 Feb 07 |
jari |
271 |
|
2 |
26 Feb 07 |
jari |
272 |
/** |
2 |
26 Feb 07 |
jari |
* Returns copy of an element with specified index. |
2 |
26 Feb 07 |
jari |
274 |
*/ |
2 |
26 Feb 07 |
jari |
275 |
public ISlideDataElement toSlideDataElement(int index) { |
2 |
26 Feb 07 |
jari |
276 |
return((ISlideDataElement)elementAt(index)).copy(); |
2 |
26 Feb 07 |
jari |
277 |
} |
2 |
26 Feb 07 |
jari |
278 |
|
2 |
26 Feb 07 |
jari |
279 |
/** |
2 |
26 Feb 07 |
jari |
* Returns CY3 value for specified index. |
2 |
26 Feb 07 |
jari |
281 |
*/ |
2 |
26 Feb 07 |
jari |
282 |
public float getCY3(int index) { |
2 |
26 Feb 07 |
jari |
283 |
ISlideDataElement sde = (ISlideDataElement)elementAt(index); |
2 |
26 Feb 07 |
jari |
284 |
if(normalizedState == ISlideData.NO_NORMALIZATION) |
2 |
26 Feb 07 |
jari |
285 |
return sde.getTrueIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
286 |
else |
2 |
26 Feb 07 |
jari |
287 |
return sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
288 |
} |
2 |
26 Feb 07 |
jari |
289 |
|
2 |
26 Feb 07 |
jari |
290 |
/** |
2 |
26 Feb 07 |
jari |
* Returns CY5 value for specified index. |
2 |
26 Feb 07 |
jari |
292 |
*/ |
2 |
26 Feb 07 |
jari |
293 |
public float getCY5(int index) { |
2 |
26 Feb 07 |
jari |
294 |
ISlideDataElement sde = (ISlideDataElement)elementAt(index); |
2 |
26 Feb 07 |
jari |
295 |
if(normalizedState == ISlideData.NO_NORMALIZATION){ |
2 |
26 Feb 07 |
jari |
// System.out.println("making experiment, no norm"); |
2 |
26 Feb 07 |
jari |
297 |
return sde.getTrueIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
298 |
} |
2 |
26 Feb 07 |
jari |
299 |
else{ |
2 |
26 Feb 07 |
jari |
// System.out.println("making experiment, NORM!!"); |
2 |
26 Feb 07 |
jari |
301 |
return sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
302 |
} |
2 |
26 Feb 07 |
jari |
303 |
} |
2 |
26 Feb 07 |
jari |
304 |
|
2 |
26 Feb 07 |
jari |
305 |
/** |
2 |
26 Feb 07 |
jari |
* Sets intensities for a spot with specified index. |
2 |
26 Feb 07 |
jari |
307 |
*/ |
2 |
26 Feb 07 |
jari |
308 |
public void setIntensities(int index, float cy3, float cy5) { |
2 |
26 Feb 07 |
jari |
309 |
ISlideDataElement sde = (ISlideDataElement)elementAt(index); |
2 |
26 Feb 07 |
jari |
310 |
sde.setTrueIntensity(ISlideDataElement.CY3, cy3); |
2 |
26 Feb 07 |
jari |
311 |
sde.setTrueIntensity(ISlideDataElement.CY5, cy5); |
2 |
26 Feb 07 |
jari |
312 |
} |
2 |
26 Feb 07 |
jari |
313 |
|
2 |
26 Feb 07 |
jari |
314 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a ratio value with specified index and log state. |
2 |
26 Feb 07 |
jari |
316 |
*/ |
2 |
26 Feb 07 |
jari |
317 |
public float getRatio(int index, int logState) { |
2 |
26 Feb 07 |
jari |
318 |
return getRatio(getCY5(index), getCY3(index), logState); |
2 |
26 Feb 07 |
jari |
319 |
} |
2 |
26 Feb 07 |
jari |
320 |
|
2 |
26 Feb 07 |
jari |
321 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a ratio of specified values. |
2 |
26 Feb 07 |
jari |
323 |
*/ |
2 |
26 Feb 07 |
jari |
324 |
public final float getRatio(float numerator, float denominator, int logState) { |
2 |
26 Feb 07 |
jari |
325 |
|
2 |
26 Feb 07 |
jari |
326 |
if(dataType == IData.DATA_TYPE_RATIO_ONLY) |
2 |
26 Feb 07 |
jari |
327 |
return numerator; |
2 |
26 Feb 07 |
jari |
328 |
|
2 |
26 Feb 07 |
jari |
329 |
float ratio; |
2 |
26 Feb 07 |
jari |
330 |
if(denominator < 0 || numerator < 0) |
2 |
26 Feb 07 |
jari |
331 |
return Float.NaN; |
2 |
26 Feb 07 |
jari |
332 |
if (isNonZero) { |
2 |
26 Feb 07 |
jari |
333 |
if (denominator == 0 && numerator == 0) { |
2 |
26 Feb 07 |
jari |
334 |
return Float.NaN; |
2 |
26 Feb 07 |
jari |
335 |
} else if (numerator == 0) { |
2 |
26 Feb 07 |
jari |
336 |
ratio = 1f/denominator; |
2 |
26 Feb 07 |
jari |
337 |
} else if (denominator == 0) { |
2 |
26 Feb 07 |
jari |
338 |
ratio = numerator; |
2 |
26 Feb 07 |
jari |
339 |
} else { |
2 |
26 Feb 07 |
jari |
340 |
ratio = numerator/denominator; |
2 |
26 Feb 07 |
jari |
341 |
} |
2 |
26 Feb 07 |
jari |
342 |
} else { |
2 |
26 Feb 07 |
jari |
343 |
if (denominator <= 0) |
2 |
26 Feb 07 |
jari |
344 |
return Float.NaN; |
2 |
26 Feb 07 |
jari |
345 |
if (numerator <= 0) |
2 |
26 Feb 07 |
jari |
346 |
return Float.NaN; |
2 |
26 Feb 07 |
jari |
347 |
ratio = numerator/denominator; |
2 |
26 Feb 07 |
jari |
348 |
} |
2 |
26 Feb 07 |
jari |
349 |
if (logState == IData.LOG) |
2 |
26 Feb 07 |
jari |
350 |
ratio = (float)(Math.log(ratio)/Math.log(2.0)); |
2 |
26 Feb 07 |
jari |
351 |
return ratio; |
2 |
26 Feb 07 |
jari |
352 |
} |
2 |
26 Feb 07 |
jari |
353 |
|
2 |
26 Feb 07 |
jari |
354 |
/** |
2 |
26 Feb 07 |
jari |
* Returns reference to a microarray meta data. |
2 |
26 Feb 07 |
jari |
356 |
*/ |
2 |
26 Feb 07 |
jari |
357 |
public ISlideMetaData getSlideMetaData() { |
2 |
26 Feb 07 |
jari |
358 |
return this; |
2 |
26 Feb 07 |
jari |
359 |
} |
2 |
26 Feb 07 |
jari |
360 |
|
2 |
26 Feb 07 |
jari |
361 |
/** |
2 |
26 Feb 07 |
jari |
* Adds an <code>ISlideDataElement</code> to a microarray. |
2 |
26 Feb 07 |
jari |
363 |
*/ |
2 |
26 Feb 07 |
jari |
364 |
public void addSlideDataElement(ISlideDataElement element) { |
2 |
26 Feb 07 |
jari |
365 |
addElement(element); |
2 |
26 Feb 07 |
jari |
366 |
} |
2 |
26 Feb 07 |
jari |
367 |
|
2 |
26 Feb 07 |
jari |
368 |
/** |
2 |
26 Feb 07 |
jari |
* Returns an element value of specified type. |
2 |
26 Feb 07 |
jari |
370 |
*/ |
2 |
26 Feb 07 |
jari |
371 |
public String getValueAt(int index, int valueType) { |
2 |
26 Feb 07 |
jari |
372 |
ISlideDataElement sde = (ISlideDataElement)elementAt(index); |
2 |
26 Feb 07 |
jari |
373 |
return sde.getFieldAt(valueType); |
2 |
26 Feb 07 |
jari |
374 |
} |
2 |
26 Feb 07 |
jari |
375 |
|
2 |
26 Feb 07 |
jari |
376 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray size. |
2 |
26 Feb 07 |
jari |
378 |
*/ |
2 |
26 Feb 07 |
jari |
379 |
public int getSize() { |
2 |
26 Feb 07 |
jari |
380 |
return size(); |
2 |
26 Feb 07 |
jari |
381 |
} |
2 |
26 Feb 07 |
jari |
382 |
|
2 |
26 Feb 07 |
jari |
383 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a microarray non-zero attribute. |
2 |
26 Feb 07 |
jari |
385 |
*/ |
2 |
26 Feb 07 |
jari |
386 |
public void setNonZero(boolean state) { |
2 |
26 Feb 07 |
jari |
387 |
this.isNonZero = state; |
2 |
26 Feb 07 |
jari |
388 |
} |
2 |
26 Feb 07 |
jari |
389 |
|
2 |
26 Feb 07 |
jari |
390 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a spot meta row. |
2 |
26 Feb 07 |
jari |
392 |
*/ |
2 |
26 Feb 07 |
jari |
393 |
public int getRow(int spot) { |
2 |
26 Feb 07 |
jari |
394 |
return getSlideDataElement(spot).getRow(SlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
395 |
} |
2 |
26 Feb 07 |
jari |
396 |
|
2 |
26 Feb 07 |
jari |
397 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a spot meta column. |
2 |
26 Feb 07 |
jari |
399 |
*/ |
2 |
26 Feb 07 |
jari |
400 |
public int getColumn(int spot) { |
2 |
26 Feb 07 |
jari |
401 |
return getSlideDataElement(spot).getColumn(SlideDataElement.BASE); |
2 |
26 Feb 07 |
jari |
402 |
} |
2 |
26 Feb 07 |
jari |
403 |
|
2 |
26 Feb 07 |
jari |
404 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the non-zero attribute. |
2 |
26 Feb 07 |
jari |
406 |
*/ |
2 |
26 Feb 07 |
jari |
407 |
public boolean isNonZero() {return isNonZero;} |
2 |
26 Feb 07 |
jari |
408 |
|
2 |
26 Feb 07 |
jari |
409 |
/** |
2 |
26 Feb 07 |
jari |
* Returns number of a microarray meta rows. |
2 |
26 Feb 07 |
jari |
411 |
*/ |
2 |
26 Feb 07 |
jari |
412 |
public int getRows() {return this.rows;} |
2 |
26 Feb 07 |
jari |
413 |
|
2 |
26 Feb 07 |
jari |
414 |
/** |
2 |
26 Feb 07 |
jari |
* Returns number of a microarray meta column. |
2 |
26 Feb 07 |
jari |
416 |
*/ |
2 |
26 Feb 07 |
jari |
417 |
public int getColumns() {return this.columns;} |
2 |
26 Feb 07 |
jari |
418 |
|
2 |
26 Feb 07 |
jari |
419 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a microarray name. |
2 |
26 Feb 07 |
jari |
421 |
*/ |
2 |
26 Feb 07 |
jari |
422 |
public void setSlideDataName(String slideDataName) { |
2 |
26 Feb 07 |
jari |
423 |
this.slideDataName = slideDataName; |
2 |
26 Feb 07 |
jari |
424 |
String key = "Default Slide Name"; |
2 |
26 Feb 07 |
jari |
425 |
sampleLabelKey = key; |
2 |
26 Feb 07 |
jari |
426 |
sampleLabelKeys.addElement(key); |
2 |
26 Feb 07 |
jari |
427 |
sampleLabels.put(key, slideDataName); |
2 |
26 Feb 07 |
jari |
428 |
} |
2 |
26 Feb 07 |
jari |
429 |
|
2 |
26 Feb 07 |
jari |
430 |
|
2 |
26 Feb 07 |
jari |
431 |
/** |
2 |
26 Feb 07 |
jari |
* Sets the slide label keys and hash table |
2 |
26 Feb 07 |
jari |
433 |
*/ |
2 |
26 Feb 07 |
jari |
434 |
public void setSlideDataLabels(Vector keys, Hashtable namesHash) { |
2 |
26 Feb 07 |
jari |
435 |
this.sampleLabelKeys = keys; |
2 |
26 Feb 07 |
jari |
436 |
this.sampleLabels = namesHash; |
2 |
26 Feb 07 |
jari |
437 |
} |
2 |
26 Feb 07 |
jari |
438 |
|
2 |
26 Feb 07 |
jari |
439 |
|
2 |
26 Feb 07 |
jari |
440 |
/** |
2 |
26 Feb 07 |
jari |
* sets boolean to indicate to abbr file and data name |
2 |
26 Feb 07 |
jari |
442 |
*/ |
2 |
26 Feb 07 |
jari |
443 |
public void toggleNameLength(){ |
2 |
26 Feb 07 |
jari |
444 |
this.abbrName = (!this.abbrName); |
2 |
26 Feb 07 |
jari |
445 |
} |
2 |
26 Feb 07 |
jari |
446 |
|
2 |
26 Feb 07 |
jari |
447 |
|
2 |
26 Feb 07 |
jari |
448 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the name of a microarray. |
2 |
26 Feb 07 |
jari |
450 |
*/ |
2 |
26 Feb 07 |
jari |
451 |
public String getSlideDataName() { |
2 |
26 Feb 07 |
jari |
452 |
if(sampleLabelKey == null) |
2 |
26 Feb 07 |
jari |
453 |
System.out.println("NULL SAMPLE LABEL KEY"); |
2 |
26 Feb 07 |
jari |
454 |
String name = (String)this.sampleLabels.get(this.sampleLabelKey); |
2 |
26 Feb 07 |
jari |
455 |
|
2 |
26 Feb 07 |
jari |
456 |
if(name == null) |
2 |
26 Feb 07 |
jari |
457 |
return " "; |
2 |
26 Feb 07 |
jari |
458 |
|
2 |
26 Feb 07 |
jari |
459 |
if(!this.abbrName) |
2 |
26 Feb 07 |
jari |
460 |
return name; |
2 |
26 Feb 07 |
jari |
461 |
else{ |
2 |
26 Feb 07 |
jari |
462 |
if(name.length() < 26) |
2 |
26 Feb 07 |
jari |
463 |
return name; |
2 |
26 Feb 07 |
jari |
464 |
return name.substring(0, 25)+"..."; |
2 |
26 Feb 07 |
jari |
465 |
} |
2 |
26 Feb 07 |
jari |
466 |
} |
2 |
26 Feb 07 |
jari |
467 |
|
2 |
26 Feb 07 |
jari |
468 |
public String getFullSlideDataName() { |
2 |
26 Feb 07 |
jari |
469 |
String name = (String)this.sampleLabels.get(this.sampleLabelKey); |
2 |
26 Feb 07 |
jari |
470 |
if(name == null) |
2 |
26 Feb 07 |
jari |
471 |
return " "; |
2 |
26 Feb 07 |
jari |
472 |
else |
2 |
26 Feb 07 |
jari |
473 |
return name; |
2 |
26 Feb 07 |
jari |
474 |
} |
2 |
26 Feb 07 |
jari |
475 |
|
2 |
26 Feb 07 |
jari |
476 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a microarray file name. |
2 |
26 Feb 07 |
jari |
478 |
*/ |
2 |
26 Feb 07 |
jari |
479 |
public void setSlideFileName(String slideFileName) {this.slideFileName = slideFileName;} |
2 |
26 Feb 07 |
jari |
480 |
|
2 |
26 Feb 07 |
jari |
481 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray file name. |
2 |
26 Feb 07 |
jari |
483 |
*/ |
2 |
26 Feb 07 |
jari |
484 |
public String getSlideFileName() { |
2 |
26 Feb 07 |
jari |
485 |
if(!this.abbrName) |
2 |
26 Feb 07 |
jari |
486 |
return this.slideFileName; |
2 |
26 Feb 07 |
jari |
487 |
else{ |
2 |
26 Feb 07 |
jari |
488 |
if(this.slideFileName.length() < 26) |
2 |
26 Feb 07 |
jari |
489 |
return this.slideFileName; |
2 |
26 Feb 07 |
jari |
490 |
return this.slideFileName.substring(0, 25)+"..."; |
2 |
26 Feb 07 |
jari |
491 |
} |
2 |
26 Feb 07 |
jari |
492 |
} |
2 |
26 Feb 07 |
jari |
493 |
|
2 |
26 Feb 07 |
jari |
494 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a microarray normalization state. |
2 |
26 Feb 07 |
jari |
496 |
*/ |
2 |
26 Feb 07 |
jari |
497 |
public void setNormalizedState(int normalizedState) {this.normalizedState = normalizedState;} |
2 |
26 Feb 07 |
jari |
498 |
|
2 |
26 Feb 07 |
jari |
499 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray normalization state. |
2 |
26 Feb 07 |
jari |
501 |
*/ |
2 |
26 Feb 07 |
jari |
502 |
public int getNormalizedState() {return this.normalizedState;} |
2 |
26 Feb 07 |
jari |
503 |
|
2 |
26 Feb 07 |
jari |
504 |
/** |
2 |
26 Feb 07 |
jari |
* Sets a microarray sort state. |
2 |
26 Feb 07 |
jari |
506 |
*/ |
2 |
26 Feb 07 |
jari |
507 |
public void setSortState(int sortState) {this.sortState = sortState;} |
2 |
26 Feb 07 |
jari |
508 |
|
2 |
26 Feb 07 |
jari |
509 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray sort state. |
2 |
26 Feb 07 |
jari |
511 |
*/ |
2 |
26 Feb 07 |
jari |
512 |
public int getSortState() {return this.sortState;} |
2 |
26 Feb 07 |
jari |
513 |
|
2 |
26 Feb 07 |
jari |
514 |
/** |
2 |
26 Feb 07 |
jari |
* Returns description of a microarray normalization state. |
2 |
26 Feb 07 |
jari |
516 |
*/ |
2 |
26 Feb 07 |
jari |
517 |
public String getNormalizationString() {return normalizationString(normalizedState);} |
2 |
26 Feb 07 |
jari |
518 |
|
2 |
26 Feb 07 |
jari |
//Change to use class constants |
2 |
26 Feb 07 |
jari |
520 |
public static String normalizationString(int normalization) { |
2 |
26 Feb 07 |
jari |
521 |
String normalizationString; |
2 |
26 Feb 07 |
jari |
522 |
switch (normalization) { |
2 |
26 Feb 07 |
jari |
523 |
case 0: normalizationString = "No Normalization"; break; |
2 |
26 Feb 07 |
jari |
524 |
case 1: normalizationString = "Total Intensity"; break; |
2 |
26 Feb 07 |
jari |
525 |
case 2: normalizationString = "Least Squares"; break; |
2 |
26 Feb 07 |
jari |
526 |
case 3: normalizationString = "Linear Regression"; break; |
2 |
26 Feb 07 |
jari |
527 |
case 4: normalizationString = "Ratio Statistics"; break; |
2 |
26 Feb 07 |
jari |
528 |
case 5: normalizationString = "Ratio Statistics"; break; |
2 |
26 Feb 07 |
jari |
529 |
case 6: normalizationString = "Iterative Log"; break; |
2 |
26 Feb 07 |
jari |
530 |
case 7: normalizationString = "Lowess"; break; |
2 |
26 Feb 07 |
jari |
531 |
|
2 |
26 Feb 07 |
jari |
532 |
case 101: normalizationString = "Total Intensity (list)"; break; |
2 |
26 Feb 07 |
jari |
533 |
case 102: normalizationString = "Least Squares (list)"; break; |
2 |
26 Feb 07 |
jari |
534 |
case 103: normalizationString = "Linear Regression (list)"; break; |
2 |
26 Feb 07 |
jari |
535 |
case 104: normalizationString = "Ratio Statistics - 95% CI (list)"; break; |
2 |
26 Feb 07 |
jari |
536 |
case 105: normalizationString = "Ratio Statistics - 99% CI (list)"; break; |
2 |
26 Feb 07 |
jari |
537 |
case 106: normalizationString = "Iterative Log (list)"; break; |
2 |
26 Feb 07 |
jari |
538 |
case 107: normalizationString = "Lowess (list)"; break; |
2 |
26 Feb 07 |
jari |
539 |
default: normalizationString = "No Normalization"; break; |
2 |
26 Feb 07 |
jari |
540 |
} |
2 |
26 Feb 07 |
jari |
541 |
|
2 |
26 Feb 07 |
jari |
542 |
return normalizationString; |
2 |
26 Feb 07 |
jari |
543 |
} |
2 |
26 Feb 07 |
jari |
544 |
|
2 |
26 Feb 07 |
jari |
545 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray max CY3 value. |
2 |
26 Feb 07 |
jari |
547 |
*/ |
2 |
26 Feb 07 |
jari |
548 |
public float getMaxCY3() { |
2 |
26 Feb 07 |
jari |
549 |
return getMaxIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
550 |
} |
2 |
26 Feb 07 |
jari |
551 |
|
2 |
26 Feb 07 |
jari |
552 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray max CY5 value. |
2 |
26 Feb 07 |
jari |
554 |
*/ |
2 |
26 Feb 07 |
jari |
555 |
public float getMaxCY5() { |
2 |
26 Feb 07 |
jari |
556 |
return getMaxIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
557 |
} |
2 |
26 Feb 07 |
jari |
558 |
|
2 |
26 Feb 07 |
jari |
// Replaces getMaxCy3, getMaxCy5 |
2 |
26 Feb 07 |
jari |
560 |
public float getMaxIntensity(int intensityType) { |
2 |
26 Feb 07 |
jari |
561 |
float intensity, maxIntensity = 0; |
2 |
26 Feb 07 |
jari |
562 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
563 |
if(this.normalizedState == ISlideData.NO_NORMALIZATION) |
2 |
26 Feb 07 |
jari |
564 |
intensity = getSlideDataElement(i).getTrueIntensity(intensityType); |
2 |
26 Feb 07 |
jari |
565 |
else |
2 |
26 Feb 07 |
jari |
566 |
intensity = getSlideDataElement(i).getIntensity(intensityType); |
2 |
26 Feb 07 |
jari |
567 |
maxIntensity = Math.max(maxIntensity, intensity); |
2 |
26 Feb 07 |
jari |
568 |
} |
2 |
26 Feb 07 |
jari |
569 |
return maxIntensity; |
2 |
26 Feb 07 |
jari |
570 |
} |
2 |
26 Feb 07 |
jari |
571 |
|
2 |
26 Feb 07 |
jari |
572 |
/** |
2 |
26 Feb 07 |
jari |
* Returns max intencity of specified type. |
2 |
26 Feb 07 |
jari |
574 |
*/ |
2 |
26 Feb 07 |
jari |
575 |
public float getMinIntensity(int intensityType) {return getMinIntensity(intensityType, true);} |
2 |
26 Feb 07 |
jari |
576 |
|
2 |
26 Feb 07 |
jari |
577 |
/** |
2 |
26 Feb 07 |
jari |
* Returns min intencity of specified type. |
2 |
26 Feb 07 |
jari |
579 |
*/ |
2 |
26 Feb 07 |
jari |
580 |
public float getMinIntensity(int intensityType, boolean acceptZeros) { |
2 |
26 Feb 07 |
jari |
581 |
float intensity, minIntensity = Float.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
582 |
|
2 |
26 Feb 07 |
jari |
583 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
584 |
if(this.normalizedState == ISlideData.NO_NORMALIZATION) |
2 |
26 Feb 07 |
jari |
585 |
intensity = getSlideDataElement(i).getTrueIntensity(intensityType); |
2 |
26 Feb 07 |
jari |
586 |
else |
2 |
26 Feb 07 |
jari |
587 |
intensity = getSlideDataElement(i).getIntensity(intensityType); |
2 |
26 Feb 07 |
jari |
588 |
if (! acceptZeros) { |
2 |
26 Feb 07 |
jari |
589 |
if ((intensity < minIntensity) && (intensity != 0)) minIntensity = intensity; |
2 |
26 Feb 07 |
jari |
590 |
} else { |
2 |
26 Feb 07 |
jari |
591 |
if (intensity < minIntensity) minIntensity = intensity; |
2 |
26 Feb 07 |
jari |
592 |
} |
2 |
26 Feb 07 |
jari |
593 |
} |
2 |
26 Feb 07 |
jari |
594 |
return minIntensity; |
2 |
26 Feb 07 |
jari |
595 |
} |
2 |
26 Feb 07 |
jari |
596 |
|
2 |
26 Feb 07 |
jari |
597 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray max ratio value. |
2 |
26 Feb 07 |
jari |
599 |
*/ |
2 |
26 Feb 07 |
jari |
600 |
public float getMaxRatio() { |
2 |
26 Feb 07 |
jari |
601 |
return getMaxRatio(IData.LINEAR); |
2 |
26 Feb 07 |
jari |
602 |
} |
2 |
26 Feb 07 |
jari |
603 |
|
2 |
26 Feb 07 |
jari |
604 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray min ratio value. |
2 |
26 Feb 07 |
jari |
606 |
*/ |
2 |
26 Feb 07 |
jari |
607 |
public float getMinRatio() { |
2 |
26 Feb 07 |
jari |
608 |
return getMinRatio(IData.LINEAR); |
2 |
26 Feb 07 |
jari |
609 |
} |
2 |
26 Feb 07 |
jari |
610 |
|
2 |
26 Feb 07 |
jari |
611 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray max ratio value, with specified log state. |
2 |
26 Feb 07 |
jari |
613 |
*/ |
2 |
26 Feb 07 |
jari |
614 |
public float getMaxRatio(int logState) { |
2 |
26 Feb 07 |
jari |
615 |
return(float)getMaxRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, logState); |
2 |
26 Feb 07 |
jari |
616 |
} |
2 |
26 Feb 07 |
jari |
617 |
|
2 |
26 Feb 07 |
jari |
618 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray min ratio value, with specified log state. |
2 |
26 Feb 07 |
jari |
620 |
*/ |
2 |
26 Feb 07 |
jari |
621 |
public float getMinRatio(int logState) { |
2 |
26 Feb 07 |
jari |
622 |
return(float)getMinRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, logState); |
2 |
26 Feb 07 |
jari |
623 |
} |
2 |
26 Feb 07 |
jari |
624 |
|
2 |
26 Feb 07 |
jari |
625 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray max ratio value of specified intensities. |
2 |
26 Feb 07 |
jari |
627 |
*/ |
2 |
26 Feb 07 |
jari |
628 |
public float getMaxRatio(int intensityIndex1, int intensityIndex2, int logState) { |
2 |
26 Feb 07 |
jari |
629 |
float ratio, maxRatio = Float.MIN_VALUE; |
2 |
26 Feb 07 |
jari |
630 |
|
2 |
26 Feb 07 |
jari |
631 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
632 |
ratio = getSlideDataElement(i).getRatio(intensityIndex1, intensityIndex2, logState); |
2 |
26 Feb 07 |
jari |
633 |
if (ratio > maxRatio) |
2 |
26 Feb 07 |
jari |
634 |
maxRatio = ratio; |
2 |
26 Feb 07 |
jari |
635 |
} |
2 |
26 Feb 07 |
jari |
636 |
return maxRatio; |
2 |
26 Feb 07 |
jari |
637 |
} |
2 |
26 Feb 07 |
jari |
638 |
|
2 |
26 Feb 07 |
jari |
639 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray min ratio value of specified intensities. |
2 |
26 Feb 07 |
jari |
641 |
*/ |
2 |
26 Feb 07 |
jari |
642 |
public float getMinRatio(int intensityIndex1, int intensityIndex2, int logState) { |
2 |
26 Feb 07 |
jari |
643 |
float ratio, minRatio = Float.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
644 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
645 |
ratio = getSlideDataElement(i).getRatio(intensityIndex1, intensityIndex2, logState); |
2 |
26 Feb 07 |
jari |
646 |
if (ratio < minRatio) minRatio = ratio; |
2 |
26 Feb 07 |
jari |
647 |
} |
2 |
26 Feb 07 |
jari |
648 |
return minRatio; |
2 |
26 Feb 07 |
jari |
649 |
} |
2 |
26 Feb 07 |
jari |
650 |
|
2 |
26 Feb 07 |
jari |
651 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray max product value of specified intensities. |
2 |
26 Feb 07 |
jari |
653 |
*/ |
2 |
26 Feb 07 |
jari |
654 |
public float getMaxProduct(int intensityIndex1, int intensityIndex2) { |
2 |
26 Feb 07 |
jari |
655 |
float product = 0, maxProduct = 0; |
2 |
26 Feb 07 |
jari |
656 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
657 |
|
2 |
26 Feb 07 |
jari |
658 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
659 |
sde = getSlideDataElement(i); |
2 |
26 Feb 07 |
jari |
660 |
product = sde.getIntensity(intensityIndex1) * sde.getIntensity(intensityIndex2); |
2 |
26 Feb 07 |
jari |
661 |
if (product > maxProduct) |
2 |
26 Feb 07 |
jari |
662 |
maxProduct = product; |
2 |
26 Feb 07 |
jari |
663 |
} |
2 |
26 Feb 07 |
jari |
664 |
return maxProduct; |
2 |
26 Feb 07 |
jari |
665 |
} |
2 |
26 Feb 07 |
jari |
666 |
|
2 |
26 Feb 07 |
jari |
667 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray min product value of specified intensities. |
2 |
26 Feb 07 |
jari |
669 |
*/ |
2 |
26 Feb 07 |
jari |
670 |
public float getMinProduct(int intensityIndex1, int intensityIndex2, boolean acceptZeros) { |
2 |
26 Feb 07 |
jari |
671 |
return getMinProduct(intensityIndex1, intensityIndex2, acceptZeros, 0); |
2 |
26 Feb 07 |
jari |
672 |
} |
2 |
26 Feb 07 |
jari |
673 |
|
2 |
26 Feb 07 |
jari |
674 |
/** |
2 |
26 Feb 07 |
jari |
* Returns a microarray min product value of specified intensities and lower cutoffs. |
2 |
26 Feb 07 |
jari |
676 |
*/ |
2 |
26 Feb 07 |
jari |
677 |
public float getMinProduct(int intensityIndex1, int intensityIndex2, boolean acceptZeros, int lowCutoff) { |
2 |
26 Feb 07 |
jari |
678 |
float product = 0, minProduct = Float.MAX_VALUE; |
2 |
26 Feb 07 |
jari |
679 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
680 |
|
2 |
26 Feb 07 |
jari |
681 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
682 |
sde = getSlideDataElement(i); |
2 |
26 Feb 07 |
jari |
683 |
product = sde.getIntensity(intensityIndex1) * sde.getIntensity(intensityIndex2); |
2 |
26 Feb 07 |
jari |
684 |
if (product >= lowCutoff) { |
2 |
26 Feb 07 |
jari |
685 |
if (!acceptZeros) { |
2 |
26 Feb 07 |
jari |
686 |
if ((product < minProduct) && (product != 0)) minProduct = product; |
2 |
26 Feb 07 |
jari |
687 |
} else { |
2 |
26 Feb 07 |
jari |
688 |
if (product < minProduct) minProduct = product; |
2 |
26 Feb 07 |
jari |
689 |
} |
2 |
26 Feb 07 |
jari |
690 |
} |
2 |
26 Feb 07 |
jari |
691 |
} |
2 |
26 Feb 07 |
jari |
692 |
return minProduct; |
2 |
26 Feb 07 |
jari |
693 |
} |
2 |
26 Feb 07 |
jari |
694 |
|
2 |
26 Feb 07 |
jari |
695 |
/** |
2 |
26 Feb 07 |
jari |
* Returns intensities sum of specified type. |
2 |
26 Feb 07 |
jari |
697 |
*/ |
2 |
26 Feb 07 |
jari |
698 |
public long getSumIntensity(int intensityType) { |
2 |
26 Feb 07 |
jari |
699 |
long totalIntensity = 0; |
2 |
26 Feb 07 |
jari |
700 |
|
2 |
26 Feb 07 |
jari |
701 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
702 |
totalIntensity += getSlideDataElement(i).getIntensity(intensityType); |
2 |
26 Feb 07 |
jari |
703 |
} |
2 |
26 Feb 07 |
jari |
704 |
return totalIntensity; |
2 |
26 Feb 07 |
jari |
705 |
} |
2 |
26 Feb 07 |
jari |
706 |
|
2 |
26 Feb 07 |
jari |
707 |
/** |
2 |
26 Feb 07 |
jari |
* Returns non-zero intensities sum of specified type. |
2 |
26 Feb 07 |
jari |
709 |
*/ |
2 |
26 Feb 07 |
jari |
710 |
public long getSumNonZeroIntensity(int intensityType) { |
2 |
26 Feb 07 |
jari |
711 |
long totalIntensity = 0; |
2 |
26 Feb 07 |
jari |
712 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
713 |
|
2 |
26 Feb 07 |
jari |
714 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
715 |
try { |
2 |
26 Feb 07 |
jari |
716 |
sde = getSlideDataElement(i); |
2 |
26 Feb 07 |
jari |
717 |
if (sde.hasNoZeros()) totalIntensity += sde.getIntensity(intensityType); |
2 |
26 Feb 07 |
jari |
718 |
} catch (NullPointerException npe) { |
2 |
26 Feb 07 |
jari |
719 |
; |
2 |
26 Feb 07 |
jari |
720 |
} |
2 |
26 Feb 07 |
jari |
721 |
} |
2 |
26 Feb 07 |
jari |
722 |
return totalIntensity; |
2 |
26 Feb 07 |
jari |
723 |
} |
2 |
26 Feb 07 |
jari |
724 |
|
2 |
26 Feb 07 |
jari |
725 |
/** |
2 |
26 Feb 07 |
jari |
* Calculates a linear equation. |
2 |
26 Feb 07 |
jari |
727 |
*/ |
2 |
26 Feb 07 |
jari |
728 |
public LinearEquation getRegressionEquation(boolean useTrueValues) { |
2 |
26 Feb 07 |
jari |
729 |
LinearEquation linearEquation; |
2 |
26 Feb 07 |
jari |
730 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
731 |
double x = 0, y = 0; |
2 |
26 Feb 07 |
jari |
732 |
double sum = 0, sumX = 0, sumY = 0; |
2 |
26 Feb 07 |
jari |
733 |
double sumX2 = 0, sumY2 = 0, sumXY = 0; |
2 |
26 Feb 07 |
jari |
734 |
double weight = 1; //Change when set dynamically |
2 |
26 Feb 07 |
jari |
735 |
double delta = 0, a = 0, b = 0; |
2 |
26 Feb 07 |
jari |
736 |
double variance = 1; //Length of potence |
2 |
26 Feb 07 |
jari |
737 |
double regressionCoefficient = 0; |
2 |
26 Feb 07 |
jari |
738 |
double sigmaA = 0, sigmaB = 0; |
2 |
26 Feb 07 |
jari |
739 |
|
2 |
26 Feb 07 |
jari |
740 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
741 |
sde = getSlideDataElement(i); |
2 |
26 Feb 07 |
jari |
742 |
if (sde != null) { |
2 |
26 Feb 07 |
jari |
743 |
if (useTrueValues == true) { |
2 |
26 Feb 07 |
jari |
744 |
x = (double) sde.getTrueIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
745 |
y = (double) sde.getTrueIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
746 |
} else { |
2 |
26 Feb 07 |
jari |
747 |
x = (double) sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
748 |
y = (double) sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
749 |
} |
2 |
26 Feb 07 |
jari |
750 |
|
2 |
26 Feb 07 |
jari |
751 |
if (x != 0 && y != 0) { |
2 |
26 Feb 07 |
jari |
752 |
sum += weight; |
2 |
26 Feb 07 |
jari |
753 |
sumX += (weight * x); |
2 |
26 Feb 07 |
jari |
754 |
sumY += (weight * y); |
2 |
26 Feb 07 |
jari |
755 |
sumX2 += (weight * x * x); |
2 |
26 Feb 07 |
jari |
756 |
sumY2 += (weight * y * y); |
2 |
26 Feb 07 |
jari |
757 |
sumXY += (weight * x * y); |
2 |
26 Feb 07 |
jari |
758 |
} |
2 |
26 Feb 07 |
jari |
759 |
} |
2 |
26 Feb 07 |
jari |
760 |
} |
2 |
26 Feb 07 |
jari |
761 |
|
2 |
26 Feb 07 |
jari |
762 |
delta = (sum * sumX2) - (sumX * sumX); |
2 |
26 Feb 07 |
jari |
763 |
a = ((sumX2 * sumY) - (sumX * sumXY)) / delta; |
2 |
26 Feb 07 |
jari |
764 |
b = ((sumXY * sum) - (sumX * sumY)) / delta; |
2 |
26 Feb 07 |
jari |
765 |
sigmaA = Math.sqrt(variance * sumX2 / delta); |
2 |
26 Feb 07 |
jari |
766 |
sigmaB = Math.sqrt(variance * sum / delta); |
2 |
26 Feb 07 |
jari |
767 |
regressionCoefficient = ((sum * sumXY - sumX * sumY) / Math.sqrt(delta * (sum * sumY2) - (sumY * sumY))); |
2 |
26 Feb 07 |
jari |
768 |
|
2 |
26 Feb 07 |
jari |
769 |
linearEquation = new LinearEquation(b, a, regressionCoefficient); |
2 |
26 Feb 07 |
jari |
770 |
return linearEquation; |
2 |
26 Feb 07 |
jari |
771 |
} |
2 |
26 Feb 07 |
jari |
772 |
|
2 |
26 Feb 07 |
jari |
773 |
|
2 |
26 Feb 07 |
jari |
774 |
/********************************************************************** |
2 |
26 Feb 07 |
jari |
* Data Normalization Code. 04-2003 MeV will support only Total Intensity |
2 |
26 Feb 07 |
jari |
* Iterative Linear Regression, Ratio Statistics, and Iterative Log Mean Centering. |
2 |
26 Feb 07 |
jari |
* Support classes and normalization algorithms have been incorporated from |
2 |
26 Feb 07 |
jari |
* TIGR-MIDAS 2.16 (Author: Wei Liang, The Institute for Genomic Research) |
2 |
26 Feb 07 |
jari |
* which remains the primary tool for data normalization |
2 |
26 Feb 07 |
jari |
780 |
* |
2 |
26 Feb 07 |
jari |
* ColumnWorker is the main data structure used by the algorithms |
2 |
26 Feb 07 |
jari |
782 |
* |
2 |
26 Feb 07 |
jari |
* A typical normalization proceeds as follows: |
2 |
26 Feb 07 |
jari |
* 1.) "True Intensities" are accumulated into double arrays and a ColumnWorker is |
2 |
26 Feb 07 |
jari |
* constructed. |
2 |
26 Feb 07 |
jari |
* 2.) The ColumnWorker is passed via constructor into a normalization algorithm |
2 |
26 Feb 07 |
jari |
* which performs the required manipulations. (parameters are also in the constructor) |
2 |
26 Feb 07 |
jari |
* 3.) Data is retrieved from the resulting ColumnWorker and the data is placed |
2 |
26 Feb 07 |
jari |
* into the appropriate SlideDataElements (or arrays) as "Current Intensities" |
2 |
26 Feb 07 |
jari |
* (normalized). |
2 |
26 Feb 07 |
jari |
791 |
* |
2 |
26 Feb 07 |
jari |
* Conventions for normalization: |
2 |
26 Feb 07 |
jari |
793 |
* |
2 |
26 Feb 07 |
jari |
* "normalizedState" a class variable is used to indicate which intensities and |
2 |
26 Feb 07 |
jari |
* ratio's to deliver. ISlideData.NO_NORMALIZATION forces the return of "True" |
2 |
26 Feb 07 |
jari |
* intensities, meaning unaltered, while any other state indicates that "Current" |
2 |
26 Feb 07 |
jari |
* intensities (altered) should be returned. |
2 |
26 Feb 07 |
jari |
798 |
* |
2 |
26 Feb 07 |
jari |
* Handling zeros: |
2 |
26 Feb 07 |
jari |
800 |
* |
2 |
26 Feb 07 |
jari |
* A zero in one or both channels would greatly impact the normalization of points |
2 |
26 Feb 07 |
jari |
* containing two good intensities. For this reason the following convention for handling |
2 |
26 Feb 07 |
jari |
* one or two zero intensities has been adopted. If one or both intensities are zero this |
2 |
26 Feb 07 |
jari |
* data is not passed on to the ColumnWorker for normalization and following the normalization |
2 |
26 Feb 07 |
jari |
* the "current" intensities are set to equal the "true", original, intensities. |
2 |
26 Feb 07 |
jari |
806 |
* |
2 |
26 Feb 07 |
jari |
* By this convention the points are preserved AND the data that has been normalized |
2 |
26 Feb 07 |
jari |
* matches MIDAS output. |
2 |
26 Feb 07 |
jari |
809 |
* |
2 |
26 Feb 07 |
jari |
810 |
************************************************************************************/ |
2 |
26 Feb 07 |
jari |
811 |
|
2 |
26 Feb 07 |
jari |
812 |
/** |
2 |
26 Feb 07 |
jari |
* Normalize a microarray data. |
2 |
26 Feb 07 |
jari |
814 |
*/ |
2 |
26 Feb 07 |
jari |
815 |
public void applyNormalization(int normalizationMode, Properties props) { |
2 |
26 Feb 07 |
jari |
816 |
switch (normalizationMode) { |
2 |
26 Feb 07 |
jari |
817 |
case SlideData.NO_NORMALIZATION: applyNoNormalization(); break; |
2 |
26 Feb 07 |
jari |
818 |
case SlideData.TOTAL_INTENSITY: applyTotalIntensity(); break; |
2 |
26 Feb 07 |
jari |
819 |
case SlideData.LEAST_SQUARES: applyLeastSquares(); break; |
2 |
26 Feb 07 |
jari |
820 |
case SlideData.LINEAR_REGRESSION: applyLinearRegression(props); break; |
2 |
26 Feb 07 |
jari |
821 |
case SlideData.RATIO_STATISTICS_95: applyRatioStatistics(props); break; |
2 |
26 Feb 07 |
jari |
822 |
case SlideData.RATIO_STATISTICS_99: applyRatioStatistics(props); break; |
2 |
26 Feb 07 |
jari |
823 |
case SlideData.ITERATIVE_LOG: applyIterativeLog(props); break; |
2 |
26 Feb 07 |
jari |
824 |
case SlideData.LOWESS: applyLowess(10); break; |
2 |
26 Feb 07 |
jari |
825 |
} |
2 |
26 Feb 07 |
jari |
826 |
} |
2 |
26 Feb 07 |
jari |
827 |
|
2 |
26 Feb 07 |
jari |
828 |
/** |
2 |
26 Feb 07 |
jari |
* Normalize a microarray data. |
2 |
26 Feb 07 |
jari |
830 |
*/ |
2 |
26 Feb 07 |
jari |
831 |
public void applyNormalizationList(int normalizationMode) { |
2 |
26 Feb 07 |
jari |
832 |
switch (normalizationMode) { |
2 |
26 Feb 07 |
jari |
//Don't forget to change over to the list versions of the functions |
2 |
26 Feb 07 |
jari |
834 |
case SlideData.TOTAL_INTENSITY_LIST: applyTotalIntensity(); break; |
2 |
26 Feb 07 |
jari |
835 |
case SlideData.LEAST_SQUARES_LIST: applyLeastSquares(); break; |
2 |
26 Feb 07 |
jari |
836 |
case SlideData.LINEAR_REGRESSION_LIST: applyLinearRegression(new Properties()); break; |
2 |
26 Feb 07 |
jari |
837 |
case SlideData.RATIO_STATISTICS_95_LIST: applyRatioStatistics(new Properties()); break; |
2 |
26 Feb 07 |
jari |
838 |
case SlideData.RATIO_STATISTICS_99_LIST: applyRatioStatistics(new Properties()); break; |
2 |
26 Feb 07 |
jari |
839 |
case SlideData.ITERATIVE_LOG_LIST: applyIterativeLog(new Properties()); break; |
2 |
26 Feb 07 |
jari |
840 |
case SlideData.LOWESS_LIST: applyLowess(10); break; |
2 |
26 Feb 07 |
jari |
841 |
} |
2 |
26 Feb 07 |
jari |
842 |
} |
2 |
26 Feb 07 |
jari |
843 |
|
2 |
26 Feb 07 |
jari |
844 |
|
2 |
26 Feb 07 |
jari |
845 |
/** |
2 |
26 Feb 07 |
jari |
* Restore an original microarray data. |
2 |
26 Feb 07 |
jari |
847 |
*/ |
2 |
26 Feb 07 |
jari |
848 |
public void applyNoNormalization() { |
2 |
26 Feb 07 |
jari |
849 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
850 |
if (normalizedState != SlideData.NO_NORMALIZATION) { |
2 |
26 Feb 07 |
jari |
851 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
852 |
sde = getSlideDataElement(i); |
2 |
26 Feb 07 |
jari |
853 |
sde.setIntensity(ISlideDataElement.CY3, sde.getTrueIntensity(ISlideDataElement.CY3)); |
2 |
26 Feb 07 |
jari |
854 |
sde.setIntensity(ISlideDataElement.CY5, sde.getTrueIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
855 |
} |
2 |
26 Feb 07 |
jari |
856 |
normalizedState = SlideData.NO_NORMALIZATION; |
2 |
26 Feb 07 |
jari |
857 |
} |
2 |
26 Feb 07 |
jari |
858 |
} |
2 |
26 Feb 07 |
jari |
859 |
|
2 |
26 Feb 07 |
jari |
860 |
/** |
2 |
26 Feb 07 |
jari |
* Applies total intensity normalization. |
2 |
26 Feb 07 |
jari |
862 |
*/ |
2 |
26 Feb 07 |
jari |
863 |
public void applyTotalIntensity() { |
2 |
26 Feb 07 |
jari |
864 |
ISlideDataElement sde = getSlideDataElement(10); |
2 |
26 Feb 07 |
jari |
865 |
boolean [] goodValues = new boolean[this.getSize()]; |
2 |
26 Feb 07 |
jari |
866 |
ColumnWorker cw = constructColumnWorker(goodValues); |
2 |
26 Feb 07 |
jari |
867 |
cw = ((new TotInt(cw, "Cy3", false)).getFileTotIntColumnWorker()); |
2 |
26 Feb 07 |
jari |
868 |
setNormalizedIntensities(cw, goodValues); |
2 |
26 Feb 07 |
jari |
869 |
normalizedState = ISlideData.TOTAL_INTENSITY; |
2 |
26 Feb 07 |
jari |
870 |
} |
2 |
26 Feb 07 |
jari |
871 |
|
2 |
26 Feb 07 |
jari |
872 |
/** |
2 |
26 Feb 07 |
jari |
* Applies linear regression normalization. |
2 |
26 Feb 07 |
jari |
874 |
*/ |
2 |
26 Feb 07 |
jari |
875 |
public void applyLinearRegression(Properties properties) { |
2 |
26 Feb 07 |
jari |
876 |
boolean [] goodValues = new boolean[this.getSize()]; |
2 |
26 Feb 07 |
jari |
877 |
ColumnWorker cw = constructColumnWorker(goodValues); |
2 |
26 Feb 07 |
jari |
878 |
try{ |
2 |
26 Feb 07 |
jari |
879 |
String mode = (String)properties.get("mode"); |
2 |
26 Feb 07 |
jari |
880 |
float sd = Float.parseFloat((String)properties.get("standard-deviation")); |
2 |
26 Feb 07 |
jari |
881 |
cw = ((new IterativeLinReg(cw, sd, mode, "Cy3")).getIterLinRegColumnWorker()); |
2 |
26 Feb 07 |
jari |
882 |
setNormalizedIntensities(cw, goodValues); |
2 |
26 Feb 07 |
jari |
883 |
normalizedState = ISlideData.LINEAR_REGRESSION; |
2 |
26 Feb 07 |
jari |
884 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
885 |
javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Error Performing Normalization: Data Unchanged", "Normalization Error : Aborted", javax.swing.JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
886 |
normalizedState = ISlideData.NO_NORMALIZATION; |
2 |
26 Feb 07 |
jari |
887 |
} |
2 |
26 Feb 07 |
jari |
888 |
} |
2 |
26 Feb 07 |
jari |
889 |
|
2 |
26 Feb 07 |
jari |
890 |
/** |
2 |
26 Feb 07 |
jari |
* Applies ratio statistics normalization. |
2 |
26 Feb 07 |
jari |
892 |
*/ |
2 |
26 Feb 07 |
jari |
893 |
public void applyRatioStatistics(Properties properties) { |
2 |
26 Feb 07 |
jari |
894 |
boolean [] goodValues = new boolean[this.getSize()]; |
2 |
26 Feb 07 |
jari |
895 |
ColumnWorker cw = constructColumnWorker(goodValues); |
2 |
26 Feb 07 |
jari |
896 |
try{ |
2 |
26 Feb 07 |
jari |
897 |
int confInt = Integer.parseInt((String)properties.get("confidence-interval")); |
2 |
26 Feb 07 |
jari |
898 |
cw = ((new RatioStats(cw, true, confInt, "Cy3")).getRatioStatsColumnWorker()); |
2 |
26 Feb 07 |
jari |
899 |
setNormalizedIntensities(cw, goodValues); |
2 |
26 Feb 07 |
jari |
900 |
normalizedState = ISlideData.LINEAR_REGRESSION; |
2 |
26 Feb 07 |
jari |
901 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
902 |
javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Error Performing Normalization: Data Unchanged", "Normalization Error : Aborted", javax.swing.JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
903 |
normalizedState = ISlideData.NO_NORMALIZATION; |
2 |
26 Feb 07 |
jari |
904 |
e.printStackTrace(); |
2 |
26 Feb 07 |
jari |
905 |
} |
2 |
26 Feb 07 |
jari |
906 |
} |
2 |
26 Feb 07 |
jari |
907 |
|
2 |
26 Feb 07 |
jari |
908 |
/** |
2 |
26 Feb 07 |
jari |
* Applies iterative log normalization. |
2 |
26 Feb 07 |
jari |
910 |
*/ |
2 |
26 Feb 07 |
jari |
911 |
public void applyIterativeLog(Properties properties) { |
2 |
26 Feb 07 |
jari |
912 |
boolean [] goodValues = new boolean[this.getSize()]; |
2 |
26 Feb 07 |
jari |
913 |
ColumnWorker cw = constructColumnWorker(goodValues); |
2 |
26 Feb 07 |
jari |
914 |
try{ |
2 |
26 Feb 07 |
jari |
915 |
float sd = Float.parseFloat((String)properties.get("standard-deviation")); |
2 |
26 Feb 07 |
jari |
//System.out.println("iter log sd = "+sd); |
2 |
26 Feb 07 |
jari |
917 |
cw = ((new IterativeLogMean(cw, sd, "Cy3")).getIterLogMeanColumnWorker()); |
2 |
26 Feb 07 |
jari |
918 |
setNormalizedIntensities(cw, goodValues); |
2 |
26 Feb 07 |
jari |
919 |
normalizedState = ISlideData.ITERATIVE_LOG; |
2 |
26 Feb 07 |
jari |
920 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
921 |
javax.swing.JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Error Performing Normalization: Data Unchanged", "Normalization Error : Aborted", javax.swing.JOptionPane.WARNING_MESSAGE); |
2 |
26 Feb 07 |
jari |
922 |
normalizedState = ISlideData.NO_NORMALIZATION; |
2 |
26 Feb 07 |
jari |
923 |
} |
2 |
26 Feb 07 |
jari |
924 |
} |
2 |
26 Feb 07 |
jari |
925 |
|
2 |
26 Feb 07 |
jari |
926 |
/** |
2 |
26 Feb 07 |
jari |
* Creates a ColumnWorker object for normalization |
2 |
26 Feb 07 |
jari |
928 |
*/ |
2 |
26 Feb 07 |
jari |
929 |
private ColumnWorker constructColumnWorker(boolean [] goodValues){ |
2 |
26 Feb 07 |
jari |
930 |
int n = this.getSize(); |
2 |
26 Feb 07 |
jari |
931 |
int size = n; |
2 |
26 Feb 07 |
jari |
932 |
float CY3; |
2 |
26 Feb 07 |
jari |
933 |
float CY5; |
2 |
26 Feb 07 |
jari |
934 |
float [] cy3 = new float[n]; |
2 |
26 Feb 07 |
jari |
935 |
float [] cy5 = new float[n]; |
2 |
26 Feb 07 |
jari |
936 |
String [] metaCombo = new String[n]; |
2 |
26 Feb 07 |
jari |
937 |
int metaRow, metaColumn; |
2 |
26 Feb 07 |
jari |
938 |
float [] goodCy3; |
2 |
26 Feb 07 |
jari |
939 |
float [] goodCy5; |
2 |
26 Feb 07 |
jari |
940 |
|
2 |
26 Feb 07 |
jari |
941 |
n = 0; |
2 |
26 Feb 07 |
jari |
942 |
for(int i = 0; i < size; i++){ |
2 |
26 Feb 07 |
jari |
943 |
metaRow = this.getSlideDataElement(i).getRow(ISlideDataElement.META); |
2 |
26 Feb 07 |
jari |
944 |
metaColumn = this.getSlideDataElement(i).getColumn(ISlideDataElement.META); |
2 |
26 Feb 07 |
jari |
945 |
|
2 |
26 Feb 07 |
jari |
946 |
CY3 = (float)this.getSlideDataElement(i).getTrueIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
947 |
CY5 = (float)this.getSlideDataElement(i).getTrueIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
948 |
|
2 |
26 Feb 07 |
jari |
//if Stanford file is normalized then we need to generate cy3 and cy5 |
2 |
26 Feb 07 |
jari |
950 |
if (this.dataType == IData.DATA_TYPE_RATIO_ONLY) { |
2 |
26 Feb 07 |
jari |
951 |
CY3 = 100000; |
2 |
26 Feb 07 |
jari |
952 |
CY5 = (float)(100000.0*Math.pow(2.0d, CY5)); |
2 |
26 Feb 07 |
jari |
// if CY5 overflows, then set to zero and force no evaluation |
2 |
26 Feb 07 |
jari |
954 |
if(CY5 == Float.POSITIVE_INFINITY || CY5 == Float.NEGATIVE_INFINITY) |
2 |
26 Feb 07 |
jari |
955 |
CY3 = CY5 = 0; |
2 |
26 Feb 07 |
jari |
956 |
} |
2 |
26 Feb 07 |
jari |
957 |
|
2 |
26 Feb 07 |
jari |
958 |
if(CY3 != 0 && CY5 != 0){ |
2 |
26 Feb 07 |
jari |
959 |
goodValues[i] = true; |
2 |
26 Feb 07 |
jari |
960 |
cy3[n] = CY3; |
2 |
26 Feb 07 |
jari |
961 |
cy5[n] = CY5; |
2 |
26 Feb 07 |
jari |
962 |
metaCombo[n] = Integer.toString(metaRow)+"_"+Integer.toString(metaColumn); |
2 |
26 Feb 07 |
jari |
963 |
n++; |
2 |
26 Feb 07 |
jari |
964 |
} |
2 |
26 Feb 07 |
jari |
965 |
} |
2 |
26 Feb 07 |
jari |
966 |
goodCy3 = new float[n]; |
2 |
26 Feb 07 |
jari |
967 |
goodCy5 = new float[n]; |
2 |
26 Feb 07 |
jari |
968 |
System.arraycopy(cy3, 0, goodCy3, 0, n); |
2 |
26 Feb 07 |
jari |
969 |
System.arraycopy(cy5, 0, goodCy5, 0, n); |
2 |
26 Feb 07 |
jari |
970 |
System.arraycopy(metaCombo, 0, metaCombo, 0, n); |
2 |
26 Feb 07 |
jari |
971 |
|
2 |
26 Feb 07 |
jari |
// ColumnWorker cw = new ColumnWorker(goodCy3.length); |
2 |
26 Feb 07 |
jari |
//cw.setColOneArray(goodCy3); |
2 |
26 Feb 07 |
jari |
//cw.setColTwoArray(goodCy5); |
2 |
26 Feb 07 |
jari |
975 |
|
2 |
26 Feb 07 |
jari |
// return cw; |
2 |
26 Feb 07 |
jari |
977 |
return new ColumnWorker(goodCy3, goodCy5, metaCombo); |
2 |
26 Feb 07 |
jari |
978 |
} |
2 |
26 Feb 07 |
jari |
979 |
|
2 |
26 Feb 07 |
jari |
980 |
/** |
2 |
26 Feb 07 |
jari |
* Extracts data from a ColumnWorker into ISlideData current (normalized) intensities |
2 |
26 Feb 07 |
jari |
982 |
*/ |
2 |
26 Feb 07 |
jari |
983 |
private void setNormalizedIntensities(ColumnWorker cw, boolean [] goodIntensity){ |
2 |
26 Feb 07 |
jari |
984 |
float [] cy3 = cw.getColumnOneArray(); |
2 |
26 Feb 07 |
jari |
985 |
float [] cy5 = cw.getColumnTwoArray(); |
2 |
26 Feb 07 |
jari |
986 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
987 |
int goodIndex= 0; |
2 |
26 Feb 07 |
jari |
988 |
for(int i = 0 ; i < goodIntensity.length; i++){ |
2 |
26 Feb 07 |
jari |
989 |
sde = this.getSlideDataElement(i); |
2 |
26 Feb 07 |
jari |
990 |
if(goodIntensity[i]){ |
2 |
26 Feb 07 |
jari |
991 |
if(this.dataType == IData.DATA_TYPE_RATIO_ONLY) { |
2 |
26 Feb 07 |
jari |
992 |
sde.setIntensity(ISlideDataElement.CY3, (float)1.0); |
2 |
26 Feb 07 |
jari |
993 |
sde.setIntensity(ISlideDataElement.CY5, (float)(Math.log(cy5[goodIndex]/cy3[goodIndex])/Math.log(2.0))); |
2 |
26 Feb 07 |
jari |
994 |
} else { |
2 |
26 Feb 07 |
jari |
995 |
sde.setIntensity(ISlideDataElement.CY3, (float)cy3[goodIndex]); |
2 |
26 Feb 07 |
jari |
996 |
sde.setIntensity(ISlideDataElement.CY5, (float)cy5[goodIndex]); |
2 |
26 Feb 07 |
jari |
997 |
} |
2 |
26 Feb 07 |
jari |
998 |
goodIndex++; |
2 |
26 Feb 07 |
jari |
999 |
} |
2 |
26 Feb 07 |
jari |
1000 |
else{ |
2 |
26 Feb 07 |
jari |
1001 |
sde.setIntensity(ISlideDataElement.CY3, sde.getTrueIntensity(ISlideDataElement.CY3)); |
2 |
26 Feb 07 |
jari |
1002 |
sde.setIntensity(ISlideDataElement.CY5, sde.getTrueIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
1003 |
} |
2 |
26 Feb 07 |
jari |
1004 |
} |
2 |
26 Feb 07 |
jari |
1005 |
} |
2 |
26 Feb 07 |
jari |
1006 |
|
2 |
26 Feb 07 |
jari |
1007 |
/******************************************************************************** |
2 |
26 Feb 07 |
jari |
* End supported normalization code. |
2 |
26 Feb 07 |
jari |
1009 |
*/ |
2 |
26 Feb 07 |
jari |
1010 |
|
2 |
26 Feb 07 |
jari |
1011 |
|
2 |
26 Feb 07 |
jari |
1012 |
/** |
2 |
26 Feb 07 |
jari |
* Applies lowess normalization. |
2 |
26 Feb 07 |
jari |
1014 |
*/ |
2 |
26 Feb 07 |
jari |
1015 |
public void applyLowess(int bins) { |
2 |
26 Feb 07 |
jari |
// applyIterativeLog(); |
2 |
26 Feb 07 |
jari |
1017 |
|
2 |
26 Feb 07 |
jari |
1018 |
Vector binVector = new Vector(); |
2 |
26 Feb 07 |
jari |
1019 |
Vector bin; |
2 |
26 Feb 07 |
jari |
1020 |
ISlideDataElement[] sdes = new ISlideDataElement[size()]; |
2 |
26 Feb 07 |
jari |
1021 |
float[] logRatios = new float[size()]; |
2 |
26 Feb 07 |
jari |
1022 |
float[] logProduct = new float[size()]; |
2 |
26 Feb 07 |
jari |
1023 |
int[] descendingRank = new int[size()]; |
2 |
26 Feb 07 |
jari |
1024 |
int binSize = size() / bins + 1; |
2 |
26 Feb 07 |
jari |
1025 |
|
2 |
26 Feb 07 |
jari |
1026 |
for (int i = 0; i < bins; i++) binVector.addElement(new Vector()); |
2 |
26 Feb 07 |
jari |
1027 |
|
2 |
26 Feb 07 |
jari |
1028 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
1029 |
sdes[i] = getSlideDataElement(i); |
2 |
26 Feb 07 |
jari |
1030 |
logRatios[i] = (float)Xcon.log2(sdes[i].getRatio(ISlideDataElement.CY5, ISlideDataElement.CY3, AC.LINEAR)); |
2 |
26 Feb 07 |
jari |
1031 |
logProduct[i] = (float)Xcon.log10(sdes[i].getIntensity(ISlideDataElement.CY3) * sdes[i].getIntensity(ISlideDataElement.CY5)); |
2 |
26 Feb 07 |
jari |
1032 |
} |
2 |
26 Feb 07 |
jari |
1033 |
|
2 |
26 Feb 07 |
jari |
1034 |
double largest = 0; |
2 |
26 Feb 07 |
jari |
1035 |
int highestRank = 0; |
2 |
26 Feb 07 |
jari |
1036 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
1037 |
for (int j = 0; j < size(); j++) { |
2 |
26 Feb 07 |
jari |
1038 |
COMP: if (largest < logProduct[j]) { |
2 |
26 Feb 07 |
jari |
1039 |
for (int k = 0; k < i; k++) { |
2 |
26 Feb 07 |
jari |
1040 |
if (j == descendingRank[k]) break COMP; |
2 |
26 Feb 07 |
jari |
1041 |
} |
2 |
26 Feb 07 |
jari |
1042 |
largest = logProduct[j]; |
2 |
26 Feb 07 |
jari |
1043 |
highestRank = j; |
2 |
26 Feb 07 |
jari |
1044 |
} |
2 |
26 Feb 07 |
jari |
1045 |
} |
2 |
26 Feb 07 |
jari |
1046 |
|
2 |
26 Feb 07 |
jari |
1047 |
descendingRank[i] = highestRank; |
2 |
26 Feb 07 |
jari |
1048 |
} |
2 |
26 Feb 07 |
jari |
1049 |
|
2 |
26 Feb 07 |
jari |
1050 |
for (int i = 0; i < size(); i++) System.out.println("Rank: " + i + ", Element: " + descendingRank[i]); |
2 |
26 Feb 07 |
jari |
1051 |
|
2 |
26 Feb 07 |
jari |
1052 |
int binC = 0; |
2 |
26 Feb 07 |
jari |
1053 |
int binP = 0; |
2 |
26 Feb 07 |
jari |
1054 |
for (int i = 0; i < size(); i++, binC++) { |
2 |
26 Feb 07 |
jari |
1055 |
((Vector) binVector.elementAt(binP)).addElement(sdes[descendingRank[i]]); |
2 |
26 Feb 07 |
jari |
1056 |
|
2 |
26 Feb 07 |
jari |
1057 |
if (binC == binSize) { |
2 |
26 Feb 07 |
jari |
1058 |
binC = 0; |
2 |
26 Feb 07 |
jari |
1059 |
binP++; |
2 |
26 Feb 07 |
jari |
1060 |
} |
2 |
26 Feb 07 |
jari |
1061 |
} |
2 |
26 Feb 07 |
jari |
1062 |
|
2 |
26 Feb 07 |
jari |
1063 |
System.out.println(binVector.size() + " bins created"); |
2 |
26 Feb 07 |
jari |
1064 |
for (int i = 0; i < binVector.size(); i++) { |
2 |
26 Feb 07 |
jari |
1065 |
System.out.println("Bin " + i + " has " + ((Vector) binVector.elementAt(i)).size() + " elements"); |
2 |
26 Feb 07 |
jari |
1066 |
} |
2 |
26 Feb 07 |
jari |
1067 |
|
2 |
26 Feb 07 |
jari |
//Adjust mean(log2(r/g)) for each bin (like iterative log) |
2 |
26 Feb 07 |
jari |
1069 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
1070 |
if (true) { //Use an adaptation of the iterative log algorithm |
2 |
26 Feb 07 |
jari |
1071 |
for (int m = 0; m < binVector.size(); m++) { |
2 |
26 Feb 07 |
jari |
1072 |
Vector targetBin = ((Vector) binVector.elementAt(m)); |
2 |
26 Feb 07 |
jari |
1073 |
long greensum = 0, redsum = 0, usegreensum = 0, useredsum = 0; |
2 |
26 Feb 07 |
jari |
1074 |
|
2 |
26 Feb 07 |
jari |
1075 |
for (int i = 0; i < targetBin.size(); i++) { |
2 |
26 Feb 07 |
jari |
1076 |
sde = ((ISlideDataElement) targetBin.elementAt(i)); |
2 |
26 Feb 07 |
jari |
1077 |
greensum += sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
1078 |
redsum += sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
1079 |
if (sde.hasNoZeros()) { |
2 |
26 Feb 07 |
jari |
1080 |
usegreensum += sde.getIntensity(ISlideDataElement.CY5); |
2 |
26 Feb 07 |
jari |
1081 |
useredsum += sde.getIntensity(ISlideDataElement.CY3); |
2 |
26 Feb 07 |
jari |
1082 |
} |
2 |
26 Feb 07 |
jari |
1083 |
} |
2 |
26 Feb 07 |
jari |
1084 |
|
2 |
26 Feb 07 |
jari |
1085 |
double norat = (double) redsum / (double) greensum; |
2 |
26 Feb 07 |
jari |
1086 |
double usenorat = (double) useredsum / (double) usegreensum; |
2 |
26 Feb 07 |
jari |
1087 |
double yzsum = 0, yz = 0, yzave = 0; |
2 |
26 Feb 07 |
jari |
1088 |
int yzmun = 0; |
2 |
26 Feb 07 |
jari |
1089 |
double lnx, lny, uselograt; |
2 |
26 Feb 07 |
jari |
1090 |
double[] ratio2 = new double[size()]; |
2 |
26 Feb 07 |
jari |
1091 |
|
2 |
26 Feb 07 |
jari |
1092 |
System.out.println(m + " - All: " + redsum + "\t" + greensum + "\t" + norat); |
2 |
26 Feb 07 |
jari |
1093 |
System.out.println(m + " - Use: " + useredsum + "\t" + usegreensum + "\t" + usenorat); |
2 |
26 Feb 07 |
jari |
1094 |
|
2 |
26 Feb 07 |
jari |
1095 |
for (int i = 0; i < targetBin.size(); i++) { |
2 |
26 Feb 07 |
jari |
1096 |
sde = ((ISlideDataElement) targetBin.elementAt(i)); |
2 |
26 Feb 07 |
jari |
1097 |
sde.setIntensity(ISlideDataElement.CY5, (long) ((double) sde.getIntensity(ISlideDataElement.CY5) * usenorat)); |
2 |
26 Feb 07 |
jari |
1098 |
yz = Xcon.log2(sde.getRatio(ISlideDataElement.CY3, ISlideDataElement.CY5, AC.LINEAR) / usenorat); |
2 |
26 Feb 07 |
jari |
1099 |
|
2 |
26 Feb 07 |
jari |
1100 |
if (sde.hasNoZeros()) { |
2 |
26 Feb 07 |
jari |
1101 |
yzsum += yz; |
2 |
26 Feb 07 |
jari |
1102 |
yzmun++; |
2 |
26 Feb 07 |
jari |
1103 |
} |
2 |
26 Feb 07 |
jari |
1104 |
|
2 |
26 Feb 07 |
jari |
1105 |
lnx = Math.log(1); |
2 |
26 Feb 07 |
jari |
1106 |
lny = Math.log(1); |
2 |
26 Feb 07 |
jari |
1107 |
} |
2 |
26 Feb 07 |
jari |
1108 |
|
2 |
26 Feb 07 |
jari |
1109 |
yzave = yzsum / yzmun; |
2 |
26 Feb 07 |
jari |
1110 |
System.out.println(m + " - Mean log ratio: " + yzave); |
2 |
26 Feb 07 |
jari |
1111 |
yzsum = 0; |
2 |
26 Feb 07 |
jari |
1112 |
yzmun = 0; |
2 |
26 Feb 07 |
jari |
1113 |
|
2 |
26 Feb 07 |
jari |
1114 |
uselograt = Math.pow(Math.E, yzave); |
2 |
26 Feb 07 |
jari |
1115 |
System.out.println(m + " - Scale: " + uselograt); |
2 |
26 Feb 07 |
jari |
1116 |
|
2 |
26 Feb 07 |
jari |
1117 |
for (int i = 0; i < targetBin.size(); i++) { |
2 |
26 Feb 07 |
jari |
1118 |
sde = ((ISlideDataElement) targetBin.elementAt(i)); |
2 |
26 Feb 07 |
jari |
1119 |
sde.setIntensity(ISlideDataElement.CY5, (long) ((double) sde.getIntensity(ISlideDataElement.CY5) * uselograt)); |
2 |
26 Feb 07 |
jari |
1120 |
yz = Xcon.log2(sde.getRatio(ISlideDataElement.CY3, ISlideDataElement.CY5, AC.LINEAR) / uselograt); |
2 |
26 Feb 07 |
jari |
1121 |
} |
2 |
26 Feb 07 |
jari |
1122 |
|
2 |
26 Feb 07 |
jari |
1123 |
for (int i = 0; i < targetBin.size(); i++) { |
2 |
26 Feb 07 |
jari |
1124 |
sde = ((ISlideDataElement) targetBin.elementAt(i)); |
2 |
26 Feb 07 |
jari |
1125 |
if (sde.hasNoZeros()) ratio2[i] = sde.getRatio(ISlideDataElement.CY3, ISlideDataElement.CY5, AC.LINEAR) / usenorat / uselograt; |
2 |
26 Feb 07 |
jari |
1126 |
else ratio2[i] = sde.getRatio(ISlideDataElement.CY3, ISlideDataElement.CY5, AC.LINEAR); |
2 |
26 Feb 07 |
jari |
1127 |
} |
2 |
26 Feb 07 |
jari |
1128 |
|
2 |
26 Feb 07 |
jari |
1129 |
double xsum = 0; |
2 |
26 Feb 07 |
jari |
1130 |
int xnum = 0; |
2 |
26 Feb 07 |
jari |
1131 |
double x = 0; |
2 |
26 Feb 07 |
jari |
1132 |
double xave = 0; |
2 |
26 Feb 07 |
jari |
1133 |
double newlognor = 0; |
2 |
26 Feb 07 |
jari |
1134 |
|
2 |
26 Feb 07 |
jari |
1135 |
for (int it = 0; it <= 10; it++) { |
2 |
26 Feb 07 |
jari |
//for (int i = 0; i < size(); i++) |
2 |
26 Feb 07 |
jari |
1137 |
for (int i = 0; i < targetBin.size(); i++) { |
2 |
26 Feb 07 |
jari |
1138 |
sde = ((ISlideDataElement) targetBin.elementAt(i)); |
2 |
26 Feb 07 |
jari |
1139 |
if (sde.hasNoZeros()) { |
2 |
26 Feb 07 |
jari |
1140 |
x = Xcon.log2(ratio2[i]); |
2 |
26 Feb 07 |
jari |
1141 |
if ((x <= 1) && (x >= -1)) { |
2 |
26 Feb 07 |
jari |
1142 |
xsum += x; |
2 |
26 Feb 07 |
jari |
1143 |
xnum++; |
2 |
26 Feb 07 |
jari |
1144 |
} |
2 |
26 Feb 07 |
jari |
1145 |
} |
2 |
26 Feb 07 |
jari |
1146 |
} |
2 |
26 Feb 07 |
jari |
1147 |
xave = xsum / xnum; |
2 |
26 Feb 07 |
jari |
//Older style, using natural logs? Conserve? |
2 |
26 Feb 07 |
jari |
//newlognor = Math.pow(Math.E, xave); |
2 |
26 Feb 07 |
jari |
1150 |
newlognor = Math.pow(Math.E, xave); |
2 |
26 Feb 07 |
jari |
1151 |
System.out.println(m + " - Iteration " + it + "\tMean Log Ratio: " + xave + "\t" + newlognor); |
2 |
26 Feb 07 |
jari |
1152 |
for (int i = 0; i < targetBin.size(); i++) { |
2 |
26 Feb 07 |
jari |
// for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
1154 |
sde = ((ISlideDataElement) targetBin.elementAt(i)); |
2 |
26 Feb 07 |
jari |
1155 |
if (sde.hasNoZeros()) { |
2 |
26 Feb 07 |
jari |
1156 |
ratio2[i] = ratio2[i] / newlognor; |
2 |
26 Feb 07 |
jari |
1157 |
} |
2 |
26 Feb 07 |
jari |
1158 |
sde.setIntensity(ISlideDataElement.CY5, (long) ((double) sde.getIntensity(ISlideDataElement.CY5) * newlognor)); |
2 |
26 Feb 07 |
jari |
1159 |
} |
2 |
26 Feb 07 |
jari |
1160 |
} |
2 |
26 Feb 07 |
jari |
1161 |
} |
2 |
26 Feb 07 |
jari |
1162 |
} |
2 |
26 Feb 07 |
jari |
1163 |
|
2 |
26 Feb 07 |
jari |
1164 |
normalizedState = SlideData.LOWESS; |
2 |
26 Feb 07 |
jari |
1165 |
} |
2 |
26 Feb 07 |
jari |
1166 |
|
2 |
26 Feb 07 |
jari |
1167 |
/** |
2 |
26 Feb 07 |
jari |
* Applies least squares normalization. |
2 |
26 Feb 07 |
jari |
1169 |
*/ |
2 |
26 Feb 07 |
jari |
1170 |
public void applyLeastSquares() { |
2 |
26 Feb 07 |
jari |
1171 |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
1172 |
LinearEquation linearEquation = getRegressionEquation(true); |
2 |
26 Feb 07 |
jari |
1173 |
|
2 |
26 Feb 07 |
jari |
1174 |
if (normalizedState != SlideData.LEAST_SQUARES) { |
2 |
26 Feb 07 |
jari |
1175 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
1176 |
sde = getSlideDataElement(i); |
2 |
26 Feb 07 |
jari |
1177 |
if (sde != null) { |
2 |
26 Feb 07 |
jari |
1178 |
sde.setIntensity(ISlideDataElement.CY5, applyLeastSquares(sde.getTrueIntensity(ISlideDataElement.CY5), linearEquation)); |
2 |
26 Feb 07 |
jari |
1179 |
} |
2 |
26 Feb 07 |
jari |
1180 |
} |
2 |
26 Feb 07 |
jari |
1181 |
normalizedState = SlideData.LEAST_SQUARES; |
2 |
26 Feb 07 |
jari |
1182 |
} |
2 |
26 Feb 07 |
jari |
1183 |
} |
2 |
26 Feb 07 |
jari |
1184 |
|
2 |
26 Feb 07 |
jari |
1185 |
/** |
2 |
26 Feb 07 |
jari |
* Applies least squares normalization. |
2 |
26 Feb 07 |
jari |
1187 |
*/ |
2 |
26 Feb 07 |
jari |
1188 |
public float applyLeastSquares(float value, LinearEquation linearEquation) { |
2 |
26 Feb 07 |
jari |
1189 |
if (value > 0) { |
2 |
26 Feb 07 |
jari |
1190 |
return(float)((value-linearEquation.getYIntercept())*(1 / linearEquation.getSlope())); |
2 |
26 Feb 07 |
jari |
1191 |
} else |
2 |
26 Feb 07 |
jari |
1192 |
return 0f; |
2 |
26 Feb 07 |
jari |
1193 |
} |
2 |
26 Feb 07 |
jari |
1194 |
|
2 |
26 Feb 07 |
jari |
1195 |
|
2 |
26 Feb 07 |
jari |
1196 |
|
2 |
26 Feb 07 |
jari |
1197 |
public void output() { |
2 |
26 Feb 07 |
jari |
1198 |
String contents = ""; |
2 |
26 Feb 07 |
jari |
1199 |
try { |
2 |
26 Feb 07 |
jari |
1200 |
contents = "\n\n\n***SlideData***\n\n"; |
2 |
26 Feb 07 |
jari |
1201 |
for (int i = 0; i < size(); i++) { |
2 |
26 Feb 07 |
jari |
1202 |
contents += getSlideDataElement(i).toString() + "\n"; |
2 |
26 Feb 07 |
jari |
1203 |
} |
2 |
26 Feb 07 |
jari |
1204 |
} catch (Exception e) { |
2 |
26 Feb 07 |
jari |
1205 |
; |
2 |
26 Feb 07 |
jari |
1206 |
} |
2 |
26 Feb 07 |
jari |
1207 |
System.out.println(contents); |
2 |
26 Feb 07 |
jari |
1208 |
} |
2 |
26 Feb 07 |
jari |
1209 |
|
2 |
26 Feb 07 |
jari |
1210 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the slide name keys. |
2 |
26 Feb 07 |
jari |
1212 |
*/ |
2 |
26 Feb 07 |
jari |
1213 |
public Vector getSlideDataKeys() { |
2 |
26 Feb 07 |
jari |
1214 |
return this.sampleLabelKeys; |
2 |
26 Feb 07 |
jari |
1215 |
} |
2 |
26 Feb 07 |
jari |
1216 |
|
2 |
26 Feb 07 |
jari |
1217 |
/** |
2 |
26 Feb 07 |
jari |
* Returns the slide name keys and pairs |
2 |
26 Feb 07 |
jari |
1219 |
*/ |
2 |
26 Feb 07 |
jari |
1220 |
public Hashtable getSlideDataLabels() { |
2 |
26 Feb 07 |
jari |
1221 |
return this.sampleLabels; |
2 |
26 Feb 07 |
jari |
1222 |
} |
2 |
26 Feb 07 |
jari |
1223 |
|
2 |
26 Feb 07 |
jari |
/** Sets the current label index. |
2 |
26 Feb 07 |
jari |
1225 |
*/ |
2 |
26 Feb 07 |
jari |
1226 |
public void setDataLabelKey(String key) { |
2 |
26 Feb 07 |
jari |
1227 |
this.sampleLabelKey = key; |
2 |
26 Feb 07 |
jari |
1228 |
} |
2 |
26 Feb 07 |
jari |
1229 |
|
2 |
26 Feb 07 |
jari |
/** Adds a new key and label value |
2 |
26 Feb 07 |
jari |
1231 |
*/ |
2 |
26 Feb 07 |
jari |
1232 |
public void addNewSampleLabel(String label, String value) { |
2 |
26 Feb 07 |
jari |
1233 |
if(!sampleLabelKeys.contains(label)) |
2 |
26 Feb 07 |
jari |
1234 |
this.sampleLabelKeys.addElement(label); |
2 |
26 Feb 07 |
jari |
1235 |
this.sampleLabels.put(label, value); |
2 |
26 Feb 07 |
jari |
1236 |
} |
2 |
26 Feb 07 |
jari |
1237 |
|
2 |
26 Feb 07 |
jari |
/** Returns the detection status for the gene specified, Affy support |
2 |
26 Feb 07 |
jari |
1239 |
*/ |
2 |
26 Feb 07 |
jari |
1240 |
public String getDetection(int row) { |
2 |
26 Feb 07 |
jari |
1241 |
return this.getSlideDataElement(row).getDetection(); |
2 |
26 Feb 07 |
jari |
1242 |
} |
2 |
26 Feb 07 |
jari |
1243 |
public Object clone(){ |
2 |
26 Feb 07 |
jari |
1244 |
return this.clone(); |
2 |
26 Feb 07 |
jari |
1245 |
} |
2 |
26 Feb 07 |
jari |
//wwang add for affy p-value filter |
2 |
26 Feb 07 |
jari |
1247 |
public float getPvalue(int row) { |
2 |
26 Feb 07 |
jari |
1248 |
return this.getSlideDataElement(row).getPvalue(); |
2 |
26 Feb 07 |
jari |
1249 |
} |
2 |
26 Feb 07 |
jari |
1250 |
public int getGenePixFlags(int row) { |
2 |
26 Feb 07 |
jari |
1251 |
return this.getSlideDataElement(row).getGenePixFlags(); |
2 |
26 Feb 07 |
jari |
1252 |
} |
2 |
26 Feb 07 |
jari |
1253 |
|
2 |
26 Feb 07 |
jari |
1254 |
|
2 |
26 Feb 07 |
jari |
1255 |
/** |
2 |
26 Feb 07 |
jari |
* CGH IFeatureData implemetations |
2 |
26 Feb 07 |
jari |
* Raktim Oct 31, 2005 |
2 |
26 Feb 07 |
jari |
1258 |
*/ |
2 |
26 Feb 07 |
jari |
1259 |
|
2 |
26 Feb 07 |
jari |
1260 |
/** |
2 |
26 Feb 07 |
jari |
* Raktim, CGH |
2 |
26 Feb 07 |
jari |
* Setter for property flankingRegions. |
2 |
26 Feb 07 |
jari |
* @param flankingRegions New value of property flankingRegions. |
2 |
26 Feb 07 |
jari |
1264 |
*/ |
2 |
26 Feb 07 |
jari |
1265 |
public void setFlankingRegions(java.util.Vector[] flankingRegions) { |
2 |
26 Feb 07 |
jari |
//System.out.println("SlideData setFlankingRegion()"); |
2 |
26 Feb 07 |
jari |
1267 |
if (flankingRegions == null) System.out.println("NULL flankingRegions in SlideData.setFlankingRegion()"); |
2 |
26 Feb 07 |
jari |
1268 |
this.flankingRegions = flankingRegions; |
2 |
26 Feb 07 |
jari |
1269 |
} |
2 |
26 Feb 07 |
jari |
1270 |
|
2 |
26 Feb 07 |
jari |
1271 |
/** |
2 |
26 Feb 07 |
jari |
* Raktim, CGH |
2 |
26 Feb 07 |
jari |
1273 |
*/ |
2 |
26 Feb 07 |
jari |
1274 |
public int getNumFlankingRegions(int chromosomeIndex){ |
2 |
26 Feb 07 |
jari |
1275 |
if (flankingRegions == null) System.out.println("NULL flankingRegions in SlideData"); |
2 |
26 Feb 07 |
jari |
1276 |
return flankingRegions[chromosomeIndex].size(); |
2 |
26 Feb 07 |
jari |
1277 |
} |
2 |
26 Feb 07 |
jari |
1278 |
|
2 |
26 Feb 07 |
jari |
1279 |
/** |
2 |
26 Feb 07 |
jari |
* Raktim, CGH |
2 |
26 Feb 07 |
jari |
* Getter for property flankingRegions. |
2 |
26 Feb 07 |
jari |
* @return Value of property flankingRegions. |
2 |
26 Feb 07 |
jari |
1283 |
*/ |
2 |
26 Feb 07 |
jari |
1284 |
public java.util.Vector[] getFlankingRegions() { |
2 |
26 Feb 07 |
jari |
1285 |
return this.flankingRegions; |
2 |
26 Feb 07 |
jari |
1286 |
} |
2 |
26 Feb 07 |
jari |
1287 |
|
2 |
26 Feb 07 |
jari |
1288 |
/** |
2 |
26 Feb 07 |
jari |
* Raktim, CGH |
2 |
26 Feb 07 |
jari |
* Remember to fix this later |
2 |
26 Feb 07 |
jari |
1291 |
*/ |
2 |
26 Feb 07 |
jari |
1292 |
public boolean isMissingData(int cloneIndex){ |
2 |
26 Feb 07 |
jari |
1293 |
|
2 |
26 Feb 07 |
jari |
1294 |
if(Float.isNaN(getCY3(cloneIndex)) || Float.isNaN(getCY5(cloneIndex))) |
2 |
26 Feb 07 |
jari |
1295 |
return true; |
2 |
26 Feb 07 |
jari |
1296 |
return false; |
2 |
26 Feb 07 |
jari |
/* Old Abramson Code. |
2 |
26 Feb 07 |
jari |
* Remember to Get Back to this Later |
2 |
26 Feb 07 |
jari |
Iterator it = cy3Slides.iterator(); |
2 |
26 Feb 07 |
jari |
boolean cy3Missing = true; |
2 |
26 Feb 07 |
jari |
boolean cy5Missing = true; |
2 |
26 Feb 07 |
jari |
while(it.hasNext()){ |
2 |
26 Feb 07 |
jari |
CGHSlideData slideData = (CGHSlideData)it.next(); |
2 |
26 Feb 07 |
jari |
if(! Float.isNaN(slideData.getRatio(cloneIndex))){ |
2 |
26 Feb 07 |
jari |
cy3Missing = false; |
2 |
26 Feb 07 |
jari |
1306 |
} |
2 |
26 Feb 07 |
jari |
1307 |
} |
2 |
26 Feb 07 |
jari |
if(cy3Missing){ |
2 |
26 Feb 07 |
jari |
return true; |
2 |
26 Feb 07 |
jari |
1310 |
} |
2 |
26 Feb 07 |
jari |
1311 |
|
2 |
26 Feb 07 |
jari |
it = cy5Slides.iterator(); |
2 |
26 Feb 07 |
jari |
while(it.hasNext()){ |
2 |
26 Feb 07 |
jari |
CGHSlideData slideData = (CGHSlideData)it.next(); |
2 |
26 Feb 07 |
jari |
if(! Float.isNaN(slideData.getRatio(cloneIndex))){ |
2 |
26 Feb 07 |
jari |
cy5Missing = false; |
2 |
26 Feb 07 |
jari |
1317 |
} |
2 |
26 Feb 07 |
jari |
1318 |
} |
2 |
26 Feb 07 |
jari |
if(cy5Missing){ |
2 |
26 Feb 07 |
jari |
return true; |
2 |
26 Feb 07 |
jari |
1321 |
} |
2 |
26 Feb 07 |
jari |
1322 |
*/ |
2 |
26 Feb 07 |
jari |
1323 |
} |
2 |
26 Feb 07 |
jari |
1324 |
/** |
2 |
26 Feb 07 |
jari |
1325 |
* |
2 |
26 Feb 07 |
jari |
*@deprecated |
2 |
26 Feb 07 |
jari |
1327 |
|
2 |
26 Feb 07 |
jari |
public void writeAnnotation(DataOutputStream dos, JFrame pb) throws IOException { |
2 |
26 Feb 07 |
jari |
StateSavingProgressPanel progressPanel = (StateSavingProgressPanel)pb; |
2 |
26 Feb 07 |
jari |
int numSlideDataElements = allSlideDataElements.size(); |
2 |
26 Feb 07 |
jari |
progressPanel.setMaximum(numSlideDataElements); |
2 |
26 Feb 07 |
jari |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
dos.writeInt(numSlideDataElements); |
2 |
26 Feb 07 |
jari |
1334 |
|
2 |
26 Feb 07 |
jari |
for(int i=0; i<numSlideDataElements; i++){ |
2 |
26 Feb 07 |
jari |
sde = (ISlideDataElement)allSlideDataElements.get(i); |
2 |
26 Feb 07 |
jari |
1337 |
|
2 |
26 Feb 07 |
jari |
String uid = sde.getUID(); |
2 |
26 Feb 07 |
jari |
char[] temp = uid.toCharArray(); |
2 |
26 Feb 07 |
jari |
dos.writeInt(temp.length); |
2 |
26 Feb 07 |
jari |
for(int j=0; j<temp.length; j++){ |
2 |
26 Feb 07 |
jari |
dos.writeChar(temp[j]); |
2 |
26 Feb 07 |
jari |
1343 |
} |
2 |
26 Feb 07 |
jari |
1344 |
|
2 |
26 Feb 07 |
jari |
int rowsize = sde.getRows().length; |
2 |
26 Feb 07 |
jari |
dos.writeInt(rowsize); |
2 |
26 Feb 07 |
jari |
for(int j=0; j<rowsize; j++){ |
2 |
26 Feb 07 |
jari |
dos.writeInt(sde.getRows()[j]); |
2 |
26 Feb 07 |
jari |
1349 |
} |
2 |
26 Feb 07 |
jari |
int colsize = sde.getColumns().length; |
2 |
26 Feb 07 |
jari |
dos.writeInt(colsize); |
2 |
26 Feb 07 |
jari |
for(int j=0; j<colsize; j++){ |
2 |
26 Feb 07 |
jari |
dos.writeInt(sde.getColumns()[j]); |
2 |
26 Feb 07 |
jari |
1354 |
} |
2 |
26 Feb 07 |
jari |
1355 |
|
2 |
26 Feb 07 |
jari |
int numFields = sde.getExtraFields().length; |
2 |
26 Feb 07 |
jari |
dos.writeInt(numFields); |
2 |
26 Feb 07 |
jari |
for(int j=0; j<numFields; j++){ |
2 |
26 Feb 07 |
jari |
try { |
2 |
26 Feb 07 |
jari |
temp = sde.getExtraFields()[j].toCharArray(); |
2 |
26 Feb 07 |
jari |
dos.writeInt(temp.length); |
2 |
26 Feb 07 |
jari |
for(int k=0; k<temp.length; k++){ |
2 |
26 Feb 07 |
jari |
dos.writeChar(temp[k]); |
2 |
26 Feb 07 |
jari |
1364 |
} |
2 |
26 Feb 07 |
jari |
} catch (NullPointerException npe){ |
2 |
26 Feb 07 |
jari |
dos.writeInt(0); |
2 |
26 Feb 07 |
jari |
1367 |
} |
2 |
26 Feb 07 |
jari |
1368 |
} |
2 |
26 Feb 07 |
jari |
1369 |
|
2 |
26 Feb 07 |
jari |
dos.writeBoolean(sde.getIsNull()); |
2 |
26 Feb 07 |
jari |
dos.writeBoolean(sde.isNonZero()); |
2 |
26 Feb 07 |
jari |
if(dataType == IData.DATA_TYPE_TWO_INTENSITY || dataType == IData.DATA_TYPE_RATIO_ONLY){ |
2 |
26 Feb 07 |
jari |
1373 |
|
2 |
26 Feb 07 |
jari |
} else { //IData has affy data |
2 |
26 Feb 07 |
jari |
dos.writeChar(((AffySlideDataElement)sde).getDetection().charAt(0)); |
2 |
26 Feb 07 |
jari |
1376 |
} |
2 |
26 Feb 07 |
jari |
progressPanel.increment(); |
2 |
26 Feb 07 |
jari |
1378 |
} |
2 |
26 Feb 07 |
jari |
1379 |
|
2 |
26 Feb 07 |
jari |
1380 |
} |
2 |
26 Feb 07 |
jari |
1381 |
*/ |
2 |
26 Feb 07 |
jari |
1382 |
/** |
2 |
26 Feb 07 |
jari |
* @deprecated |
2 |
26 Feb 07 |
jari |
1384 |
|
2 |
26 Feb 07 |
jari |
public void loadAnnotation(DataInputStream dis) throws IOException { |
2 |
26 Feb 07 |
jari |
int numSlideDataElements = dis.readInt(); |
2 |
26 Feb 07 |
jari |
allSlideDataElements = new Vector(numSlideDataElements); |
2 |
26 Feb 07 |
jari |
1388 |
|
2 |
26 Feb 07 |
jari |
int[] rows, cols; |
2 |
26 Feb 07 |
jari |
String[] extraFields; |
2 |
26 Feb 07 |
jari |
String uid; |
2 |
26 Feb 07 |
jari |
int temp; |
2 |
26 Feb 07 |
jari |
boolean isNull, isNonZero; |
2 |
26 Feb 07 |
jari |
for(int i=0; i<numSlideDataElements; i++){ |
2 |
26 Feb 07 |
jari |
1395 |
|
2 |
26 Feb 07 |
jari |
temp = dis.readInt(); |
2 |
26 Feb 07 |
jari |
char[] buff = new char[temp]; |
2 |
26 Feb 07 |
jari |
for(int j=0; j<temp; j++) { |
2 |
26 Feb 07 |
jari |
buff[j] = dis.readChar(); |
2 |
26 Feb 07 |
jari |
1400 |
} |
2 |
26 Feb 07 |
jari |
uid = new String(buff); |
2 |
26 Feb 07 |
jari |
1402 |
|
2 |
26 Feb 07 |
jari |
rows = new int[dis.readInt()]; |
2 |
26 Feb 07 |
jari |
for(int j=0; j<rows.length; j++){ |
2 |
26 Feb 07 |
jari |
rows[j] = dis.readInt(); |
2 |
26 Feb 07 |
jari |
1406 |
} |
2 |
26 Feb 07 |
jari |
1407 |
|
2 |
26 Feb 07 |
jari |
cols = new int[dis.readInt()]; |
2 |
26 Feb 07 |
jari |
for(int j=0; j<cols.length; j++){ |
2 |
26 Feb 07 |
jari |
cols[j] = dis.readInt(); |
2 |
26 Feb 07 |
jari |
1411 |
} |
2 |
26 Feb 07 |
jari |
1412 |
|
2 |
26 Feb 07 |
jari |
extraFields = new String[dis.readInt()]; |
2 |
26 Feb 07 |
jari |
for(int j=0; j<extraFields.length; j++){ |
2 |
26 Feb 07 |
jari |
buff = new char[dis.readInt()]; |
2 |
26 Feb 07 |
jari |
for(int k=0; k<buff.length; k++){ |
2 |
26 Feb 07 |
jari |
buff[k] = dis.readChar(); |
2 |
26 Feb 07 |
jari |
1418 |
} |
2 |
26 Feb 07 |
jari |
extraFields[j] = new String(buff); |
2 |
26 Feb 07 |
jari |
1420 |
} |
2 |
26 Feb 07 |
jari |
isNull = dis.readBoolean(); |
2 |
26 Feb 07 |
jari |
isNonZero = dis.readBoolean(); |
2 |
26 Feb 07 |
jari |
if(dataType == IData.DATA_TYPE_TWO_INTENSITY || dataType == IData.DATA_TYPE_RATIO_ONLY){ |
2 |
26 Feb 07 |
jari |
allSlideDataElements.add(i, new SlideDataElement(rows, cols, extraFields, uid, isNull, isNonZero)); |
2 |
26 Feb 07 |
jari |
} else { //IData has affy data |
2 |
26 Feb 07 |
jari |
char detection = dis.readChar(); |
2 |
26 Feb 07 |
jari |
allSlideDataElements.add(i, new AffySlideDataElement(rows, cols, extraFields, uid, isNull, isNonZero, detection)); |
2 |
26 Feb 07 |
jari |
1428 |
|
2 |
26 Feb 07 |
jari |
1429 |
} |
2 |
26 Feb 07 |
jari |
1430 |
} |
2 |
26 Feb 07 |
jari |
1431 |
|
2 |
26 Feb 07 |
jari |
1432 |
}*/ |
2 |
26 Feb 07 |
jari |
1433 |
/* |
2 |
26 Feb 07 |
jari |
* @deprecated |
2 |
26 Feb 07 |
jari |
1435 |
|
2 |
26 Feb 07 |
jari |
public void loadAnnotation(DataInputStream dis, JFrame pb) throws IOException { |
2 |
26 Feb 07 |
jari |
StateSavingProgressPanel progressPanel = (StateSavingProgressPanel)pb; |
2 |
26 Feb 07 |
jari |
int numSlideDataElements = dis.readInt(); |
2 |
26 Feb 07 |
jari |
progressPanel.setMaximum(numSlideDataElements); |
2 |
26 Feb 07 |
jari |
allSlideDataElements = new Vector(numSlideDataElements); |
2 |
26 Feb 07 |
jari |
1441 |
|
2 |
26 Feb 07 |
jari |
int[] rows, cols; |
2 |
26 Feb 07 |
jari |
String[] extraFields; |
2 |
26 Feb 07 |
jari |
String uid; |
2 |
26 Feb 07 |
jari |
int temp; |
2 |
26 Feb 07 |
jari |
boolean isNull, isNonZero; |
2 |
26 Feb 07 |
jari |
for(int i=0; i<numSlideDataElements; i++){ |
2 |
26 Feb 07 |
jari |
1448 |
|
2 |
26 Feb 07 |
jari |
temp = dis.readInt(); |
2 |
26 Feb 07 |
jari |
char[] buff = new char[temp]; |
2 |
26 Feb 07 |
jari |
for(int j=0; j<temp; j++) { |
2 |
26 Feb 07 |
jari |
buff[j] = dis.readChar(); |
2 |
26 Feb 07 |
jari |
1453 |
} |
2 |
26 Feb 07 |
jari |
uid = new String(buff); |
2 |
26 Feb 07 |
jari |
1455 |
|
2 |
26 Feb 07 |
jari |
rows = new int[dis.readInt()]; |
2 |
26 Feb 07 |
jari |
for(int j=0; j<rows.length; j++){ |
2 |
26 Feb 07 |
jari |
rows[j] = dis.readInt(); |
2 |
26 Feb 07 |
jari |
1459 |
} |
2 |
26 Feb 07 |
jari |
1460 |
|
2 |
26 Feb 07 |
jari |
cols = new int[dis.readInt()]; |
2 |
26 Feb 07 |
jari |
for(int j=0; j<cols.length; j++){ |
2 |
26 Feb 07 |
jari |
cols[j] = dis.readInt(); |
2 |
26 Feb 07 |
jari |
1464 |
} |
2 |
26 Feb 07 |
jari |
1465 |
|
2 |
26 Feb 07 |
jari |
extraFields = new String[dis.readInt()]; |
2 |
26 Feb 07 |
jari |
for(int j=0; j<extraFields.length; j++){ |
2 |
26 Feb 07 |
jari |
buff = new char[dis.readInt()]; |
2 |
26 Feb 07 |
jari |
for(int k=0; k<buff.length; k++){ |
2 |
26 Feb 07 |
jari |
buff[k] = dis.readChar(); |
2 |
26 Feb 07 |
jari |
1471 |
} |
2 |
26 Feb 07 |
jari |
extraFields[j] = new String(buff); |
2 |
26 Feb 07 |
jari |
1473 |
} |
2 |
26 Feb 07 |
jari |
isNull = dis.readBoolean(); |
2 |
26 Feb 07 |
jari |
isNonZero = dis.readBoolean(); |
2 |
26 Feb 07 |
jari |
if(dataType == IData.DATA_TYPE_TWO_INTENSITY || dataType == IData.DATA_TYPE_RATIO_ONLY){ |
2 |
26 Feb 07 |
jari |
allSlideDataElements.add(i, new SlideDataElement(rows, cols, extraFields, uid, isNull, isNonZero)); |
2 |
26 Feb 07 |
jari |
} else { //IData has affy data |
2 |
26 Feb 07 |
jari |
char detection = dis.readChar(); |
2 |
26 Feb 07 |
jari |
allSlideDataElements.add(i, new AffySlideDataElement(rows, cols, extraFields, uid, isNull, isNonZero, detection)); |
2 |
26 Feb 07 |
jari |
1481 |
|
2 |
26 Feb 07 |
jari |
1482 |
} |
2 |
26 Feb 07 |
jari |
progressPanel.increment(); |
2 |
26 Feb 07 |
jari |
1484 |
} |
2 |
26 Feb 07 |
jari |
1485 |
|
2 |
26 Feb 07 |
jari |
1486 |
}*/ |
2 |
26 Feb 07 |
jari |
1487 |
|
2 |
26 Feb 07 |
jari |
1488 |
|
2 |
26 Feb 07 |
jari |
1489 |
/** |
2 |
26 Feb 07 |
jari |
1490 |
* |
2 |
26 Feb 07 |
jari |
* @param dos |
2 |
26 Feb 07 |
jari |
* @throws IOException |
2 |
26 Feb 07 |
jari |
* @deprecated |
2 |
26 Feb 07 |
jari |
1494 |
|
2 |
26 Feb 07 |
jari |
public void writeIntensities(DataOutputStream dos) throws IOException { |
2 |
26 Feb 07 |
jari |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
int numSlideDataElements = size(); |
2 |
26 Feb 07 |
jari |
dos.writeInt(numSlideDataElements); |
2 |
26 Feb 07 |
jari |
for(int i=0; i<numSlideDataElements; i++){ |
2 |
26 Feb 07 |
jari |
sde = (ISlideDataElement)allSlideDataElements.get(i); |
2 |
26 Feb 07 |
jari |
dos.writeFloat(sde.getIntensity(0)); |
2 |
26 Feb 07 |
jari |
dos.writeFloat(sde.getIntensity(1)); |
2 |
26 Feb 07 |
jari |
dos.writeFloat(sde.getTrueIntensity(0)); |
2 |
26 Feb 07 |
jari |
dos.writeFloat(sde.getTrueIntensity(1)); |
2 |
26 Feb 07 |
jari |
if(dataType != IData.DATA_TYPE_TWO_INTENSITY && dataType != IData.DATA_TYPE_RATIO_ONLY){ |
2 |
26 Feb 07 |
jari |
dos.writeChar(sde.getDetection().toCharArray()[0]); |
2 |
26 Feb 07 |
jari |
1507 |
} |
2 |
26 Feb 07 |
jari |
1508 |
} |
2 |
26 Feb 07 |
jari |
1509 |
} */ |
2 |
26 Feb 07 |
jari |
//TODO remove |
2 |
26 Feb 07 |
jari |
1511 |
/* |
2 |
26 Feb 07 |
jari |
public void loadIntensities(DataInputStream dis) throws IOException{ |
2 |
26 Feb 07 |
jari |
ISlideDataElement sde; |
2 |
26 Feb 07 |
jari |
int numSlideDataElements = dis.readInt(); |
2 |
26 Feb 07 |
jari |
for(int i=0; i<numSlideDataElements; i++){ |
2 |
26 Feb 07 |
jari |
sde = (ISlideDataElement)allSlideDataElements.get(i); |
2 |
26 Feb 07 |
jari |
sde.setIntensity(0, dis.readFloat()); |
2 |
26 Feb 07 |
jari |
sde.setIntensity(1, dis.readFloat()); |
2 |
26 Feb 07 |
jari |
sde.setTrueIntensity(0, dis.readFloat()); |
2 |
26 Feb 07 |
jari |
sde.setTrueIntensity(1, dis.readFloat()); |
2 |
26 Feb 07 |
jari |
if(dataType != IData.DATA_TYPE_TWO_INTENSITY && dataType != IData.DATA_TYPE_RATIO_ONLY){ |
2 |
26 Feb 07 |
jari |
sde.setDetection(new Character(dis.readChar()).toString()); |
2 |
26 Feb 07 |
jari |
1523 |
} |
2 |
26 Feb 07 |
jari |
1524 |
} |
2 |
26 Feb 07 |
jari |
1525 |
}*/ |
2 |
26 Feb 07 |
jari |
1526 |
} |