Exemple #1
0
    bootstrapResults = []
    for a in xrange(0, maxPositiveSeqs + 1):
        for b in xrange(a, maxPositiveSeqs + 1):
            # calculate p-values
            barnardOneSided, barnardTwoSided = barnard.hypothesisTest(
                a, b, totalSamples1, totalSamples2)
            if (barnardTwoSided < 0.01 or barnardTwoSided > 0.1):
                continue

            fishersOneSided, fishersTwoSided = fishers.hypothesisTest(
                a, b, totalSamples1, totalSamples2)
            chiSquareOneSided, chiSquareTwoSided = chiSquare.hypothesisTest(
                a, b, totalSamples1, totalSamples2)
            chiSquareYatesOneSided, chiSquareYatesTwoSided = chiSquareYates.hypothesisTest(
                a, b, totalSamples1, totalSamples2)
            gTestOneSided, gTestTwoSided = gTest.hypothesisTest(
                a, b, totalSamples1, totalSamples2)
            gTestYatesOneSided, gTestYatesTwoSided = gTestYates.hypothesisTest(
                a, b, totalSamples1, totalSamples2)
            diffBetweenPropOneSided, diffBetweenPropTwoSided = diffBetweenProp.hypothesisTest(
                a, b, totalSamples1, totalSamples2)
            permutationOneSided, permutationTwoSided = permutation.hypothesisTest(
                a, b, totalSamples1, totalSamples2)
            bootstrapOneSided, bootstrapTwoSided = bootstrap.hypothesisTest(
                a, b, totalSamples1, totalSamples2)

            # calculate p-values relative to Barnard's
            fishersResults.append(100 * (fishersTwoSided - barnardTwoSided) /
                                  barnardTwoSided)
            chiSquareResults.append(
                100 * (chiSquareTwoSided - barnardTwoSided) / barnardTwoSided)
            chiSquareYatesResults.append(
Exemple #2
0
     
   # draw samples w/o replacement for community 2
   samplesInSS = popSize*prop
   samplesNotInSS = popSize - samplesInSS      
   inSS2 = 0
   for s in xrange(0, sampleSize2[sampleSizeIndex]):
     rnd = random.random()
     
     if rnd <= float(samplesInSS) / popSize:
       samplesInSS -= 1
       inSS2 += 1
     else:
       samplesNotInSS -= 1
                 
   fishersOneSided, fishersTwoSided = fishers.hypothesisTest(inSS1, inSS2, totalSamples1, totalSamples2)        
   gTestOneSided, gTestTwoSided = gTest.hypothesisTest(inSS1, inSS2, totalSamples1, totalSamples2)
   gTestYatesOneSided, gTestYatesTwoSided = gTestYates.hypothesisTest(inSS1, inSS2, totalSamples1, totalSamples2)
   diffBetweenPropOneSided, diffBetweenPropTwoSided = diffBetweenProp.hypothesisTest(inSS1, inSS2, totalSamples1, totalSamples2)
   
   fishersResults.append(fishersTwoSided)
   gTestResults.append(gTestTwoSided)
   gTestYatesResults.append(gTestYatesTwoSided)
   diffBetweenPropResults.append(diffBetweenPropTwoSided)   
   
 pValues = [fishersResults,gTestResults,gTestYatesResults,diffBetweenPropResults] 
   
 bins = {}
 numBins = 20
 binSize = 1.0 / numBins
 for i in xrange(0,numBins):
   bins[i] = []
Exemple #3
0
gTestResults = []
gTestYatesResults = []
permutationResults = []
diffBetweenPropResults = []
bootstrapResults = []
for a in xrange(11, maxPositiveSeqs):
    print a
    for b in xrange(a, maxPositiveSeqs):

        # calculate p-values
        fishersOneSided, fishersTwoSided = fishers.hypothesisTest(a, b, totalSamples1, totalSamples2)
        chiSquareOneSided, chiSquareTwoSided = chiSquare.hypothesisTest(a, b, totalSamples1, totalSamples2)
        chiSquareYatesOneSided, chiSquareYatesTwoSided = chiSquareYates.hypothesisTest(
            a, b, totalSamples1, totalSamples2
        )
        gTestOneSided, gTestTwoSided = gTest.hypothesisTest(a, b, totalSamples1, totalSamples2)
        gTestYatesOneSided, gTestYatesTwoSided = gTestYates.hypothesisTest(a, b, totalSamples1, totalSamples2)
        diffBetweenPropOneSided, diffBetweenPropTwoSided = diffBetweenProp.hypothesisTest(
            a, b, totalSamples1, totalSamples2
        )
        permutationOneSided, permutationTwoSided = permutation.hypothesisTest(a, b, totalSamples1, totalSamples2)
        bootstrapOneSided, bootstrapTwoSided = bootstrap.hypothesisTest(a, b, totalSamples1, totalSamples2)

        fishersResults.append(fishersTwoSided)
        chiSquareResults.append(chiSquareTwoSided)
        chiSquareYatesResults.append(chiSquareYatesTwoSided)
        gTestResults.append(gTestTwoSided)
        gTestYatesResults.append(gTestYatesTwoSided)
        permutationResults.append(permutationTwoSided)
        diffBetweenPropResults.append(diffBetweenPropTwoSided)
        bootstrapResults.append(bootstrapTwoSided)
Exemple #4
0
            # draw samples w/o replacement for community 2
            samplesInSS = popSize * prop
            samplesNotInSS = popSize - samplesInSS
            inSS2 = 0
            for s in xrange(0, sampleSize2[sampleSizeIndex]):
                rnd = random.random()

                if rnd <= float(samplesInSS) / popSize:
                    samplesInSS -= 1
                    inSS2 += 1
                else:
                    samplesNotInSS -= 1

            fishersOneSided, fishersTwoSided = fishers.hypothesisTest(
                inSS1, inSS2, totalSamples1, totalSamples2)
            gTestOneSided, gTestTwoSided = gTest.hypothesisTest(
                inSS1, inSS2, totalSamples1, totalSamples2)
            gTestYatesOneSided, gTestYatesTwoSided = gTestYates.hypothesisTest(
                inSS1, inSS2, totalSamples1, totalSamples2)
            diffBetweenPropOneSided, diffBetweenPropTwoSided = diffBetweenProp.hypothesisTest(
                inSS1, inSS2, totalSamples1, totalSamples2)

            fishersResults.append(fishersTwoSided)
            gTestResults.append(gTestTwoSided)
            gTestYatesResults.append(gTestYatesTwoSided)
            diffBetweenPropResults.append(diffBetweenPropTwoSided)

        pValues = [
            fishersResults, gTestResults, gTestYatesResults,
            diffBetweenPropResults
        ]