Exemple #1
0
 fishersResults = []
 chiSquareResults = []
 chiSquareYatesResults = []
 gTestResults = []
 gTestYatesResults = []
 permutationResults = []
 diffBetweenPropResults = []
 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(100 * (chiSquareYatesTwoSided - barnardTwoSided) / barnardTwoSided)
     gTestResults.append(100 * (gTestTwoSided - barnardTwoSided) / barnardTwoSided)
     gTestYatesResults.append(100 * (gTestYatesTwoSided - barnardTwoSided) / barnardTwoSided)
     permutationResults.append(100 * (permutationTwoSided - barnardTwoSided) / barnardTwoSided)
       samplesNotInSS -= 1          
     
   # 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):