\HeaderA{prune.graph}{Prunes spurious edges in a phenotypic hierarchy}{prune.graph}
\keyword{graphs}{prune.graph}
\begin{Description}\relax
A heuristic to prune spurious edges in a pehnotypic hierarchy
\end{Description}
\begin{Usage}
\begin{verbatim}
prune.graph(g,cutIN=NULL,cutOUT=NULL,quant=.95,verbose=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{g}] an adjacency matrix or a 'graphNEL' object
\item[\code{cutIN}] minimum number of missing in-edges required to cut all in-edges. Default
\item[\code{cutOUT}] minimum number of missing out-edges required to cut all out-edges
\item[\code{quant}] if 'cutIN' or 'cutOUT' are not assigned, a quantile 'quant' of the distribution of missing in- or out-edges for all nodes is used
\item[\code{verbose}] Default: TRUE
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
\code{prune.graph} provides a heuristic approach to prune surious edges.
\code{prune.graph} compares the input graph to its transitive closure, and counts for each node how many incoming and outgoing edges are missing.
If the number is bigger than a user-defined cutoff, all incoming (outgoing) edges are removed.
\end{Details}
\begin{Value}
\begin{ldescription}
\item[\code{graph}] the pruned phenotypic hierarchy (a 'graphNEL' object)
\item[\code{removed}] number of removed edges
\item[\code{missing.in}] number of missing in-edges for each node
\item[\code{missing.out}] number of missing out-edges for each node
\end{ldescription}
\end{Value}
\begin{Author}\relax
Florian Markowetz \textless{}URL: http://genomics.princeton.edu/\textasciitilde{}florian\textgreater{}
\end{Author}
\begin{Examples}
\begin{ExampleCode}
    # a transitively closed core with two spurious edges
    g <- matrix(0,5,5)
    g[1,2] <- 1
    g[2,c(3,4)] <- 1
    g[3,4] <- 1
    g[4,5] <- 1
    dimnames(g) <- list(LETTERS[1:5],LETTERS[1:5])
    g <- as(g,"graphNEL")
    
    # prune graph
    gP <- prune.graph(g)
    
    # plot
    par(mfrow=c(1,2))
    plot(g,main="two spurious edges")
    plot(gP$graph,main="pruned")
    
    
\end{ExampleCode}
\end{Examples}

