Shuffle DNA

Reorders the residues and keeps every count. Whole sequence, inside windows, or keeping dinucleotides.

Shuffled sequence

What does shuffling a sequence give you?

A control. Scores in sequence analysis, a motif hit, an alignment bit score, a folding energy, depend heavily on composition, so the honest question is not "is this score high?" but "is this score high for a sequence made of these residues?". Shuffled copies of the real sequence answer that: they keep the composition and destroy the order, so anything that survives is composition, and anything that disappears was order.

Every record is shuffled on its own and keeps its header, so a whole FASTA file can be turned into a matched control set in one step.

The three methods

  • Whole sequence. A Fisher-Yates shuffle of every residue. Base or amino acid counts are kept exactly; everything else is randomised.
  • Inside windows. The sequence is cut into windows of a size you set and each is shuffled separately, so composition is kept at that scale, not just overall. Use it when the signal you are testing is local, such as a GC-rich island or a hydrophobic stretch.
  • Keep dinucleotides. The Altschul and Erikson Eulerian path shuffle for DNA and RNA. All 16 dinucleotide counts survive as well as the base counts, and the first and last base stay in place. This is the control to use whenever CpG content, stacking energies or a Markov model of order 1 could explain the result.
read the sequence as a walk: each step s[i] → s[i+1] is one edge
draw a new walk that uses every edge exactly once (an Eulerian path)
same edges used = same dinucleotide counts

Worked example

"Try an example" loads the first 120 nt of the EGFP coding sequence: A 23, C 32, G 47, T 18, so 65.8% GC. Both shuffles return those same four counts. The difference shows in the pairs: the input contains 12 CG dinucleotides, the whole-sequence shuffle at seed 1 leaves 11 and would scatter around that number on every new draw, while "Keep dinucleotides" returns 12 every time, for CG and for the other fifteen pairs. The counts sit under Details.

How many shuffles do you need?

For a p-value from shuffled controls, the smallest value you can report is roughly 1 ÷ (N + 1) with N shuffles, so 99 shuffles reach p = 0.01 and 999 reach p = 0.001. Change the seed for each draw and keep a note of the seeds; the same seed always rebuilds the same shuffle.

To measure what changed, count the pairs or k-mers with thek-mer counter, compare composition insequence statistics, or look at order directly withShannon entropy. To invent a sequence instead of reordering one, use random DNA or sample DNA.

Frequently asked questions

Does shuffling change the composition?

No. Shuffling only reorders the residues that are already there, so every base or amino acid count, the length and the GC content come out exactly as they went in. The counts are listed under Details so you can check. What a shuffle destroys is order: motifs, repeats, codon structure and, unless you keep them, the dinucleotide frequencies.

What does a dinucleotide-preserving shuffle do differently?

A plain shuffle keeps single base counts but flattens the pairs, so a CpG-poor genome suddenly looks CpG-average and any score that reacts to dinucleotides shifts. The dinucleotide shuffle keeps the count of all 16 pairs as well, using the Eulerian path method of Altschul and Erikson: the sequence is read as a walk through a graph whose edges are the dinucleotides, and a different walk over the same edges is drawn.

Why would I shuffle a sequence at all?

To build a null model. Shuffled copies of the real sequence answer the question "how good would this score be by chance, for a sequence with this composition?", which is the control for motif hits, alignment scores, folding energies and gene-finder output. Composition alone explains a surprising share of such scores, so a shuffled control is a fairer baseline than a random sequence.

What does shuffling inside windows do?

The sequence is cut into windows of the size you set and each window is shuffled on its own. Local composition, such as a GC-rich island or a hydrophobic stretch, survives at the scale of the window while everything smaller is randomised. It is the right control when the property you are testing is local.

Is the result repeatable?

Yes. The seed drives a deterministic generator, so the same input and seed give the same shuffle in any browser, and editing another option does not redraw it. Press Shuffle again for a new draw, and note the seed shown with the result if you need to rebuild it later.