# An example for N50? Why do we need it?

I'm trying to understand N50 on the wikipedia. But I was unable to get a sense of the definition:

Given a set of contigs, each with its own length, the N50 length is defined as the length for which the collection of all contigs of that length or longer contains at least half of the sum of the lengths of all contigs, and for which the collection of all contigs of that length or shorter also contains at least half of the sum of the lengths of all contigs.

Is there a simple example that illustrates this definition? Furthermore, why do we need this statistic? What does it really tell me? Do we want a higher or less value?

Contig or scaffold N50 is a weighted median statistic such that 50% of the entire assembly is contained in contigs or scaffolds equal to or larger than this value.

Mathematically:

Given a set of sequences of varying lengths, the N50 length is defined as the length N for which 50% of all bases in the sequences are in a sequence of length L < N. This can be found mathematically as follows: Take a list L of positive integers. Create another list L' , which is identical to L, except that every element n in L has been replaced with n copies of itself. Then the median of L' is the N50 of L. For example: If L = {2, 2, 2, 3, 3, 4, 8, 8}, then L' consists of six 2's, six 3's, four 4's, and sixteen 8's; the N50 of L is the median of L' , which is 6.

In simple words:

scaffold N50 is the median contig size of your genomic assembly. It's a metric that you can use to evaluate the quality of your assembly, since an overly small N50 suggests that you were unable to generate many contigs of biologically meaningful size (i.e. you probably have a lot of bogus little contigs in your assembly). You can increase your N50 by eliminating sequences which are bound to cause you problems, e.g. short repetitive stretches.

note that this metric only applies when doing de novo assembly. If you are aligning to a reference (i.e. for variant discovery applications) this metric doesn't apply

For a sample workout on an arbitrary small dataset: http://www.r-bloggers.com/calculating-an-n50-from-velvet-output/

This answer was compiled from multiple sources: