Exemple #1
0
class EnrichmentFinderTest(unittest.TestCase):

    def setUp(self):
        self.go_graph = OntoIO.read("Ontology/go_test.obo", "obo")
        self.assocs = OntoIO.read("Ontology/ga_test.fb", "gaf")
        self.ef = TermForTermEnrichmentFinder(self.assocs, self.go_graph)
    
    def test_find_terms_associations(self):
        expected = {'GO:0032502': set(['FBgn0010340']),'GO:0005737': set(['FBgn0026615']), 'GO:0045177': set(['FBgn0026615']), 'GO:0032501': set(['FBgn0010340']), 'GO:0044707': set(['FBgn0010340']), 'GO:0044464': set(['FBgn0026615']), 'GO:0005623': set(['FBgn0026615']), 'GO:0005622': set(['FBgn0026615']), 'GO:0005575': set(['FBgn0026615']), 'GO:0008150': set(['FBgn0010340', 'FBgn0026615']), 'GO:0044424': set(['FBgn0026615']), 'GO:0003674': set(['FBgn0026615']), 'GO:0007275': set(['FBgn0010340']), 'GO:0044699': set(['FBgn0010340'])}
        self.assertEqual(expected, self.ef._find_terms_associations(['FBgn0010340', 'FBgn0026615']))
        
    def test_parent_child_union(self):
        genes = ['FBgn0043467', 'FBgn0010339', 'FBgn0070057', 'FBgn0070052']
        ef = ParentChildEnrichmentFinder(self.assocs, self.go_graph)
        en = ef.find_enrichment(genes, ['bh_fdr'], 'union')
        self.assertEqual(7, len(en.filter_p_val(0.9).entries))
    
    def test_parent_child_intersection(self):
        genes = ['FBgn0043467', 'FBgn0010339', 'FBgn0070057', 'FBgn0070052']
        ef = ParentChildEnrichmentFinder(self.assocs, self.go_graph)
        en = ef.find_enrichment(genes, ['bonferroni'], 'intersection')
        self.assertEqual(7, len(en.filter_p_val(0.9).entries))
        
    def test_term_for_term(self):
        genes = ['FBgn0043467', 'FBgn0010339', 'FBgn0070057', 'FBgn0070052']
        en = self.ef.find_enrichment(genes)
        self.assertEqual(24, len(en.filter_p_val(0.9).entries))
def run_term(assocs, go_graph, gene_list, corrections):
    from Bio.Ontology import TermForTermEnrichmentFinder

    ef = TermForTermEnrichmentFinder(assocs, go_graph)
    result = ef.find_enrichment(gene_list, corrections)
    return result
Exemple #3
0
 def setUp(self):
     self.go_graph = OntoIO.read("Ontology/go_test.obo", "obo")
     self.assocs = OntoIO.read("Ontology/ga_test.fb", "gaf")
     self.ef = TermForTermEnrichmentFinder(self.assocs, self.go_graph)
def run_term(assocs, go_graph, gene_list, corrections):
    from Bio.Ontology import TermForTermEnrichmentFinder

    ef = TermForTermEnrichmentFinder(assocs, go_graph)
    result = ef.find_enrichment(gene_list, corrections)
    return result