public double testSiteSimple(OpenBitSet dA1, OpenBitSet dA2, OpenBitSet dT, OpenBitSet dF) { double result = 1; int cntIA1 = 0, cntIA2 = 0; cntIA1 = (int) OpenBitSet.intersectionCount(dT, dA1); cntIA2 = (int) OpenBitSet.intersectionCount(dT, dA2); int sum = cntIA1 + cntIA2; if (sum > 0) { if (cntIA1 < cntIA2) result = (double) cntIA1 / sum; else result = (double) cntIA2 / sum; } /* if (result < 0.0001) { int cA1 = (int)dA1.lastCalculatedCardinality(); int cA2 = (int)dA2.lastCalculatedCardinality(); int cT = (int)dT.lastCalculatedCardinality(); int cF = (int)dF.lastCalculatedCardinality(); int cntIA1F = (int)OpenBitSet.intersectionCount(dF, dA1); int cntIA2F = (int)OpenBitSet.intersectionCount(dF, dA2); System.out.println(cntIA1 + "\t" + cntIA2 + "\t" + sum +"\t"+cA1+"\t"+cA2+"\t"+cT+"\t"+cF+"\t"+cntIA1F+"\t"+cntIA2F); } * */ return result; }
public boolean checkAnchorSegregationInFamilies( OpenBitSet familiesMark, OpenBitSet dA1, OpenBitSet dA2, int familySize) { int cntA1 = (int) OpenBitSet.intersectionCount(familiesMark, dA1); int cntA2 = (int) OpenBitSet.intersectionCount(familiesMark, dA2); if (cntA1 > cntA2) { int temp = cntA1; cntA1 = cntA2; cntA2 = temp; } int sum = cntA1 + cntA2; double rate = (double) cntA1 / sum; if (rate < 0.2) return false; // check segregation // if ((double)sum/familySize < 0.8) return false; //check missing data return true; }
public double testSiteBio(OpenBitSet dA1, OpenBitSet dA2, OpenBitSet dT, OpenBitSet dF) { double result = 1, minorP = 1; int cntIA1 = 0, cntIA2 = 0, cntIA1T = 0, cntIA2T = 0, cntIA1F = 0, cntIA2F = 0; cntIA1T = (int) OpenBitSet.intersectionCount(dT, dA1); cntIA2T = (int) OpenBitSet.intersectionCount(dT, dA2); cntIA1F = (int) OpenBitSet.intersectionCount(dF, dA1); cntIA2F = (int) OpenBitSet.intersectionCount(dF, dA2); int sumTag = cntIA1T + cntIA2T; if (sumTag == 0) return result; int sumAnchor = cntIA1F + cntIA2F; if (cntIA1T < cntIA2T) { minorP = (double) cntIA1F / sumAnchor; } else { minorP = (double) cntIA2F / sumAnchor; } Binomial binomFunc = new Binomial(5, 0.5, new RandomJava()); binomFunc.setNandP(sumTag, minorP); try { result = (cntIA1T < cntIA2T) ? binomFunc.cdf(cntIA1T) : binomFunc.cdf(cntIA2T); } catch (Exception e) { System.out.println(e.toString()); } return result; }