source: orange-bioinformatics/docs/reference/obiGO.htm @ 1634:32373d957326

Revision 1634:32373d957326, 8.8 KB checked in by mitar, 2 years ago (diff)

Renamed addon reference documentation.

Line 
1<html>
2
3<head>
4<title>obiGO: Gene Ontology Handling Library</title>
5<link rel=stylesheet href="../style.css" type="text/css">
6<link rel=stylesheet href="style-print.css" type="text/css" media=print>
7</head>
8
9<body>
10<h1>obiGO: Gene Ontology Handling Library</h1>
11<index name="modules/gene ontology GO">
12<p>obiGO is a library for hadling gene ontology (GO) databases. <a href="http://www.geneontology.org/GO.doc.shtml">(More about GO).</a></p>
13
14<p class=section>Attributes</p>
15<dl class=attributes>
16    <dt>evidenceTypes</dt>
17    <dd>A dictionary with all evidence codes as keys and short description as values. </dd>
18</dl>
19
20<h2>Ontology</h2>
21<p>Ontology is the main class representing a gene ontology.</p>
22<p class=section>Attributes</p>
23<dl class=attributes>
24    <dt>terms</dt>
25    <dd>A dictionary mapping term ids to instances of Term </dd>
26</dl>
27
28<p class=section>Methods</p>
29<dl class=attributes>
30    <dt>__init__(file=None, progressCallback=None)</dt>
31    <dd>Initialize the ontology from <code>file</code> (if not given try and load ontology from default_database_path). The optional <code>progressCallback</code> will be called with a single argument to report on the progress.</dd>
32    <dt>Load(progressCallback=None)</dt>
33    <dd>A class method that tries to load the ontology file from default_database_path. It looks for a filename starting with 'gene_ontology'. The optional <code>progressCallback</code> will be called with a single argument to report on the progress.</dd>
34    <dt>ParseFile(file, progressCallback=None)</dt>
35    <dd>Parse the <code>file</code>. <code>file</code> can be a file name string or an open filelike object. The optional <code>progressCallback</code> will be called with a single argument to report on the progress.</dd>
36    <dt>ExtractSuperGraph(terms)</dt>
37    <dd>Return ids of all super terms of <code>terms</code> up to the most general one.</dd>
38    <dt>ExtractSubGraph(terms)</dt>
39    <dd>Return all sub terms of <code>terms</code>.</dd>
40    <dt>GetTermDepth(term)</dt>
41    <dd>Return the minimum depth of a term (length of the shortest path to this term from the top level term).</dd>
42    <dt>GetDefinedSlimsSubsets()</dt>
43    <dd>Return a list of defined subsets</dd>
44    <dt>SetSlimsSubset(subset)</dt>
45    <dd>Set the slims term subset to subset. If subset is a string it must equal one of the defined subsetdef.</dd>
46    <dt>GetSlimTerms(termId)</dt>
47    <dd>Return a list of slim terms for termId.</dd>
48    <dt>DownloadOntology(file, progressCallback=None)</dt>
49    <dd>A static method that downloads the ontology from the GO website and saves it in <code>file</code>.</dd>
50    <dt>__getitem__(termId)</dt>
51    <dd>return a Term object with <code>termID</code> as id or alt_id</dd>
52    <dt>__len__()</dt>
53    <dd>return the number of terms in the ontology</dd>
54    <dt>__iter__()</dt>
55    <dd>iterator over all term ids</dd>
56    <dt>__contains__(id)</dt>
57    <dd>check if a term with <code>id</code> is in the ontology (also checks alt_ids)</dd>
58</dl>
59
60<h2>Term</h2>
61<p>Term is a class that represents a term in the ontology</p>
62<p class=section>Attributes</p>
63<dl class=attributes>
64    <dt>id</dt>
65    <dd>The term id</dd>
66    <dt>name</dt>
67    <dd>The term name</dd>
68    <dt>namespace</dt>
69    <dd>The namespace of the term</dd>
70    <dt>def_</dt>
71    <dd>The term def entry (Note the use of trailing unserscore to avoid conflict with a python keyword)</dd>
72    <dt>is_a</dt>
73    <dd>List of term ids this term is a subterm of.</dd>
74    <dt>related</dt>
75    <dd>List of (relType, termId) tuples with relType specifying the relationship type with termId</dd>
76</dl>
77<h2>Annotations</h2>
78<p>Annotations object holds the annotations.</p>
79<p class=section>Attributes</p>
80<dl class=attributes>
81    <dt>geneAnnotations</dt>
82    <dd>A dictionary mapping a gene name (DB_Object_Symbol) to a set of all annotations of that gene</dd>
83    <dt>termAnnotations</dt>
84    <dd>A dictionary mapping a GO term id to a set of all annotations to that term</dd>
85    <dt>geneNames</dt>
86    <dd>A set of all gene names (all entrys from DB_Object_Symbol)</dd>
87    <dt>geneNamesDict</dt>
88    <dd>A dictionary mapping each unique identifier from DB_Object_ID, DB_Object_Symbol and DB_Object_Synonym to a list of all equivalent names</dd>
89    <dt>aliasMapper</dt>
90    <dd>A dictionary mapping each unique identifier from DB_Object_ID, DB_Object_Symbol and DB_Object_Synonym to a DB_Object_Symbol equivalent</dd>
91    <dt>annotations</dt>
92    <dd>A list of all AnnotationRecord instances</dd>
93</dl>
94<p class=section>Methods</p>
95<dl class=attributes>
96    <dt> __init__(file=None, ontology=None, genematcher=None, progressCallback=None)</dt>
97    <dd>Initialize the annotations from <code>file</code> by calling <code>ParseFile</code> on it. If file does not exist asume it is the name of the organism to be loaded from default_database_path. The <code>ontology</code> argument if present must be an instance of Ontology class. <code>genematcher</code> should be an instance of obiGene.Macher and defaults to obiGene.GMGO. The optional <code>progressCallback</code> will be called with a single argument to report on the progress.</dd>
98    <dt>Load(org, ontology=None, progressCallback=None)</dt>
99    <dd>A class method that tries to load the association file for the given organism from default_database_path. It trys to match the <code>org</code> with GO organism codes and if it fails, searches for org in NCBI Taxonomy using obiTaxonomy module.</dd>
100    <dt>ParseFile(self, file, progressCallback=None)</dt>
101    <dd>Parse the <code>file</code>. <code>file</code> can be a file name string or an open filelike object. The optional <code>progressCallback</code> will be called with a single argument to report on the progress.</dd>
102    <dt>GetAllAnnotations(term)</dt>
103    <dd>Return all annotations that are annotated to term whose id entry equals <code>id</code></dd>
104    <dt>GetAllGenes(id, evidenceCodes=None)</dt>
105    <dd>Return a list of genes annotated by specified evidence codes to this and all subterms.</dd>
106    <dt>GetEnrichedTerms(genes, reference=None, evidenceCodes=None, slimsOnly=False, aspect="P", prob=obiProb.Binomial(), progressCallback=None)</dt>
107    <dd>Return a dictionary of enriched terms, with tuples of (list_of_genes, p_value, reference_count) for items and term ids as keys. P-Values are FDR adjusted if useFDR is True (default).</dd>
108    <dt>GetAnnotatedTerms(genes, directAnnotationOnly=False, evidenceCodes=None, progressCallback=None)</dt>
109    <dd>Return all terms that are annotated by genes with evidenceCodes.</dd>
110    <dt>DownloadAnnotations(org, file, progressCallback=None)</dt>
111    <dd>A static method that downloads the annotation file for organism <code>org</code> to <code>file</code></dd>
112    <dt>__contains__(annotation)</dt>
113    <dd>check in annotations is in this Annotations object</dd>
114    <dt>__iter__</dt>
115    <dd>iterate over all annotations in this object</dd>
116    <dt>__len__()</dt>
117    <dd>retrun the number of annotations in this object</dd>
118    <dt></dt>
119    <dd></dd>
120</dl>
121
122<h2>Examples</h2>
123<p>Searching the annotation(part of <a href="obiGO-gene-annotations.py">obiGO-gene-annotations.py</a>)</p>
124<xmp class=code>import obiGO
125ontology = obiGO.Ontology.Load()
126# Print names and definitions of all terms with "apoptosis" in the name
127for term in [term for term in ontology.terms.values() if "apoptosis" in term.name.lower()]:
128    print term.name, term.id
129    print term.def_
130annotations = obiGO.Annotations.Load("sgd", ontology=ontology)
131annotations.GetEnrichedTerms(["YGR270W", "YIL075C", "YDL007W"])
132
133gene = annotations.aliasMapper["YIL075C"]
134print gene, "(YIL075C) directly annotated to the folowing terms:"
135for a in annotations.geneAnnotations[gene]:
136    print ontology[a.GO_ID].name, "with evidence code", a.Evidence_code
137   
138# Get all genes annotated to the same terms as YIL075C
139ids = set([a.GO_ID for a in annotations.geneAnnotations[gene]])
140for GOID in ids:
141    ants = annotations.GetAllAnnotations(GOID)
142    genes = set([a.geneName for a in ants])
143    print ", ".join(genes), "annotated to", GOID, ontology[a.GO_ID].name
144</xmp>
145
146<p>Term enrichment (part of <a href="obiGO-enrichment.py">obiGO-enrichment.py</a>)</p>
147<xmp class=code>res = annotations.GetEnrichedTerms(["YGR270W", "YIL075C", "YDL007W"])
148print "Enriched terms:"
149for GOId, (genes, p_value, ref) in res.items():
150    if p_value < 0.05:
151        print ontology[GOId].name, "with p-value: %.4f" %p_value, ", ".join(genes)
152
153# And again for slims
154ontology.SetSlimsSubset("goslim_yeast")
155
156res = annotations.GetEnrichedTerms(["YGR270W", "YIL075C", "YDL007W"], slimsOnly=True)
157print "Enriched slim terms:"
158for GOId, (genes, p_value, _) in res.items():
159    if p_value < 0.05:
160        print ontology[GOId].name, "with p-value: %.4f" %p_value, ", ".join(genes)
161</xmp>
162
163<p>Mapping to slim terms (part of <a href="obiGO-slim-mapping.py">obiGO-slim-mapping.py</a>)</p></p>
164<xmp class=code>ontology.SetSlimsSubset("goslim_yeast")
165terms = annotations.GetAnnotatedTerms(["YGR270W", "YIL075C", "YDL007W"], directAnnotationOnly=True)
166slims = set()
167for term in terms:
168    print term
169    slims.update(ontology.GetSlimTerms(term))
170
171print "Genes: YGR270W, YIL075C and YDL007W map to the folowing slims terms:"
172for term in slims:
173    print term, ontology[term].name
174</xmp>
Note: See TracBrowser for help on using the repository browser.