Fixes rounding errors in FS using the same solution as R

This commit is contained in:
meganshand 2017-04-27 14:12:43 -04:00
parent 4fe4ace232
commit ea5efa0b2c
5 changed files with 11 additions and 7 deletions

View File

@ -65,6 +65,8 @@ public class StrandBiasTableUtils {
private final static Logger logger = Logger.getLogger(StrandBiasTableUtils.class);
private static final double REL_ERR = 1 + 10e-7;
//For now this is only for 2x2 contingency tables
protected static final int ARRAY_DIM = 2;
protected static final int ARRAY_SIZE = ARRAY_DIM * ARRAY_DIM;
@ -117,7 +119,7 @@ public class StrandBiasTableUtils {
final HypergeometricDistribution dist = new HypergeometricDistribution(N, numberOfSuccesses, sampleSize);
//Then we determine a given probability with the sampled successes (k = a) from the first entry in the table.
double pCutoff = dist.probability(table[0][0]);
double pCutoff = dist.probability(table[0][0]) * REL_ERR;
double pValue = 0.0;
/**

View File

@ -79,6 +79,8 @@ public class StrandBiasTableUtilsTest {
tests.add(new Object[]{9,13,12,10, 0.5466948});
tests.add(new Object[]{12,10,9,13, 0.5466948});
tests.add(new Object[]{9,12,11,9, 0.5377362});
tests.add(new Object[]{12,4,26,7, 1.0}); //tests rounding the probabilities from the Hypergeometric
tests.add(new Object[]{12,26,4,7, 1.0}); //tests rounding the probabilities from the Hypergeometric
tests.add(new Object[]{0, 0, 0, 0, 1.0});
tests.add(new Object[]{100000, 100000, 100000, 100000, 1.0} );

View File

@ -108,7 +108,7 @@ public class HaplotypeCallerGVCFIntegrationTest extends WalkerTest {
final String WExIntervals = "-L 20:10,000,000-10,100,000 -isr INTERSECTION -L " + hg19Chr20Intervals;
// this functionality can be adapted to provide input data for whatever you might want in your data
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.NONE, PCRFreeIntervals, "f2807ff921854059746da2954dc44a7b"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.NONE, PCRFreeIntervals, "cd21856eec2f1c1920408f20fd08411b"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.BP_RESOLUTION, PCRFreeIntervals, "d146c8dc4fc0605b3776ab5fec837d53"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.GVCF, PCRFreeIntervals, "c317193f0d1c9a8168f2625c8bf1dd2b"});
tests.add(new Object[]{NA12878_WEx, ReferenceConfidenceMode.NONE, WExIntervals, "63ff771eed3e62340c8938b4963d0add"});
@ -131,7 +131,7 @@ public class HaplotypeCallerGVCFIntegrationTest extends WalkerTest {
final String WExIntervals = "-L 20:10,000,000-10,100,000 -isr INTERSECTION -L " + hg19Chr20Intervals;
// this functionality can be adapted to provide input data for whatever you might want in your data
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.NONE, PCRFreeIntervals, "126527c225d24a2a0bb329ad9b3f682a"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.NONE, PCRFreeIntervals, "093f129861ea93526f6b80b4c8c70178"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.BP_RESOLUTION, PCRFreeIntervals, "6c727b804084a2324ecd1c98b72734b9"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.GVCF, PCRFreeIntervals, "190cef14684c95ba290d7a5fa13fdc07"});
tests.add(new Object[]{NA12878_WEx, ReferenceConfidenceMode.NONE, WExIntervals, "6ad7855dbf6dda2060aa93a3ee010b3e"});
@ -149,7 +149,7 @@ public class HaplotypeCallerGVCFIntegrationTest extends WalkerTest {
final String WExIntervals = "-L 20:10,000,000-10,100,000 -isr INTERSECTION -L " + hg19Chr20Intervals;
// this functionality can be adapted to provide input data for whatever you might want in your data
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.NONE, PCRFreeIntervals, "8e17f26d07fbba596d3cfd2e344c4cd2"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.NONE, PCRFreeIntervals, "468550db971e29b3696e5a14f3e31bfc"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.BP_RESOLUTION, PCRFreeIntervals, "48521b89cecceb9846e4dfc0dd415874"});
tests.add(new Object[]{NA12878_PCRFREE, ReferenceConfidenceMode.GVCF, PCRFreeIntervals, "eaacbeaff99a37ffa07e1f11e7f1deb2"});
tests.add(new Object[]{NA12878_WEx, ReferenceConfidenceMode.NONE, WExIntervals, "af0fe243e3b96e59097187cd16ba1597"});

View File

@ -319,7 +319,7 @@ public class HaplotypeCallerIntegrationTest extends WalkerTest {
public void HCTestDBSNPAnnotationWGS() {
WalkerTest.WalkerTestSpec spec = new WalkerTest.WalkerTestSpec(
"-T HaplotypeCaller --disableDithering --pcr_indel_model NONE -pairHMMSub " + HMM_SUB_IMPLEMENTATION + " " + ALWAYS_LOAD_VECTOR_HMM + " -R " + b37KGReference + " --no_cmdline_in_header -I " + NA12878_PCRFREE + " -o %s -L 20:10,090,000-10,100,000 -D " + b37dbSNP132, 1,
Arrays.asList("04ff9b301bd6f50df848800fbe09de5c"));
Arrays.asList("fc71471b01f93bc531e3cf19cdf78b1f"));
executeTest("HC calling with dbSNP ID annotation on WGS intervals", spec);
}

View File

@ -83,7 +83,7 @@ public class GenotypeGVCFsIntegrationTest extends WalkerTest {
final WalkerTestSpec spec = new WalkerTestSpec(
baseTestString(" -V " + privateTestDir + "testUpdatePGT.vcf", b37KGReference),
1,
Collections.singletonList("cdff1a18cd820c9d9c2b5b05ab7ef8a9"));
Collections.singletonList("326ec5afa27ade4d0c562aa227997d88"));
executeTest("testUpdatePGT", spec);
}
@ -93,7 +93,7 @@ public class GenotypeGVCFsIntegrationTest extends WalkerTest {
final WalkerTestSpec spec = new WalkerTestSpec(
baseTestString(" -V " + privateTestDir + "testUpdatePGT.vcf -A StrandAlleleCountsBySample -log " + logFileName, b37KGReference),
1,
Collections.singletonList("7a459c5ff606239620e5f7b089186dfb"));
Collections.singletonList("b995bf820c3edff5b721338ea9cf44aa"));
executeTest("testUpdatePGTStrandAlleleCountsBySample", spec);
final File file = new File(logFileName);