\HeaderA{makeGOGraph}{Construct a GO Graph}{makeGOGraph}
\keyword{manip}{makeGOGraph}
\begin{Description}\relax
The directed acyclic graph (DAG) based on finding the most specific
terms for the supplied Entrez Gene IDs is constructed and returned. The
constructuion is per GO ontology (there are three, MF, BP and CC) and
once the most specific terms have been identified then all less
specific terms are found (these are the parents of the terms) and then
their parents and so on, until the root is encountered.
\end{Description}
\begin{Usage}
\begin{verbatim}
makeGOGraph(x, Ontology = "MF", removeRoot = TRUE, mapfun = NULL,
            chip = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] A vector of Entrez Gene IDs. 
\item[\code{Ontology}] Which GO ontology to use (CC, BP, or MF). 
\item[\code{removeRoot}] A logical value indicating whether the GO root node
should be removed or not.
\item[\code{mapfun}] A function taking a character vector of Entrez Gene IDs
as its only argument and returning a list of "GO lists" matching the
structure of the lists in the GO maps of annotation data packages.
The function should behave similarly to
\code{mget(x, eg2gomap, ifnotfound=NA)},
that is, \code{NA} should be returned if a specified Entrez ID has
no GO mapping.  See details for the interaction of \code{mapfun} and
\code{chip}.
\item[\code{chip}] The name of a DB-based annotation data package (the name
will end in ".db").  This package will be used to generate an Entrez
ID to GO ID mapping instead of \code{mapfun}.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
For each supplied Entrez Gene identifier all the GO annotations (in the
specified ontology) are found.  The mapping is achieved in one of
three ways:

\Enumerate{
\item If \code{mapfun} is provided, it will be used to perform the
needed lookups.  In this case, \code{chip} will be ignored.

\item If \code{chip} is provided and \code{mapfun=NULL}, then the
needed lookups will be done based on the Entrez to GO mappings
encapsulated in the specified annotation data package.  This is
the recommended usage.

\item If \code{mapfun} and \code{chip} are \code{NULL} or missing,
then the function will attempt to load the GO package (the
environment-based package, distinct from GO.db).  This package
contains a legacy environment mapping Entrez IDs to GO IDs.  If
the GO package is not available, an error will be raised.
Omitting both \code{mapfun} and \code{chip} is not recommended as
it is not compatible with the DB-based annotation data packages.
}

The mappings are different for the different ontologies. Typically a
GO indentifier is used only in one specific ontology.

The resulting structure is stored in a graph using the \code{graph}
package, again from Bioconductor.
\end{Details}
\begin{Value}
An object that inherits from the \code{graph} class. The particular
implementation is not specified.
\end{Value}
\begin{Author}\relax
R. Gentleman
\end{Author}
\begin{References}\relax
The Gene Ontology Consortium
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{oneGOGraph}{oneGOGraph}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
 library("hgu95av2.db")
 set.seed(321)
 uniqun <- function(x) unique(unlist(x))
 gN <- uniqun(sample(hgu95av2ENTREZID, 4))
 gg1 <- makeGOGraph(gN, "BP", chip="hgu95av2.db")

\end{ExampleCode}
\end{Examples}

