Package gem.util

Examples of gem.util.Histogram


    printChangeHisto(dir + "data.txt", pos[1], pos[5]);
  }
 
  public static void printChangeHisto(String datafile, boolean[] pos1, boolean[] pos2) throws IOException
  {
    Histogram h = new Histogram(0.01);
    int cnt1 = ArrayUtils.countTrue(pos1);
    int cnt2 = ArrayUtils.countTrue(pos2);

    assert pos1.length == pos2.length;
    BufferedReader reader = FileUtil.getReader(datafile);

    reader.readLine();
    for (String line = reader.readLine(); line != null; line = reader.readLine())
    {
      line = line.substring(line.indexOf("\t") + 1);
      String[] token = line.split("\t");
      assert token.length == pos1.length;

      double[] val = new double[token.length];
      for (int i = 0; i < val.length; i++)
      {
        val[i] = Double.parseDouble(token[i]);
      }

      double mean1 = 0;
      double mean2 = 0;
      for (int i = 0; i < val.length; i++)
      {
        if (pos1[i]) mean1 += val[i];
        if (pos2[i]) mean2 += val[i];
      }

      mean1 /= cnt1;
      mean2 /= cnt2;

      double rat = mean2 / mean1;
      double lograt = Math.log(rat);
      h.count(lograt);
    }

    reader.close();
    h.printDensity();
  }
View Full Code Here


  {
    List<Triplet> trips = readTripsAndAssociate("result/All_fdr0.05_var1.0.xls",
      "resource/experiments_expO_1.txt", "resource/experiments_expO_2.txt");

    Random r = new Random();
    Histogram h = new Histogram(0.05);
    Set<String> counted = new HashSet<String>();

    for (Triplet t : trips)
    {
      Gene g1 = t.M;
      Gene g2 = trips.get(r.nextInt(trips.size())).M;

      if (g1 == g2) continue;
     
      String s = g1.id + g2.id;
      if (!counted.contains(s))
      {
        double eff = TripletGraphMLWriter.calcPairwiseEffect(g1, g2);
        h.count(eff);
        counted.add(s);
      }
    }
    h.printDensity();
  }
View Full Code Here

    {
      System.out.println("dev " + i + " = " + Summary.stdev(d[i]));
    }

    double[] g = getSample(Summary.stdev(d[0]), d[0].length);
    Histogram h1 = new Histogram(0.01, d[0]);
    Histogram h2 = new Histogram(0.01, g);
    h1.printTogether(h2)
  }
View Full Code Here

  /**
   * Prints a histogram of expression values on the console.
   */
  public void printValueHisto()
  {
    Histogram h = new Histogram(1);
    for (double v : value)
    {
      h.count(v);
    }
    h.printDensity();
  }
View Full Code Here

    {
      ids.add(Triplet.getSymbolToGeneMap().get(sym));
    }
    Map<String, List<Gene>> map = Gene.readGenes(ids, 1, "resource/experiments_expO_1.txt", "resource/experiments_expO_2.txt");

    Histogram h = new Histogram(0.1);
    for (String id : ids)
    {
      List<Gene> genes = map.get(id);
      for (int i = 0; i < genes.size()-1; i++)
      {
        for (int k = i+1; k < genes.size(); k++)
        {
          Gene g1 = genes.get(i);
          Gene g2 = genes.get(k);
          if (g1.status==null) g1.rankAdjustStatus(1D/3);
          if (g2.status==null) g2.rankAdjustStatus(1D/3);
          h.count(Difference.calcPairwiseCoefficient(g1, g2));
        }
      }
    }
    h.print();
  }
View Full Code Here

    }
  }
 
  public Histogram getDistribution(boolean[] pos, double range)
  {
    Histogram h = new Histogram(range);
    for (int i = 0; i < value.length; i++)
    {
      if (pos == null || pos[i]) h.count(value[i]);
    }
    return h;
  }
View Full Code Here

TOP

Related Classes of gem.util.Histogram

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.