# What is the difference between local and global sequence alignments?

There are a bunch of different alignment tools out there, and I don't want to get bogged down in the maths behind them as this not only between software but varies from software version to version.

There are two main divides in the programs; some use local alignments and others use global alignments. My question is threefold:

• What are the fundamental differences between the two?
• When should one use either a global or local sequence alignment?

The very basic difference between a local and a global alignments is that in a local alignment, you try to match your query with a substring (a portion) of your subject (reference). Whereas in a global alignment you perform an end to end alignment with the subject (and therefore as von mises said, you may end up with a lot of gaps in global alignment if the sizes of query and subject are dissimilar). You may have gaps in local alignment also.

Local Alignment

5' ACTACTAGATTACTTACGGATCAGGTACTTTAGAGGCTTGCAACCA 3'
|||| |||||| |||||||||||||||
5' TACTCACGGATGAGGTACTTTAGAGGC 3'


Global Alignment

5' ACTACTAGATTACTTACGGATCAGGTACTTTAGAGGCTTGCAACCA 3'
|||||||||||    |||||||  |||||||||||||| |||||||
5' ACTACTAGATT----ACGGATC--GTACTTTAGAGGCTAGCAACCA 3'


I shall give the example of the well known dynamic programming algorithms. In the Needleman-Wunsch (Global) algorithm, the score tracking is done from the (m,n) co-ordinate corresponding to the bottom right corner of the scoring matrix (i.e. the end of the aligned sequences) whereas in the Smith-Waterman (local), it is done from the element with highest score in the matrix (i.e. the end of the highest scoring pair). You can check these algorithms for details.

You can adopt any scoring schemes and there is no fixed rule for it.

Global alignments are usually done for comparing homologous genes whereas local alignment can be used to find homologous domains in otherwise non-homologous genes.

Global alignment is when you take the entirety of both sequences into consideration when finding alignments, whereas in local you may only take a small portion into account. This sounds confusing so here an example:

Let's say you have a large reference, maybe 2000 bp. And you have a sequence, which is about 100 bp. Let's say that the reference contains the sequence almost exactly. If you did a local alignment, you would have a very good match. But if you did a global alignment, it may not match. Instead, it may look for matches throughout the entire reference, so you'd end up with an alignment with many large gaps. It does not matter that it matches near perfectly at one particular region on the reference, because it's looking for matches globally (i.e. throughout the reference).

If you have a really good match it may not matter what type of alignment you use. But when you have mismatches and such it starts to get important. This is because of the scoring algorithms used. In the example above let's say that there is a 100bp region in the reference that matches your 100bp sequence with 85% accuracy. In local alignment it's very likely it will align there. Now let's say that the first 30 bp of your sequence matches a region in the beginning of the reference 95%, and the next 30bp matches a region in the middle of the reference 85%, and the final 40bp matches a region at the end of the reference about 90%. In global alignment the best match is the gapped alignment, whereas in local alignment the ungapped alignment would be best. I think in general gap penalties are less in global alignments, but I'm not really an expert on the scoring algorithms.

What you want to use depends on what you are doing. If you think your sequence is a subsequence of the reference, do a local alignment. But if you think your entire sequence should match your entire reference, you would do a global alignment.

Take look to the attached image file. It will clear your doubts about difference between local and global sequence alignments.

• Please do not post text answers as image files on SE Biology. This discriminates agains people with vision defects who use screen readers, and does not allow proper indexing. Commented Sep 27, 2018 at 21:53