Esempio n. 1
0
  public String[] getNontransmitted() {
    String control[] = new String[getChildrenNum()];
    TreeMap<String, Integer> controlMap = NewIt.newTreeMap();
    // how to deal with missing data???

    if (childrenGenoMap.size() == 1) { // situation 1
      // System.out.println("Table1 s1");

      String[] genopool = new String[1];
      genopool[0] = childrenGenoMap.firstKey();
      double[] freq = new double[1];
      freq[0] = 1.0;
      Produce(control, controlMap, genopool, freq);
    } else if (childrenGenoMap.size() == 2) { // situation 2, 3
      // System.out.println("Table1 s2,3");

      String[] genopool = new String[2];
      genopool[0] = childrenGenoMap.firstKey();
      genopool[1] = childrenGenoMap.lastKey();
      double[] freq = new double[2];
      freq[0] = 0.5;
      freq[1] = 1.0;
      do {
        controlMap.clear();
        Produce(control, controlMap, genopool, freq);
      } while (!(controlMap.size() > 1));
    } else {
      System.err.println("Wrecked in Rabinowitz table 1");
    }
    return control;
  }
Esempio n. 2
0
  protected void RevvingUp() {

    ChenBase.LineUpGenotypePhenotype lineup = new ChenBase.LineUpGenotypePhenotype();
    Hashtable<String, BFamilyStruct> Fam = PedData.getFamilyStruct();

    PersonTable.ensureCapacity(qualified_Unrelated + qualified_Sib);
    if (PhenoData != null) CovariateTable.ensureCapacity(qualified_Unrelated + qualified_Sib);

    status = new double[qualified_Unrelated + qualified_Sib];

    ArrayList<PersonIndex> u_P = NewIt.newArrayList();
    ArrayList<ArrayList<String>> u_C = NewIt.newArrayList();

    ArrayList<PersonIndex> s_P = NewIt.newArrayList();
    ArrayList<ArrayList<String>> s_C = NewIt.newArrayList();

    ArrayList<Integer> SibIdx = NewIt.newArrayList();

    int c = 0;
    int s = 0;
    int un = 0;
    for (String fi : PedData.getFamListSorted()) {
      if ((lineup.num_qualified[c][0] + lineup.num_qualified[c][1]) == 0) {
        c++;
        continue;
      }
      BFamilyStruct fs = Fam.get(fi);
      FamilyUnit FamUnit = PhenoData == null ? null : PhenoData.getFamilyUnit(fi);
      String[] pi = fs.getPersonListSorted();
      int si = 0;

      for (int i = 0; i < pi.length; i++) {
        if (!lineup.filter[c][i]) continue;
        BPerson per = fs.getPerson(pi[i]);
        Subject sub = PhenoData == null ? null : FamUnit.getSubject(pi[i]);

        if (fs.hasAncestor(per.getPersonID())) {
          s_P.add(new PersonIndex(fs.getFamilyStructName(), pi[i], per, false, false));
          status[s + qualified_Unrelated] = Double.parseDouble(per.getAffectedStatus());
          if (PhenoData != null) s_C.add(sub.getTraits());
          si++;
          s++;
        } else {
          u_P.add(new PersonIndex(fs.getFamilyStructName(), pi[i], per, false, true));
          status[un] = Double.parseDouble(per.getAffectedStatus());
          if (PhenoData != null) u_C.add(sub.getTraits());
          un++;
        }
      }
      if (si != 0) SibIdx.add(new Integer(si));
      c++;
    }
    PersonTable.addAll(u_P);
    PersonTable.addAll(s_P);
    if (PhenoData != null) {
      CovariateTable.addAll(u_C);
      CovariateTable.addAll(s_C);
    }

    numSib = ArrayUtils.toPrimitive(SibIdx.toArray(new Integer[0]));

    System.err.println(un + " unrelated individuals.");
    Test.LOG.append(un + " unrelated individuals." + "\n");
    System.err.println(s + " siblings from " + numSib.length + " families.\n");
    Test.LOG.append(s + " siblings from " + numSib.length + " families." + "\n");
  }
Esempio n. 3
0
/** @author Guo-Bo Chen, [email protected] */
public final class SimulationPower {
  private static String model = "0,3";
  private HashMap<String, MDRStatistic> result;
  private double[] threshold;
  private double p_001 = 0.01;
  private double t_001;
  private int p_001_idx = 0;
  private double p_005 = 0.05;
  private double t_005;
  private int p_005_idx = 0;
  public static int typeI_005;
  public static int typeI_001;

  public static int power_005;
  public static int power_001;

  private ArrayList<SimulationStatistic> result_005 = NewIt.newArrayList();
  private ArrayList<SimulationStatistic> result_001 = NewIt.newArrayList();

  public class SimulationStatistic {
    protected String model;
    private double TestingBalancedAccuracy;
    private double TrainingBalancedAccuracy;
    private double p_value;

    public SimulationStatistic(String m, double tra, double ta, double p) {
      model = m;
      TestingBalancedAccuracy = tra;
      TrainingBalancedAccuracy = ta;
      p_value = p;
    }

    public String toString() {
      NumberFormat number = new DecimalFormat("#.####");
      StringBuilder sb = new StringBuilder();
      sb.append(
          model
              + " "
              + number.format(TestingBalancedAccuracy)
              + " "
              + number.format(TrainingBalancedAccuracy)
              + " "
              + number.format(p_value)
              + System.getProperty("line.separator"));
      return sb.toString();
    }
  }

  public SimulationPower(HashMap<String, MDRStatistic> r, double[] t) {
    result = r;
    threshold = t;
    Arrays.sort(threshold);
    p_005_idx = (int) (threshold.length * (1 - p_005));
    p_001_idx = (int) (threshold.length * (1 - p_001));
    t_005 = threshold[p_005_idx];
    t_001 = threshold[p_001_idx];
  }

  public void calculatePower() {

    for (Entry<String, MDRStatistic> entry : result.entrySet()) {
      String k = entry.getKey();
      MDRStatistic v = entry.getValue();
      double ta = v.getTestingBalancedAccuracy();
      if (ta > t_005) {
        result_005.add(
            new SimulationStatistic(
                k,
                v.getTestingBalancedAccuracy(),
                v.getTrainingBalancedAccuracy(),
                getP(p_005_idx, ta)));
      }
      if (ta > t_001) {
        result_001.add(
            new SimulationStatistic(
                k,
                v.getTestingBalancedAccuracy(),
                v.getTrainingBalancedAccuracy(),
                getP(p_001_idx, ta)));
      }
    }
    if (result_005.size() > 0) {
      typeI_005++;
      for (SimulationStatistic s : result_005) {
        if (s.model.compareTo(model) == 0) {
          power_005++;
        }
      }
    }
    if (result_001.size() > 0) {
      typeI_001++;
      for (SimulationStatistic s : result_001) {
        if (s.model.compareTo(model) == 0) {
          power_001++;
        }
      }
    }
  }

  private double getP(int idx, double t) {
    double p = idx;
    for (int i = idx, len = threshold.length; i < len; i++) {
      if (t > threshold[i]) p++;
    }
    return 1 - p / threshold.length;
  }

  public String toString() {

    DecimalFormat fmt = new DecimalFormat("#.###E0");
    StringBuilder sb = new StringBuilder();
    sb.append(threshold.length + " rounds of permutation:");
    sb.append(System.getProperty("line.separator"));
    sb.append("significance level at alpha = 0.05, BTA threshold=" + fmt.format(t_005));
    sb.append(System.getProperty("line.separator"));
    if (result_005.size() > 0) {
      for (SimulationStatistic sr : result_005) {
        sb.append(sr);
      }
    } else {
      sb.append("null");
      sb.append(System.getProperty("line.separator"));
    }
    sb.append("significance level at alpha = 0.01, BTA threshold=" + fmt.format(t_001));
    sb.append(System.getProperty("line.separator"));
    if (result_001.size() > 0) {
      for (SimulationStatistic sr : result_001) {
        sb.append(sr);
      }
    } else {
      sb.append("null");
      sb.append(System.getProperty("line.separator"));
    }
    return sb.toString();
  }
}