\HeaderA{consensus}{Build consensus tree out of bootstrap cluster result}{consensus}
\keyword{cluster}{consensus}
\begin{Description}\relax
This is the function to build the consensus tree from the bootstrap
clustering analysis. If the clustering algorithm is hierarchical
clustering, the majority rule consensus tree will be built based on
the given significance level. If the clustering algorithm is K-means, a
consensus K-means group will be built.
\end{Description}
\begin{Usage}
\begin{verbatim}
consensus(macluster, level = 0.8, draw=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{macluster}] An object of class \code{macluster}, which is the
output of \code{\LinkA{macluster}{macluster}}
\item[\code{level}] The significance level for the consensus tree. This is a
numeric number between 0.5 and 1.
\item[\code{draw}] A logical value to indicate whether to draw the consensus
tree on screen or not.
\end{ldescription}
\end{Arguments}
\begin{Value}
An object of class \code{consensus.hc} or \code{consensus.kmean}
according to the clustering method.
\end{Value}
\begin{Author}\relax
Hao Wu
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{macluster}{macluster}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# load data
data(abf1)
## Not run: 
# fit the anova model
fit.fix = fitmaanova(abf1,formula = ~Strain)
# test Strain effect 
test.fix = matest(abf1, fit.fix, term="Strain",n.perm= 1000)
# pick significant genes - pick the genes selected by Fs test
idx <- volcano(test.fix)$idx.Fs
# do k-means cluster on genes
gene.cluster <- macluster(fit.fix, term="Strain", idx, what="gene", 
   method="kmean", kmean.ngroups=5, n.perm=100)
# get the consensus group
genegroup = consensus(gene.cluster, 0.5)
# get the gene names belonging to each group
genegroupname = genegroup$groupname

# HC cluster on samples
sample.cluster <- macluster(fit.fix, term="Strain", idx, what="sample",method="hc")
# get the consensus group
consensus(sample.cluster, 0.5)
## End(Not run)\end{ExampleCode}
\end{Examples}

