Changeset 221


Ignore:
Timestamp:
Dec 20, 2006, 3:07:20 PM (16 years ago)
Author:
Johan Enell
Message:

Fixes #40

Location:
trunk/se/lu/onk/ZTest/src/ztest
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/se/lu/onk/ZTest/src/ztest/Plot.java

    r220 r221  
    187187    throws IOException
    188188  {
     189    if (m.getItemCount(0) == 0)
     190    {
     191      System.err.println("Can't print histogram. Dataset empty.");
     192      return;
     193    }
     194   
    189195    NumberAxis domainAxis = new NumberAxis("M, log2(int1/int2)");
    190196    NumberAxis rangeAxis1 = new NumberAxis("Frequence");
  • trunk/se/lu/onk/ZTest/src/ztest/Reporter.java

    r220 r221  
    2929  private String reporter;
    3030  private double m;
     31  private double a;
    3132  private double p;
    3233  private int size;
    3334  private String symbol;
    3435  private String locusLink;
     36  private int id;
    3537 
    3638 
    37   public Reporter(String reporter, String symbol, String locusLink)
     39  public Reporter(int id, String reporter, String symbol, String locusLink, double a)
    3840  {
     41    this.id = id;
    3942    this.reporter = reporter;
    4043    this.symbol = symbol;
    4144    this.locusLink = locusLink;
     45    this.a = a;
    4246  }
    4347
     
    6064  {
    6165    return m;
     66  }
     67 
     68  public double getA()
     69  {
     70    return a;
     71  }
     72 
     73  public int getId()
     74  {
     75    return id;
    6276  }
    6377
  • trunk/se/lu/onk/ZTest/src/ztest/Spot.java

    r197 r221  
    2626public class Spot
    2727{
    28   double m;
     28  private double m;
    2929 
    3030  public Spot(Double m)
  • trunk/se/lu/onk/ZTest/src/ztest/Start.java

    r220 r221  
    5959
    6060      int mCol = assayFields.indexOf("l2ratio1_2");
     61      int aCol = assayFields.indexOf("l10intgmean1_2");
    6162      int repCol = columns.indexOf("reporter");
    6263      int repidCol = columns.indexOf("reporterId");
     
    6566      int assayDataCol = columns.indexOf("assayData");
    6667
    67       if (mCol == -1 || repCol == -1 || repidCol == -1 || symCol == -1 || llCol == -1 || assayDataCol == -1)
     68      if (aCol == -1 || mCol == -1 || repCol == -1 || repidCol == -1 || symCol == -1 || llCol == -1 || assayDataCol == -1)
    6869      {
    6970        throw new BASEFileException("Cant find the columns l2ratio1_2, reporter or assayData");
    7071      }
    7172      mCol += assayDataCol;
     73      aCol += assayDataCol;
    7274
    7375      int dataLength = columns.size() + assays.size() * assayFields.size() - 1;
    74       bfss.setDataMatrix(bfss.findIntOpt("count"), assays.size() * assayFields.size());
     76      bfss.setDataMatrix(bfss.findIntOpt("count"), assays.size());
    7577      String[] data = bfr.readDataRow(dataLength);
    7678      while (data != null)
    7779      {
    7880        Spot[] spots = new Spot[assays.size()];
     81        Double a = 0.0;
     82        int aCount = 0;
    7983        for (int i = 0; i < assays.size(); i++)
    8084        {
    81           int index = mCol + i * assayFields.size();
     85          int mIndex = mCol + i * assayFields.size();
     86          int aIndex = aCol + i * assayFields.size();
    8287          Double m = Double.NaN;
    83           if (!data[index].equals(""))
     88          if (!data[mIndex].equals(""))
     89            m = new Double(data[mIndex]);
     90          if (!data[aIndex].equals(""))
    8491          {
    85             m = new Double(data[index]);
     92            a += new Double(data[aIndex]);
     93            aCount++;
    8694          }
    8795          spots[i] = new Spot(m);
    8896        }
    89         Reporter r = new Reporter(data[repidCol], data[symCol], data[llCol]);
     97        Reporter r = new Reporter(new Integer(data[repCol]), data[repidCol], data[symCol], data[llCol], a/aCount);
    9098        bfss.addData(r, spots);
    9199        data = bfr.readDataRow(dataLength);
     
    140148      Object[] tableRow = {"Reporter","GeneSymbol","LocusLink","AverageM","up/down","P","Rank","Expected","FDR","NumberOfValues"};
    141149
     150      System.out.println("BASEfile");
     151      System.out.println("section\tassays");
     152      System.out.println("annotationColumns\t");
     153      System.out.println("columns\tid\tname\tparents");
     154      System.out.println("count\t1");
     155      System.out.println("%");
     156      System.out.println("1\tztest\t"+bfss.findStringOpt("assays").replaceAll("\t", "/"));
     157      System.out.println();
     158      System.out.println("section\tspots");
     159      System.out.println("channels\t2");
     160      System.out.println("setExtraFloats\tJE_nbrOfElements\tJE_rank\tJE_Expected\tJE_fdr");
     161      System.out.println("assayFields\tl2ratio1_2\tl10intgmean1_2\tJE_nbrOfElements\tJE_rank\tJE_Expected\tJE_fdr");
     162      System.out.println("columns\tposition\treporter\tassayData");
     163      System.out.println("assays\t1");
     164      System.out.println("count\t"+bfss.getReporterSize());
     165      System.out.println("%");
     166     
    142167      html.println("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">");
    143168      html.println("<html>");
     
    149174      html.println("<table>");
    150175      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><th>%s</th><th>%s</th></tr>\n", tableRow);
     176     
    151177      tab.printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", tableRow);
    152178
     
    158184        double fdr = (expected / rank);
    159185       
     186        System.out.printf("%d\t%d\t", (-1*rank), r.getId());
     187        System.out.printf("%f\t%f\t", r.getM(), r.getA());
     188        System.out.printf("%d\t%d\t%f\t%f\n", r.getSize(), rank, expected, fdr);
     189       
     190        tableRow[0] = r.getReporter();
     191        tableRow[1] = r.getSymbol();
     192        tableRow[2] = r.getLocusLink();
     193        tableRow[3] = r.getM();
     194        tableRow[4] = r.getM() > 0 ? "+" : "-";
     195        tableRow[5] = r.getP();
     196        tableRow[6] = rank;
     197        tableRow[7] = expected;
     198        tableRow[8] = fdr;
     199        tableRow[9] = r.getSize();
     200
    160201        if (i < 1000)
    161202        {
    162           tableRow[0] = r.getReporter();
    163           tableRow[1] = r.getSymbol();
    164           tableRow[2] = r.getLocusLink();
    165           tableRow[3] = r.getM();
    166           tableRow[4] = r.getM() > 0 ? "+" : "-";
    167           tableRow[5] = r.getP();
    168           tableRow[6] = rank;
    169           tableRow[7] = expected;
    170           tableRow[8] = fdr;
    171           tableRow[9] = r.getSize();
    172          
    173203          html.printf(
    174204            "<tr class=\"row" + (i % 2 + 1) + "\"><td>%s</td><td>%s</td><td>%s</td><td>%f</td>" +
     
    183213        mHist.addObservation(r.getM());
    184214      }
     215      System.out.println();
     216     
    185217      html.println("</table>");
    186218      html.print("</html>");
Note: See TracChangeset for help on using the changeset viewer.