This file is indexed.

/usr/lib/R/site-library/annotate/doc/GOusage.Rnw is in r-bioc-annotate 1.56.1+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
%
% NOTE -- ONLY EDIT THE .Rnw FILE!!!  The .tex file is
% likely to be overwritten.
%
%\VignetteIndexEntry{Basic GO Usage}
%\VignetteDepends{GO.db, hgu95av2.db, Biobase}
%\VignetteSuggests{Rgraphviz, org.Hs.eg.db}
%\VignetteKeywords{GO, ontology}
%\VignettePackage{annotate}
\documentclass[12pt]{article}

\usepackage{times}
\usepackage{hyperref}

\usepackage[authoryear,round]{natbib}
\usepackage{times}
\usepackage{comment}

\textwidth=6.2in
\textheight=8.5in
%\parskip=.3cm
\oddsidemargin=.1in
\evensidemargin=.1in
\headheight=-.3in

\newcommand{\scscst}{\scriptscriptstyle}
\newcommand{\scst}{\scriptstyle}

\newcommand{\Rfunction}[1]{{\texttt{#1}}}
\newcommand{\Robject}[1]{{\texttt{#1}}}
\newcommand{\Rpackage}[1]{{\textit{#1}}}
\newcommand{\Rclass}[1]{{\textit{#1}}}

\bibliographystyle{plainnat}

\title{Basic GO Usage}
\author{R. Gentleman}

\begin{document}

\maketitle

\section*{Introduction}

<<Setup, echo=FALSE, results=hide>>=
library("Biobase")
library("annotate")
library("xtable")
require("Rgraphviz", quietly=TRUE)
library("hgu95av2.db")
library("GO.db")
@

In this vignette we describe some of the basic characteristics of the
data available from the Gene Ontology (GO), \citep{GO} and how these
data have been incorporated into Bioconductor. We assume that readers
are familiar with the basic DAG structure of GO and with the mappings
of genes to GO terms that are provide by GOA \citep{GOA}. We consider
these basic structures and properties quite briefly.

GO, itself, is a structured terminology. The ontology describes genes
and gene products and is divided into three separate ontologies. One
for cellular component (CC), one for molecular function (MF) and one
for biological process (BP). We maintain those same distinctions were
appropriate. The relationship between terms is a parent-child one,
where the parents of any term are less specific than the child. The
mapping in either direction can be one to many (so a child may have
many parents and a parent may have many children). There is a single
root node for all ontologies as well as separate root nodes for each
of the three ontologies named above. These terms are structured as a
directed acyclic graph (or a DAG).

GO itself is only the collection of terms; the descriptions of genes,
gene products, what they do, where they do it and so on. But there is
no direct association of genes to terms. The assignment of genes to
terms is carried out by others, in particular the GOA project
\citep{GOA}. It is this assignment that makes GO useful for data
analysis and hence it is the combined relationship between the
structure of the terms and the assignment of genes to terms that is
the concern of the \Rpackage{GO.db} package.

The basis for child-parent relationships in GO can be either an
\textit{is-a} relationship, where the child term is a more specific
version of the parent. Or, it can be a \textit{has-a}, or
\textit{part-of} relationship where the child is a part of the
parent. For example a telomere is a part-of a chromosome.

Genes are assigned to terms on the basis of their LocusLink ID. For
this reason we make most of our mappings and functions work for
LocusLink identifiers. Users of specific chips, or data with other
gene identifiers should first map their identifiers to LocusLink
before using \Rpackage{GOstats}.

A gene is mapped only to the most specific terms that are applicable
to it (in each ontology). Then, all less specific terms are also
applicable and they are easily obtained by traversing the set of
parent relationships down to the root node. In practice many of these
mappings are precomputed and easily obtained from the different hash
tables provided by the \Rpackage{GO.db} package.

Mapping of a gene to a term can be based on many different things. GO
and GOA provide an extensive set of evidence codes, some of which are
given in Table~\ref{tab:EC}, but readers are referred to the GO web
site and the documentation for the \Rpackage{GO.db} package for a more
comprehensive listing. Clearly for some investigations one will want
to exclude genes that were mapped according to some of the evidence
codes.

\begin{table}[ht]
\begin{center}
\begin{tabular}{|c|l|}
\hline
 IMP & inferred from mutant phenotype \\
  IGI & inferred from genetic interaction \\
  IPI & inferred from physical interaction \\
  ISS & inferred from sequence similarity \\
  IDA & inferred from direct assay \\
  IEP & inferred from expression pattern \\
  IEA & inferred from electronic annotation \\
  TAS & traceable author statement \\
  NAS & non-traceable author statement \\
  ND & no biological data available \\
  IC & inferred by curator \\
\hline
\end{tabular}
\end{center}
\caption{GO Evidence Codes \label{tab:EC}}
\end{table}

In some sense TAS is probably the most reliable of the mappings. IEA
is a weak association and is based on electronic information, no human
curator has examined or confirmed this association. As we shall see
later, IEA is also the most common evidence code.

The sets of mappings of interest are roughly divided into three
parts. First there is the basic description of the terms etc., these
are provided in the \Robject{GOTERMS} hash table. Each element of this
hash table is named using its GO identifier (these are all of the
form \texttt{GO:} followed by seven digits). Each element is an
instance of the \Robject{GOTerms} class. A complete description of
this class can be obtained from the appropriate manual page (use
\verb+class?GOTerms+).
From these data we can find the text string describing the term, which
ontology it is in as well as some other basic information.

There are also a set of hash tables that contain the information about
parents and children. They are provided as hash tables (the
\texttt{XX}  in the names below should be substituted for one of
\texttt{BP}, \texttt{MF}, or \texttt{CC}.
\begin{itemize}
\item \texttt{GOXXPARENTS}: the parents of the term
\item \texttt{GOXXANCESTOR}: the parents, and all their parents and
      so on.
\item \texttt{GOXXCHILDREN}: the children of the term
\item \texttt{GOXXOFFSPRING}: the children, their children and so on
      out to the leaves of the GO graph.
\end{itemize}

For the \texttt{GOXXPARENTS} mappings (only) information about the
nature of the relationship is included.

<<parentrel>>=
 GOTERM$"GO:0003700"

 GOMFPARENTS$"GO:0003700"
 GOMFCHILDREN$"GO:0003700"

@
%%FIXME: text here should be checked against code
Here we see that the term \texttt{GO:0003700} has two parents, that the
relationships are \texttt{is-a} and that it has one child. One can
then follow this chains of relationships or use the \texttt{ANCESTOR}
and \texttt{OFFSPRING} hash tables to get more information.

The mappings of genes to GO terms is not contained in the \texttt{GO}
package. Rather these mappings are held in each of the chip and
organism specific data packages, such as \Robject{hgu95av2GO} and
\Robject{org.Hs.egGO} are contained within packages \texttt{hgu95av2.db}
and \texttt{org.Hs.eg.db} respectively. These mappings are from a
Entrez Gene ID to the most specific applicable GO terms. Each such
entry is a list of lists where the innermost list has these names:
\begin{itemize}
\item \texttt{GOID}: the GO identifier
\item \texttt{Evidence}: the evidence code for the assignment
\item \texttt{Ontology}: the ontology the GO identifier belongs to
      (one of \texttt{BP}, \texttt{MF}, or \texttt{CC}).
\end{itemize}

Some genes are mapped to a GO identifier based on two or more evidence
codes. Currently these appear as separate entries. So you may want to
remove duplicate entries if you are not interested in evidence
codes. However, as more sophisticated use is made of these data it
will be important to be able to separate out mappings according to
specific evidence codes.

In this next example we consider the gene with Entrez Gene ID
\texttt{4121}, this corresponds to Affymetrix ID \texttt{39613\_at}.

<<locusid>>=

 ll1 = hgu95av2GO[["39613_at"]]
 length(ll1)
 sapply(ll1, function(x) x$Ontology)

@

We see that there are \Sexpr{length(ll1)} different mappings.
We can get only those mappings for the \texttt{BP} ontology by using
\Rfunction{getOntology}.
We can get the evidence codes using \Rfunction{getEvidence} and we can
drop those codes we do not wish to use by using \Rfunction{dropECode}.

<<getmappings>>=

getOntology(ll1, "BP")
getEvidence(ll1)
zz = dropECode(ll1)
getEvidence(zz)

@


\subsection*{A Basic Description of GO}

We now characterize GO and some of its properties.
First we list some of the specific GO IDs that might be of interest
(please feel free to propose even more).

\begin{itemize}
\item \texttt{GO:0003673} is the GO root.
\item \texttt{GO:0003674} is the MF root.
\item \texttt{GO:0005575} is the CC root.
\item \texttt{GO:0008150} is the BP root.
\item \texttt{GO:0000004} is biological process unknown
\item \texttt{GO:0005554} is molecular function unknown
\item \texttt{GO:0008372} is cellular component unknown
\end{itemize}

We can find out how many terms are in each of the different ontologies
by:
<<sizeofonts>>=

 zz = Ontology(GOTERM)
 table(unlist(zz))

@

Or we can ask about the number of is-a and partof relationships in
each of the three different ontologies.

<<isa-partof>>=

 BPisa = eapply(GOBPPARENTS, function(x) names(x))
 table(unlist(BPisa))

 MFisa = eapply(GOMFPARENTS, function(x) names(x))
 table(unlist(MFisa))

 CCisa = eapply(GOCCPARENTS, function(x) names(x))
 table(unlist(CCisa))

@


\section*{Working with GO}

Finding terms that have specific character strings in them is easily
accomplished using \Rfunction{grep}. In the next example we first
convert the data from \Robject{GOTERM} into a character vector to make
it easier to do multiple searches.

<<finding these>>=
 goterms = unlist(Term(GOTERM))
 whmf = grep("fertilization", goterms)
@

So we see that there are \Sexpr{length(whmf)} terms with the string
``fertilization'' in them in the ontology. They can be accessed
by subsetting the \Robject{goterms} object.

<<subsetGT>>=
 goterms[whmf]

@

\subsection*{Working with chip specific meta-data}

In some cases users will want to restrict their attention to the set
of terms etc that map to genes that were assayed in the experiments
that they are working with. To do this you should first get the
appropriate chip specific meta-data file. Here we demonstrate some of
the examples on the Affymetrix HGu95av2 chips and so use the package
\Rpackage{hgu95av2.db}. Each of these packages has a data environment
whose name is the basename of the package with a \texttt{GO} suffix, so in
this case \Robject{hgu95av2GO}. Note that if there are many manufacturer
ids that map to the same Entrez Gene identifier then these will be
duplicate entries (with different keys).

We can get all the \texttt{MF} terms for our Affymetrix data.

<<getMF>>=
affyGO = eapply(hgu95av2GO, getOntology)
table(sapply(affyGO, length))

@

How many of these probes have multiple GO
terms associated with them? What do we do if we want to compare two
genes that have multiple GO terms associated with them?

What about evidence codes? To find these we apply a similar function
to the affyGO terms.

<<getEvidence>>=
affyEv = eapply(hgu95av2GO, getEvidence)

table(unlist(affyEv, use.names=FALSE))

@

<<dropOneEvidence>>=
test1 = eapply(hgu95av2GO, dropECode, c("IEA", "NR"))

table(unlist(sapply(test1, getEvidence),
             use.names=FALSE))
@

These functions make is somewhat straightforward to select subsets of
the GO terms that are specific to different evidence codes.

\bibliography{annotate}

\end{document}