Changeset 252
- Timestamp:
- Apr 10, 2007, 4:40:47 PM (16 years ago)
- Location:
- trunk/se/lu/onk/OneClass/src/oneclass/rankproduct
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/se/lu/onk/OneClass/src/oneclass/rankproduct/RankProduct.java
r246 r252 24 24 package oneclass.rankproduct; 25 25 26 import java.io.File; 27 import java.io.IOException; 28 import java.io.PrintWriter; 29 import java.text.DecimalFormat; 26 30 import java.util.Comparator; 27 31 import java.util.List; 32 33 import basefile.BASEFile; 34 import basefile.BASEFileAssaySection; 35 import basefile.BASEFileException; 28 36 import basefile.BASEFileSpotSection; 29 37 30 38 public class RankProduct 31 39 { 32 public void calculate(BASEFileSpotSection<Reporter, Spot> bfss, boolean up) 33 { 34 for (int i = 0; i < bfss.getWidth(); ++i) 35 { 36 // to be able use i in the comparator it has to be final 37 final int finali = i; 38 final boolean finalup = up; 39 40 bfss.sortReporter(new Comparator<Reporter>() 41 { 42 public int compare(Reporter r1, Reporter r2) 43 { 44 double s1 = r1.getSpot(finali).getM(); 45 double s2 = r2.getSpot(finali).getM(); 46 47 int ret = 0; 48 if (!Double.isNaN(s1) && !Double.isNaN(s2)) 49 { 50 ret = Double.compare(s1, s2); 51 if (finalup) 52 ret *= -1; 53 } 54 else if (Double.isNaN(s1) && Double.isNaN(s2)) 55 ret = 0; 56 else if (Double.isNaN(s1)) 57 ret = 1; 58 else if (Double.isNaN(s2)) 59 ret = -1; 60 return ret; 61 } 62 }); 63 64 // set the rank 40 private final File dataFolder; 41 42 private final BASEFile<Reporter, Spot> basefile; 43 44 private final BASEFile<ReporterOut, SpotOut> basefileOut; 45 46 private final BASEFileSpotSection<Reporter, Spot> bfss; 47 48 private final BASEFileSpotSection<ReporterOut, SpotOut> bfssOutDown; 49 50 private final BASEFileSpotSection<ReporterOut, SpotOut> bfssOutUp; 51 52 public RankProduct(BASEFile<Reporter, Spot> basefile) throws BASEFileException 53 { 54 dataFolder = new File("lib"); 55 dataFolder.mkdir(); 56 57 this.basefile = basefile; 58 readAssaySection(); 59 readSpotSection(); 60 bfss = this.basefile.getSpotSection(); 61 62 this.basefileOut = new BASEFile<ReporterOut, SpotOut>(new File("stdout.txt"), "rw"); 63 BASEFileSpotSection<Reporter, Spot> bfss = this.basefile.getSpotSection(); 64 BASEFileAssaySection bfas = new BASEFileAssaySection(); 65 bfas.setAnnotationColumns(""); 66 bfas.setColumns("id", "name", "parents"); 67 bfas.setCount(2); 68 String parents = bfss.findStringOpt("assays").replaceAll("\t", "/"); 69 bfas.addData("1", "RankProduct down", parents); 70 bfas.addData("2", "RankProduct up", parents); 71 basefileOut.setAssaySection(bfas); 72 73 bfssOutDown = new BASEFileSpotSection<ReporterOut, SpotOut>(); 74 bfssOutDown.setChannels(2); 75 bfssOutDown.setExtraFloats("JE_nbrOfElements", "JE_rank", "JE_rankProduct"); 76 bfssOutDown.setAssayFields("l2ratio1_2", "l10intgmean1_2", "JE_nbrOfElements", "JE_rank", "JE_rankProduct"); 77 bfssOutDown.setColumns("position", "reporter", "assayData"); 78 bfssOutDown.setAssays(1); 79 bfssOutDown.setCount(bfss.getCount()); 80 basefileOut.addSpotSection(bfssOutDown); 81 82 bfssOutUp = new BASEFileSpotSection<ReporterOut, SpotOut>(bfssOutDown); 83 bfssOutUp.setAssays(2); 84 basefileOut.addSpotSection(bfssOutUp); 85 } 86 87 public void calculate() throws BASEFileException 88 { 89 ReporterComparator comp = new ReporterComparator(); 90 calculateRank(reverse(comp)); 91 calculateRankProduct(bfssOutDown); 92 calculateRank(comp); 93 calculateRankProduct(bfssOutUp); 94 } 95 96 private void calculateRank(ReporterComparator comp) 97 { 98 for (int i = 0; i < bfss.getAssays().size(); ++i) 99 { 100 comp.setSpot(i); 101 bfss.sortReporter(comp); 102 int count = countAssay(bfss, i); 103 int rank = 1; 65 104 for (int j = 0; j < bfss.getHeight(); ++j) 66 105 { … … 68 107 if (!Double.isNaN(s.getM())) 69 108 { 70 s.setRank(j+1); 109 s.setRank((double) rank / (double) count); 110 ++rank; 71 111 } 72 } 112 else 113 { 114 s.setRank(Double.NaN); 115 } 116 } 117 } 118 } 119 120 private void calculateRankProduct(BASEFileSpotSection<ReporterOut, SpotOut> bfssOut) throws BASEFileException 121 { 122 bfss.sortReporter(new Comparator<Reporter>() 123 { 124 public int compare(Reporter r1, Reporter r2) 125 { 126 return Double.compare(r1.getRankProduct(), r2.getRankProduct()); 127 } 128 }); 129 for (int i = 0; i < bfss.getHeight(); ++i) 130 { 131 Reporter r = bfss.getReporter(i); 132 SpotOut sOut = new SpotOut((float)r.getM(), (float)r.getM(), r.getSize(), i+1, (float)r.getRankProduct()); 133 ReporterOut rOut = new ReporterOut(r, sOut); 134 bfssOut.addData(rOut, sOut); 135 } 136 } 137 138 public void printTab() throws BASEFileException 139 { 140 bfss.sortReporter(new Comparator<Reporter>() 141 { 142 public int compare(Reporter r1, Reporter r2) 143 { 144 return Double.compare(r1.getRankProduct(), r2.getRankProduct()); 145 } 146 }); 147 148 writeTabFile(basefileOut.getSpotSection(0), new File(dataFolder, "resultUP.csv")); 149 writeTabFile(basefileOut.getSpotSection(1), new File(dataFolder, "resultDOWN.csv")); 150 } 151 152 private void writeTabFile(BASEFileSpotSection<ReporterOut, SpotOut> bfss, File file) throws BASEFileException 153 { 154 try 155 { 156 PrintWriter tab = new PrintWriter(file); 157 158 List<Integer> assays = this.bfss.getAssays(); 159 String[] tableRow = new String[8 + 2 * basefile.getAssaySection().getCount()]; 160 tableRow[0] = "Reporter"; 161 tableRow[1] = "GeneSymbol"; 162 tableRow[2] = "LocusLink"; 163 tableRow[3] = "AverageM"; 164 tableRow[4] = "up/down"; 165 tableRow[5] = "Rank"; 166 tableRow[6] = "Rank product"; 167 tableRow[7] = "NumberOfValues"; 168 for (int i = 0; i < assays.size(); ++i) 169 { 170 int assay = assays.get(i); 171 tableRow[8 + i] = "log-ratio " + basefile.getAssaySection().getAssayName(assay); 172 tableRow[8 + i + assays.size()] = "rank " + basefile.getAssaySection().getAssayName(assay); 173 } 174 tab.println(formatArray("", "", "\t", tableRow)); 175 176 for (int i = 0; i < bfss.getHeight(); i++) 177 { 178 ReporterOut r = bfss.getReporter(i); 179 SpotOut s = r.getSpot(); 180 tableRow[0] = String.valueOf(r.getId()); 181 tableRow[1] = r.getSymbol(); 182 tableRow[2] = r.getLocusLink(); 183 tableRow[3] = String.valueOf(s.getM()); 184 tableRow[4] = s.getM() > 0 ? "+" : "-"; 185 tableRow[5] = String.valueOf(s.getRank()); 186 tableRow[6] = String.valueOf(s.getRankProduct()); 187 tableRow[7] = String.valueOf(s.getNbrOfElements()); 188 for (int j = 0; j < assays.size(); ++j) 189 { 190 Spot ss = r.getReporter().getSpot(j); 191 tableRow[8 + j] = String.valueOf(ss.getM()); 192 tableRow[8 + j + assays.size()] = String.valueOf(ss.getRank()); 193 } 194 tab.println(formatArray("", "", "\t", tableRow)); 195 } 196 tab.close(); 197 } 198 catch (IOException e) 199 { 200 throw new BASEFileException(e); 201 } 202 } 203 204 public void printHTML() throws BASEFileException 205 { 206 bfss.sortReporter(new Comparator<Reporter>() 207 { 208 public int compare(Reporter r1, Reporter r2) 209 { 210 return Double.compare(r1.getRankProduct(), r2.getRankProduct()); 211 } 212 }); 213 214 writeHTMLFile(basefileOut.getSpotSection(0), new File(dataFolder, "resultUP.html")); 215 writeHTMLFile(basefileOut.getSpotSection(1), new File(dataFolder, "resultDOWN.html")); 216 } 217 218 private void writeHTMLFile(BASEFileSpotSection<ReporterOut, SpotOut> bfss, File file) throws BASEFileException 219 { 220 try 221 { 222 PrintWriter html = new PrintWriter(file); 223 html.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"); 224 html.println("<html>"); 225 html.println("<head>"); 226 html.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"); 227 html.println("</head>"); 228 html.println("<table>"); 229 230 String[] tableRow = new String[8]; 231 tableRow[0] = "Reporter"; 232 tableRow[1] = "GeneSymbol"; 233 tableRow[2] = "LocusLink"; 234 tableRow[3] = "AverageM"; 235 tableRow[4] = "up/down"; 236 tableRow[5] = "Rank"; 237 tableRow[6] = "Rank product"; 238 tableRow[7] = "NumberOfValues"; 239 html.println("<tr>" + formatArray("<th>", "</th>", "", tableRow) + "</tr>"); 240 241 DecimalFormat df = new DecimalFormat("# ##0.000"); 242 for (int i = 0; i < 1000 && i < bfss.getHeight(); i++) 243 { 244 ReporterOut r = bfss.getReporter(i); 245 SpotOut s = r.getSpot(); 246 tableRow[0] = String.valueOf(r.getId()); 247 tableRow[1] = r.getSymbol(); 248 tableRow[2] = r.getLocusLink(); 249 tableRow[3] = df.format(s.getM()); 250 tableRow[4] = s.getM() > 0 ? "+" : "-"; 251 tableRow[5] = df.format(s.getRank()); 252 tableRow[6] = df.format(s.getRankProduct()); 253 tableRow[7] = df.format(s.getNbrOfElements()); 254 255 html.println("<tr class=\"row" + (i % 2 + 1) + "\">" + formatArray("<th>", "</th>", "", tableRow) + "</tr>"); 256 } 257 html.println("</table>"); 258 html.print("</html>"); 259 html.close(); 260 } 261 catch (IOException e) 262 { 263 throw new BASEFileException(e); 264 } 265 } 266 267 public void printBASE() throws BASEFileException 268 { 269 basefileOut.write(); 270 } 271 272 private int countAssay(BASEFileSpotSection<Reporter, Spot> bfss, int i) 273 { 274 int count = 0; 275 for (int j = 0; j < bfss.getReporterSize(); ++j) 276 { 277 Spot s = bfss.getReporter(j).getSpot(i); 278 if (!Double.isNaN(s.getM())) 279 { 280 ++count; 281 } 282 } 283 return count; 284 } 285 286 private static Object formatArray(String begin, String end, String del, String... array) 287 { 288 StringBuffer sb = new StringBuffer(); 289 if (array.length > 0) 290 { 291 sb.append(begin + array[0] + end); 292 for (int i = 1; i < array.length; ++i) 293 { 294 sb.append(del); 295 sb.append(begin); 296 sb.append(array[i]); 297 sb.append(end); 298 } 299 } 300 return sb; 301 } 302 303 private void readAssaySection() throws BASEFileException 304 { 305 //Read assay section 306 basefile.setCurrentSection(basefile.getAssaySection()); 307 String[] data = basefile.readData(); 308 while (data != null) 309 { 310 basefile.getAssaySection().addData(data); 311 data = basefile.readData(); 312 } 313 } 314 315 private void readSpotSection() throws BASEFileException 316 { 317 //Read spot section 318 BASEFileSpotSection<Reporter, Spot> bfss = basefile.getSpotSection(); 319 320 int mCol = bfss.getAssayFieldsColIndex("l2ratio1_2"); 321 int aCol = bfss.getAssayFieldsColIndex("l10intgmean1_2"); 322 int repCol = bfss.getColumnsColIndex("reporter"); 323 int repidCol = bfss.getColumnsColIndex("reporterId"); 324 int symCol = bfss.getColumnsColIndex("geneSymbol"); 325 int llCol = bfss.getColumnsColIndex("locusLink"); 326 int assayDataCol = bfss.getColumnsColIndex("assayData"); 327 328 mCol += assayDataCol; 329 aCol += assayDataCol; 330 331 int pos = 0; 332 basefile.setCurrentSection(bfss); 333 String[] data = basefile.readData(); 334 while (data != null) 335 { 336 double a = 0; 337 int aCount = 0; 338 Spot[] spots = new Spot[basefile.getAssaySection().getCount()]; 339 for (int i = 0; i < spots.length; i++) 340 { 341 int index = i * bfss.getAssayFields().size(); 342 Double m = Double.NaN; 343 if (!data[mCol + index].equals("")) 344 { 345 m = new Double(data[mCol + index]); 346 } 347 if (!data[aCol + index].equals("")) 348 { 349 a += new Double(data[aCol + index]); 350 ++aCount; 351 } 352 spots[i] = new Spot(m); 353 } 354 Reporter r = new Reporter(--pos, new Integer(data[repCol]), data[repidCol], data[symCol], data[llCol], a/aCount, spots); 355 bfss.addData(r, spots); 356 data = basefile.readData(); 357 } 358 359 basefile.validate(); 360 } 361 362 private ReporterComparator reverse(ReporterComparator comp) 363 { 364 return new ReporterComparator() 365 { 366 @Override 367 public int compare(Reporter r1, Reporter r2) 368 { 369 return super.compare(r2, r1); 370 } 371 372 }; 373 } 374 375 private class ReporterComparator implements Comparator<Reporter> 376 { 377 int i; 378 379 public void setSpot(int i) 380 { 381 this.i = i; 382 } 383 384 /* 385 * Will sort the i'th assay with upregulated first. NaN is 386 * always sorted last. 387 */ 388 public int compare(Reporter r1, Reporter r2) 389 { 390 double s1 = r1.getSpot(i).getM(); 391 double s2 = r2.getSpot(i).getM(); 392 393 int ret = 0; 394 if (!Double.isNaN(s1) && !Double.isNaN(s2)) 395 { 396 ret = Double.compare(s1, s2); 397 } 398 else if (Double.isNaN(s1) && Double.isNaN(s2)) ret = 0; 399 else if (Double.isNaN(s1)) ret = 1; 400 else if (Double.isNaN(s2)) ret = -1; 401 402 return ret; 73 403 } 74 404 } -
trunk/se/lu/onk/OneClass/src/oneclass/rankproduct/Reporter.java
r246 r252 30 30 private final String locusLink; 31 31 private final int id; 32 private final int pos; 32 33 private final Spot[] spots; 33 34 private double a; … … 35 36 private int size = 0;; 36 37 37 public Reporter(int id, String reporter, String symbol, String locusLink, double a, Spot ... spots)38 public Reporter(int pos, int id, String reporter, String symbol, String locusLink, double a, Spot ... spots) 38 39 { 40 this.pos = pos; 39 41 this.id = id; 40 42 this.reporter = reporter; … … 86 88 } 87 89 } 88 89 return Math.pow(rankProduct, 1.0/getSize()); 90 return rankProduct; 90 91 } 91 92 … … 114 115 return size; 115 116 } 117 118 public int getPos() 119 { 120 // TODO Auto-generated method stub 121 return 0; 122 } 116 123 } -
trunk/se/lu/onk/OneClass/src/oneclass/rankproduct/Spot.java
r246 r252 28 28 private double m; 29 29 30 private int rank = -1;30 private double rank = Double.NaN; 31 31 32 32 public Spot(Double m) … … 40 40 } 41 41 42 public final intgetRank()42 public final double getRank() 43 43 { 44 44 return rank; 45 45 } 46 46 47 public final void setRank( intrank)47 public final void setRank(double rank) 48 48 { 49 49 this.rank = rank; -
trunk/se/lu/onk/OneClass/src/oneclass/rankproduct/Start.java
r246 r252 24 24 package oneclass.rankproduct; 25 25 26 import oneclass.plot.HistogramDataset; 27 import oneclass.plot.Plot; 28 29 import org.jfree.data.xy.XYSeries; 30 26 import basefile.BASEFile; 31 27 import basefile.BASEFileException; 32 import basefile.BASEFileReader;33 import basefile.BASEFileSpotSection;34 import basefile.BadFormatException;35 28 36 29 import java.io.File; 37 import java.io.FileNotFoundException;38 import java.io.IOException;39 import java.io.PrintWriter;40 import java.util.Comparator;41 import java.util.List;42 30 43 31 public class Start 44 32 { 45 46 private static RankProduct rankproduct = new RankProduct();47 33 48 34 /** 49 35 * @param args 50 36 */ 51 public static void main(String[] args) 37 public static void main(String[] args) throws BASEFileException 52 38 { 53 BASEFileReader bfr;54 39 try 55 40 { 56 bfr = new BASEFileReader(new File(args.length == 1 ? args[0] : "stdin.txt")); 57 BASEFileSpotSection<Reporter, Spot> bfss = bfr.readSpotSection(); 58 59 List<String> columns = bfss.findFieldList("columns"); 60 List<Integer> assays = bfss.findFieldIntList("assays"); 61 List<String> assayFields = bfss.findFieldList("assayFields"); 62 63 int mCol = assayFields.indexOf("l2ratio1_2"); 64 int aCol = assayFields.indexOf("l10intgmean1_2"); 65 int repCol = columns.indexOf("reporter"); 66 int repidCol = columns.indexOf("reporterId"); 67 int symCol = columns.indexOf("geneSymbol"); 68 int llCol = columns.indexOf("locusLink"); 69 int assayDataCol = columns.indexOf("assayData"); 70 71 if (mCol == -1 || repCol == -1 || repidCol == -1 || symCol == -1 || llCol == -1 || assayDataCol == -1) 72 { 73 throw new BASEFileException("Cant find the columns l2ratio1_2, reporter or assayData"); 74 } 75 mCol += assayDataCol; 76 aCol += assayDataCol; 77 78 int dataLength = columns.size() + assays.size() * assayFields.size() - 1; 79 bfss.setDataMatrix(bfss.findIntOpt("count"), assays.size()); 80 String[] data = bfr.readDataRow(dataLength); 81 while (data != null) 82 { 83 double a = 0; 84 int aCount = 0; 85 Spot[] spots = new Spot[assays.size()]; 86 for (int i = 0; i < assays.size(); i++) 87 { 88 int index = i * assayFields.size(); 89 Double m = Double.NaN; 90 if (!data[mCol + index].equals("")) 91 { 92 m = new Double(data[mCol + index]); 93 } 94 if (!data[aCol + index].equals("")) 95 { 96 a += new Double(data[aCol + index]); 97 ++aCount; 98 } 99 spots[i] = new Spot(m); 100 } 101 Reporter r = new Reporter(new Integer(data[repCol]), data[repidCol], data[symCol], data[llCol], a/aCount, spots); 102 bfss.addData(r, spots); 103 data = bfr.readDataRow(dataLength); 104 } 41 BASEFile<Reporter, Spot> basefile; 42 basefile = new BASEFile<Reporter, Spot>(new File(args.length == 1 ? args[0] : "stdin.txt"), "r"); 105 43 106 System.out.println("BASEfile"); 107 System.out.println("section\tassays"); 108 System.out.println("annotationColumns\t"); 109 System.out.println("columns\tid\tname\tparents"); 110 System.out.println("count\t1"); 111 System.out.println("%"); 112 System.out.println("1\tRankProduct down\t"+bfss.findStringOpt("assays").replaceAll("\t", "/")); 113 System.out.println("2\tRankProduct up\t"+bfss.findStringOpt("assays").replaceAll("\t", "/")); 114 System.out.println(); 115 116 rankproduct.calculate(bfss, false); 117 118 System.out.println("section\tspots"); 119 System.out.println("channels\t2"); 120 System.out.println("setExtraFloats\tJE_nbrOfElements\tJE_rank\tJE_rankProduct"); 121 System.out.println("assayFields\tl2ratio1_2\tl10intgmean1_2\tJJE_nbrOfElements\tJE_rank\tE_rankProduct"); 122 System.out.println("columns\tposition\treporter\tassayData"); 123 System.out.println("assays\t1"); 124 System.out.println("count\t"+bfss.getReporterSize()); 125 System.out.println("%"); 126 127 print(bfss, "down"); 128 129 rankproduct.calculate(bfss, true); 130 131 System.out.println("section\tspots"); 132 System.out.println("channels\t2"); 133 System.out.println("setExtraFloats\tJE_nbrOfElements\tJE_rank\tJE_rankProduct"); 134 System.out.println("assayFields\tl2ratio1_2\tl10intgmean1_2\tJJE_nbrOfElements\tJE_rank\tE_rankProduct"); 135 System.out.println("columns\tposition\treporter\tassayData"); 136 System.out.println("assays\t2"); 137 System.out.println("count\t"+bfss.getReporterSize()); 138 System.out.println("%"); 139 140 print(bfss, "up"); 141 142 } 143 catch (FileNotFoundException e) 144 { 145 System.err.println("Can't find the file " + (args.length == 1 ? args[0] : "stdin.txt")); 146 } 147 catch (BadFormatException e) 148 { 149 System.err.println((args.length == 1 ? args[0] : "stdin.txt") + " is not a basefile"); 150 } 151 catch (IOException e) 152 { 153 System.err.println("An error when reading file " + (args.length == 1 ? args[0] : "stdin.txt")); 154 e.printStackTrace(); 44 RankProduct rankproduct = new RankProduct(basefile); 45 rankproduct.calculate(); 46 rankproduct.printTab(); 47 rankproduct.printHTML(); 48 rankproduct.printBASE(); 49 155 50 } 156 51 catch (BASEFileException e) 157 52 { 158 e.printStackTrace();53 throw e; 159 54 } 160 55 } 161 56 162 private static void print(BASEFileSpotSection<Reporter, Spot> bfss, String prefix)163 {164 try165 {166 bfss.sortReporter(new Comparator<Reporter>()167 {168 public int compare(Reporter r1, Reporter r2)169 {170 return Double.compare(r1.getRankProduct(), r2.getRankProduct());171 }172 });173 XYSeries oSeries = new XYSeries("Observed");174 XYSeries eSeries = new XYSeries("Expected");175 XYSeries fdrSeries = new XYSeries("FDR");176 HistogramDataset mHist = new HistogramDataset("M", 0.1);177 57 178 PrintWriter html = new PrintWriter(new File(prefix+"index.html")); 179 PrintWriter tab = new PrintWriter(new File(prefix+"result.tsv")); 180 181 Object[] tableRow = {"Reporter","GeneSymbol","LocusLink","AverageM","up/down","Rank","Rank product","NumberOfValues"}; 182 183 184 html.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"); 185 html.println("<html>"); 186 html.println("<head>"); 187 html.println("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\" />"); 188 html.println("<title>BASE 1.2.16dev - Experiment Enell:Enell Plugin</title>"); 189 html.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"base.css\" />"); 190 html.println("</head>"); 191 html.println("<table>"); 192 html.printf("<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>\n", tableRow); 193 194 tab.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", tableRow); 195 196 for (int i = 0; i < bfss.getReporterSize(); i++) 197 { 198 int rank = i + 1; 199 Reporter r = bfss.getReporter(i); 200 double rankProduct = r.getRankProduct(); 201 202 System.out.printf("%d\t%d\t", (-1*rank), r.getId()); 203 System.out.printf("%f\t%f\t", r.getM(), r.getA()); 204 System.out.printf("%d\t%d\t%f\n", r.getSize(), rank, rankProduct); 205 206 tableRow[0] = r.getReporter(); 207 tableRow[1] = r.getSymbol(); 208 tableRow[2] = r.getLocusLink(); 209 tableRow[3] = r.getM(); 210 tableRow[4] = r.getM() > 0 ? "+" : "-"; 211 tableRow[5] = rank; 212 tableRow[6] = rankProduct; 213 tableRow[7] = r.getSize(); 214 215 if (i < 1000) 216 { 217 html.printf( 218 "<tr class=\"row" + (i % 2 + 1) + "\"><td>%s</td><td>%s</td><td>%s</td><td>%f</td>" + 219 "<td>%s</td><td>%d</td><td>%f</td><td>%d</td></tr>\n", 220 tableRow); 221 } 222 tab.printf("%s\t%s\t%s\t%f\t%s\t%d\t%f\t%d\n", tableRow); 223 224 oSeries.add(rank, rank); 225 eSeries.add(rank, rankProduct); 58 // private static void print(BASEFileSpotSection<Reporter, Spot> bfss, String prefix) throws BASEFileException 59 // { 60 // XYSeries oSeries = new XYSeries("Observed"); 61 // XYSeries eSeries = new XYSeries("Expected"); 62 // XYSeries fdrSeries = new XYSeries("FDR"); 63 // HistogramDataset mHist = new HistogramDataset("M", 0.1); 64 // 65 // for (int i = 0; i < bfss.getReporterSize(); i++) 66 // { 67 // int rank = i + 1; 68 // Reporter r = bfss.getReporter(i); 69 // double rankProduct = r.getRankProduct(); 70 // 71 // 72 // oSeries.add(rank, rank); 73 // eSeries.add(rank, rankProduct); 226 74 // fdrSeries.add(rank, fdr); 227 mHist.addObservation(r.getM()); 228 } 229 System.out.println(); 230 231 html.println("</table>"); 232 html.print("</html>"); 233 html.close(); 234 235 tab.close(); 236 75 // mHist.addObservation(r.getM()); 76 // } 77 // 237 78 // Plot.plotFDR(fdrSeries); 238 79 // Plot.plotOE(oSeries, eSeries); 239 80 // Plot.plotOE_FDR(oSeries, eSeries, fdrSeries); 240 81 // Plot.plotMHist(mHist, ztest.getTotalMean(), ztest.getTotalSD()); 241 } 242 catch (IOException e) 243 { 244 e.printStackTrace(); 245 } 246 } 82 // } 247 83 }
Note: See TracChangeset
for help on using the changeset viewer.