\HeaderA{nem}{Nested Effects Models - main function}{nem}
\aliasA{print.ModuleNetwork}{nem}{print.ModuleNetwork}
\aliasA{print.nem}{nem}{print.nem}
\methaliasA{print.nem.BN}{nem}{print.nem.BN}
\methaliasA{print.nem.greedy}{nem}{print.nem.greedy}
\methaliasA{print.nem.greedyMAP}{nem}{print.nem.greedyMAP}
\aliasA{print.pairwise}{nem}{print.pairwise}
\aliasA{print.score}{nem}{print.score}
\aliasA{print.triples}{nem}{print.triples}
\keyword{graphs}{nem}
\keyword{models}{nem}
\begin{Description}\relax
The main function to perform model learning from data
\end{Description}
\begin{Usage}
\begin{verbatim}
nem(D,inference="nem.greedy",models=NULL,control=set.default.parameters(setdiff(unique(colnames(D)),"time")), verbose=TRUE)

## S3 method for class 'nem':
print(x, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{D}] data matrix with experiments in the columns (binary or continious)
\item[\code{inference}] \code{search} to use exhaustive enumeration, \code{triples} for triple-based inference, \code{pairwise} for the pairwise heuristic, \code{ModuleNetwork} for the module based inference, \code{nem.greedy} for greedy hillclimbing, \code{nem.greedyMAP} for alternating MAP optimization using log odds or log p-value densities
\item[\code{models}] a list of adjacency matrices for model search. If NULL, an  exhaustive enumeration of all possible models is performed.
\item[\code{control}] list of parameters: see \code{set.default.parameters}
\item[\code{verbose}] do you want to see progression statements? Default: TRUE
\item[\code{x}] nem object
\item[\code{...}] other arguments to pass
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If parameter Pm != NULL and parameter lambda == 0, a Bayesian approach to include prior knowledge is used. Alternatively, the regularization parameter lambda can be tuned in a model selection step via the function \code{nemModelSelection} using the BIC criterion. 
If automated subset selection of effect reporters is used and parameter type == CONTmLLMAP, the regularization parameter delta is tuned via the AIC model selection criterion. Otherwise, an iterative algorithm is executed, which in an alternating optimization scheme reconstructs a network given the current set of effect reporters and then selects the effect reporters having the highest likelihood under the given network. The procedure is run until convergence.

The function \code{plot.nem} plots the inferred phenotypic hierarchy as a directed graph, the likelihood distribution of the models (only for exhaustive search) or the posterior position of the effected genes.
\end{Details}
\begin{Value}
\begin{ldescription}
\item[\code{graph}] the inferred directed graph (graphNEL object)
\item[\code{mLL}] log posterior marginal likelihood of final model
\item[\code{pos}] posterior over effect positions
\item[\code{mappos}] MAP estimate of effect positions
\item[\code{selected}] selected E-gene subset
\item[\code{LLperGene}] likelihood per selected E-gene
\item[\code{control}] hyperparameter as in function call
\end{ldescription}
\end{Value}
\begin{Author}\relax
Holger Froehlich \textless{}URL: http:/www.dkfz.de/mga2/people/froehlich\textgreater{}, Florian Markowetz \textless{}URL: http://genomics.princeton.edu/\textasciitilde{}florian\textgreater{}
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{set.default.parameters}{set.default.parameters}}, \code{\LinkA{nemModelSelection}{nemModelSelection}}, \code{\LinkA{nem.jackknife}{nem.jackknife}}, \code{\LinkA{nem.bootstrap}{nem.bootstrap}}, \code{\LinkA{nem.consensus}{nem.consensus}}, \code{\LinkA{local.model.prior}{local.model.prior}}, \code{\LinkA{plot.nem}{plot.nem}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
   data("BoutrosRNAi2002")
   D <- BoutrosRNAiDiscrete[,9:16]
   control = set.default.parameters(unique(colnames(D)), para=c(0.13, 0.05))   
   res1 <- nem(D,inference="search", control=control)
   res2 <- nem(D,inference="pairwise", control=control)
   res3 <- nem(D,inference="triples", control=control)
   res4 <- nem(D,inference="ModuleNetwork", control=control)
   res5 <- nem(D,inference="nem.greedy", control=control)        
   res6 = nem(BoutrosRNAiLods, inference="nem.greedyMAP", control=control)
   

   par(mfrow=c(2,3))
   plot.nem(res1,main="exhaustive search")
   plot.nem(res2,main="pairs")
   plot.nem(res3,main="triples")
   plot.nem(res4,main="module network")
   plot.nem(res5,main="greedy hillclimber")      
   plot.nem(res6,main="alternating MAP optimization")
\end{ExampleCode}
\end{Examples}

