Exemple #1
0
	def testGTestYates(self):
		"""Verify computation of G-test with Yates' continuity correction"""
		from stamp.plugins.samples.statisticalTests.GTestYates import GTestYates
		gTestYates = GTestYates(preferences)
		
		# Ground truth obtained from Peter L. Hurd's R script (http://www.psych.ualberta.ca/~phurd/cruft/g.test.r)	
		oneSided, twoSided, _ = gTestYates.hypothesisTest(table1[0], table1[1], table1[2], table1[3])	 
		self.assertEqual(oneSided, float('inf'))
		self.assertAlmostEqual(twoSided, 0.325502240010)
		
		oneSided, twoSided, _ = gTestYates.hypothesisTest(table2[0], table2[1], table2[2], table2[3])	 
		self.assertEqual(oneSided, float('inf'))
		self.assertAlmostEqual(twoSided, 2.220446049e-16)
Exemple #2
0
class GTestFisher(AbstractSampleStatsTestPlugin):
	'''
	Perform G-test w/ Yates' correction or Fisher's exact test.
	'''
	
	def __init__(self, preferences):
		AbstractSampleStatsTestPlugin.__init__(self, preferences)
		self.name = 'G-test (w/ Yates\') + Fisher\'s'
		self.fishers = Fishers(self.preferences)
		self.gTestYates = GTestYates(self.preferences)
		
	def hypothesisTest(self, seq1, seq2, totalSeq1, totalSeq2):
		a = seq1
		b = seq2
		c = totalSeq1 - seq1
		d = totalSeq2 - seq2
		
		if a < 20 or b < 20 or c < 20 or d < 20:
			return self.fishers.hypothesisTest(seq1, seq2, totalSeq1, totalSeq2)
		else:
			return self.gTestYates.hypothesisTest(seq1, seq2, totalSeq1, totalSeq2)
Exemple #3
0
class GTestFisher(AbstractSampleStatsTestPlugin):
    '''
	Perform G-test w/ Yates' correction or Fisher's exact test.
	'''
    def __init__(self, preferences):
        AbstractSampleStatsTestPlugin.__init__(self, preferences)
        self.name = 'G-test (w/ Yates\') + Fisher\'s'
        self.fishers = Fishers(self.preferences)
        self.gTestYates = GTestYates(self.preferences)

    def hypothesisTest(self, seq1, seq2, totalSeq1, totalSeq2):
        a = seq1
        b = seq2
        c = totalSeq1 - seq1
        d = totalSeq2 - seq2

        if a < 20 or b < 20 or c < 20 or d < 20:
            return self.fishers.hypothesisTest(seq1, seq2, totalSeq1,
                                               totalSeq2)
        else:
            return self.gTestYates.hypothesisTest(seq1, seq2, totalSeq1,
                                                  totalSeq2)
Exemple #4
0
 def __init__(self, preferences):
     AbstractSampleStatsTestPlugin.__init__(self, preferences)
     self.name = 'G-test (w/ Yates\') + Fisher\'s'
     self.fishers = Fishers(self.preferences)
     self.gTestYates = GTestYates(self.preferences)
Exemple #5
0
	def __init__(self, preferences):
		AbstractSampleStatsTestPlugin.__init__(self, preferences)
		self.name = 'G-test (w/ Yates\') + Fisher\'s'
		self.fishers = Fishers(self.preferences)
		self.gTestYates = GTestYates(self.preferences)