\HeaderA{twilight.combi}{All permutations of a binary vector}{twilight.combi}
\keyword{datagen}{twilight.combi}
\begin{Description}\relax
For a given binary input vector, the function completely enumerates all possible permutations.
\end{Description}
\begin{Usage}
\begin{verbatim}
twilight.combi(xin, pin, bin)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{xin}] Binary input vector, e.g. class labels. 
\item[\code{pin}] Logical value. \code{TRUE} if samples are paired, \code{FALSE} if not. 
\item[\code{bin}] Logical value. \code{TRUE} if permutations should be balanced, \code{FALSE} if not. 
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Please note, that the resulting permutations are always as "balanced" as possible. The balancing is done for the smaller subsample. If its sample size is odd, say 5, \code{twilight.combi} computes all permutations with 2 or 3 samples unchanged. In the paired case, the output matrix contains only one half of all permutations. The second half is simply 1-\code{output} which leads to the same absolute test statistics in a paired test.
\end{Details}
\begin{Value}
Returns a matrix where each row contains one permuted vector. Note that even for balanced permutations, the first row always contains the original vector. If the number of rows exceeds 10000, \code{NULL} is returned.
\end{Value}
\begin{Author}\relax
Stefanie Scheid \url{http://www.molgen.mpg.de/~scheid}
\end{Author}
\begin{References}\relax
Scheid S and Spang R (2004): A stochastic downhill search algorithm for estimating the local false discovery rate, \emph{IEEE TCBB} \bold{1(3)}, 98--108.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{twilight.permute.pair}{twilight.permute.pair}}, \code{\LinkA{twilight.permute.unpair}{twilight.permute.unpair}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- c(rep(0,4),rep(1,3))
y <- twilight.combi(x,pin=FALSE,bin=FALSE)
\end{ExampleCode}
\end{Examples}

