\HeaderA{misc}{Some miscellaneous stuff}{misc}
\aliasA{N50}{misc}{N50}
\keyword{methods}{misc}
\begin{Description}\relax
Some miscellaneous stuff.
\end{Description}
\begin{Usage}
\begin{verbatim}
  N50(csizes)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{csizes}] A vector containing the contig sizes.

\end{ldescription}
\end{Arguments}
\begin{Value}
\code{N50}: The N50 value as an integer.
\end{Value}
\begin{Section}{The N50 contig size}
\bold{Definition}
The N50 contig size of an assembly (aka the N50 value) is the
size of the largest contig such that the contigs larger than
that have at least 50\% the bases of the assembly.

\bold{How is it calculated?}
It is calculated by adding the sizes of the biggest contigs until
you reach half the total size of the contigs.
The N50 value is then the size of the contig that was added last
(i.e. the smallest of the big contigs covering 50\% of the genome).

\bold{What for?}
The N50 value is a standard measure of the quality of a de novo
assembly.
\end{Section}
\begin{Author}\relax
Nicolas Delhomme <delhomme@embl.de>
\end{Author}
\begin{SeeAlso}\relax
\LinkA{XStringSet-class}{XStringSet.Rdash.class}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
  ## ---------------------------------------------------------------------
  ## A. The N50 contig size
  ## ---------------------------------------------------------------------

  # generate 10 random contigs of sizes comprised between 100 and 10000
  my.contig <- DNAStringSet(
                 sapply(
                   sample(c(100:10000), 10),
                   function(size)
                       paste(sample(DNA_BASES, size, replace=TRUE), collapse="")
                 )
               )

  # get their sizes
  my.size <- width(my.contig)

  # calculate the N50 value of this set of contigs
  my.contig.N50 <- N50(my.size)
\end{ExampleCode}
\end{Examples}

