public double get_P_LN() {
   double pLN = 0;
   ChiSquaredDistribution chid = new ChiSquaredDistributionImpl(degree_freedom_wald);
   try {
     pLN = 1 - chid.cumulativeProbability(lod / 0.217);
   } catch (Exception E) {
     E.printStackTrace(System.err);
   }
   return pLN;
 }
Beispiel #2
0
  public void SummuarySimulation() {
    calculatePower();
    PrintStream Pout1 = null;
    PrintStream Pout2 = null;
    PrintStream Pout3 = null;
    PrintStream Pout4 = null;
    PrintStream Pout5 = null;
    PrintStream Pout6 = null;
    ChiSquaredDistribution chi = new ChiSquaredDistributionImpl(weight.length);
    try {
      Pout1 = new PrintStream(new BufferedOutputStream(new FileOutputStream("LogAP.txt")));
      Pout2 = new PrintStream(new BufferedOutputStream(new FileOutputStream("LNP.txt")));
      Pout3 = new PrintStream(new BufferedOutputStream(new FileOutputStream("LN.txt")));
      Pout4 = new PrintStream(new BufferedOutputStream(new FileOutputStream("Wald.txt")));
      Pout5 = new PrintStream(new BufferedOutputStream(new FileOutputStream("F.txt")));
      Pout6 = new PrintStream(new BufferedOutputStream(new FileOutputStream("LogDP.txt")));
    } catch (Exception E) {
      E.printStackTrace(System.err);
    }
    for (int i = 0; i < SimulationResults.size(); i++) {
      ArrayList PointStatistics = (ArrayList) SimulationResults.get(i);
      double[] LRT = new double[PointStatistics.size()];
      double[] WALD = new double[PointStatistics.size()];
      DescriptiveStatistics dsLRT = new DescriptiveStatisticsImpl();
      DescriptiveStatistics dsWALD = new DescriptiveStatisticsImpl();
      SimpleRegression sr = new SimpleRegression();
      for (int j = 0; j < PointStatistics.size(); j++) {
        PointMappingStatistic pms = (PointMappingStatistic) PointStatistics.get(j);
        double lod = pms.get_LOD() > 0 ? pms.get_LOD() : 0;
        double ln = pms.get_LN();
        double p = 0;
        try {
          p = chi.cumulativeProbability(ln);
        } catch (Exception E) {
          E.printStackTrace(System.err);
        }
        double logLOD = -1 * Math.log10(1 - p);
        Pout1.print(pms.get_logP_additive() + " ");
        Pout2.print(logLOD + " ");
        Pout3.print(pms.get_LN() + " ");
        Pout4.print(pms.get_wald() + " ");
        Pout5.print(pms.get_logP_F() + " ");
        Pout6.print(pms.get_logP_dominance() + " ");

        dsLRT.addValue(pms.get_LN());
        dsWALD.addValue(pms.get_wald());
        LRT[j] = pms.get_LN();
        WALD[j] = pms.get_wald();
        sr.addData(pms.get_LN(), pms.get_wald());
      }
      System.out.println(
          dsLRT.getMean()
              + " +- "
              + dsLRT.getStandardDeviation()
              + " "
              + dsWALD.getMean()
              + " +- "
              + dsWALD.getStandardDeviation()
              + " cor "
              + sr.getR());
      dsLRT.clear();
      dsWALD.clear();
      sr.clear();
      Pout1.println();
      Pout2.println();
      Pout3.println();
      Pout4.println();
      Pout5.println();
      Pout6.println();
    }
    Pout1.close();
    Pout2.close();
    Pout3.close();
    Pout4.close();
    Pout5.close();
    Pout6.close();
  }
Beispiel #3
0
  private void calculatePower() {
    ChiSquaredDistribution chi = new ChiSquaredDistributionImpl(weight.length);
    Collections.sort(thresholdAP);
    Collections.sort(thresholdDP);
    Collections.sort(thresholdLOD);
    Collections.sort(thresholdPwald);
    Collections.sort(thresholdPF);
    EmpiricalLogBonAP =
        ((Double) thresholdAP.get((new Double((thresholdAP.size() - 1) * 0.95)).intValue()))
            .doubleValue();
    if (weight.length > 1) {
      EmpiricalLogBonDP =
          ((Double) thresholdDP.get((new Double((thresholdDP.size() - 1) * 0.95)).intValue()))
              .doubleValue();
    }

    threshold_LOD =
        ((Double) thresholdLOD.get((new Double((thresholdLOD.size() - 1) * 0.95)).intValue()))
            .doubleValue();
    threshold_lodp = 0;
    double ln = threshold_LOD / 0.217;
    threshold_Pwald =
        ((Double) thresholdPwald.get((new Double((thresholdPwald.size() - 1) * 0.95)).intValue()))
            .doubleValue();
    threshold_PF =
        ((Double) thresholdPF.get((new Double((thresholdPF.size() - 1) * 0.95)).intValue()))
            .doubleValue();
    try {
      threshold_lodp = -1 * Math.log10(1 - chi.cumulativeProbability(ln));
    } catch (Exception E) {
      E.printStackTrace(System.err);
    }
    System.out.println("BonT: " + BonT);
    System.out.println("LogBon: " + LogBon);
    System.out.println("EmpLogBonAP: " + EmpiricalLogBonAP);
    System.out.println("EmpLogBonDP: " + EmpiricalLogBonDP);
    System.out.println(
        "threshold_LOD: " + "log10:" + threshold_LOD + " LR: " + ln + " P(ln) " + threshold_lodp);
    System.out.println("threshold_PWald: " + threshold_Pwald);
    System.out.println("threshold_PF: " + threshold_PF);
    for (Iterator e = SimulationResults.iterator(); e.hasNext(); ) {
      ArrayList result = (ArrayList) e.next();
      for (Iterator e1 = result.iterator(); e1.hasNext(); ) {
        PointMappingStatistic pms = (PointMappingStatistic) e1.next();
        String key = pms.getKey();
        if (Param1.permutation > 0
            && pointPowerF.containsKey(key)
            && pms.get_logP_F() > threshold_PF) {
          int p = ((Integer) pointPowerF.get(key)).intValue();
          p++;
          pointPowerF.put(key, new Integer(p));
        }
        if (Param1.permutation > 0
            && pointPowerWald.containsKey(key)
            && pms.get_logP_wald() > threshold_Pwald) {
          int p = ((Integer) pointPowerWald.get(key)).intValue();
          p++;
          pointPowerWald.put(key, new Integer(p));
        }
        if (Param1.permutation > 0
            && pointPowerLOD.containsKey(key)
            && pms.get_LOD() > threshold_LOD) {
          int p = ((Integer) pointPowerLOD.get(key)).intValue();
          p++;
          pointPowerLOD.put(key, new Integer(p));
        }
        if (pointPowerAPvalue.containsKey(key) && pms.get_logP_additive() > LogBon) {
          int p = ((Integer) pointPowerAPvalue.get(key)).intValue();
          p++;
          pointPowerAPvalue.put(key, new Integer(p));
        }
        if (pointPowerEmpiricalAPvalue.containsKey(key)
            && pms.get_logP_additive() > EmpiricalLogBonAP) {
          int p = ((Integer) pointPowerEmpiricalAPvalue.get(key)).intValue();
          p++;
          pointPowerEmpiricalAPvalue.put(key, new Integer(p));
        }
        if (weight.length > 1) {
          if (pointPowerDPvalue.containsKey(key) && pms.get_logP_dominance() > LogBon) {
            int p = ((Integer) pointPowerDPvalue.get(key)).intValue();
            p++;
            pointPowerDPvalue.put(key, new Integer(p));
          }
          if (pointPowerEmpiricalDPvalue.containsKey(key)
              && pms.get_logP_dominance() > EmpiricalLogBonDP) {
            int p = ((Integer) pointPowerEmpiricalDPvalue.get(key)).intValue();
            p++;
            pointPowerEmpiricalDPvalue.put(key, new Integer(p));
          }
        }
      }
    }
    Set keys = pointPowerLOD.keySet();
    System.out.println("type I LogBon: " + typeI_LogBon / Param1.permutation);
    System.out.println("QTL\tFP\tWald\tLOD\tBonAP\tEmpAP\tBonDP\tEmpDP");
    for (Iterator e = keys.iterator(); e.hasNext(); ) {
      String key = (String) e.next();
      System.out.print(key + "\t");
      System.out.print((Integer) pointPowerF.get(key) + "\t");
      System.out.print((Integer) pointPowerWald.get(key) + "\t");
      System.out.print((Integer) pointPowerLOD.get(key) + "\t");
      System.out.print((Integer) pointPowerAPvalue.get(key) + "\t");
      System.out.print((Integer) pointPowerEmpiricalAPvalue.get(key) + "\t");
      if (weight.length > 1) {
        System.out.print(pointPowerDPvalue.get(key) + "\t");
        System.out.println(pointPowerEmpiricalDPvalue.get(key) + "\t");
      } else {
        System.out.println("--\t--\t");
      }
    }
  }
  /**
   * @param param degrees of freedom
   * @return chi squared distribution
   */
  protected ChiSquaredDistribution getChiSquaredDistribution(double param) {
    if (chisquared == null || chisquared.getDegreesOfFreedom() != param)
      chisquared = new ChiSquaredDistributionImpl(param);

    return chisquared;
  }