Class 6: Finding Local Alignments

Bioinformatics

Andrés Aravena

October 20, 2022

In the previous classes

  • Partial match
    • Hamming distance: count mismatches
    • Levenstein distance: count mismatches and indels
  • Dot plots
  • Global and semi-global alignment

Different questions need different alignments

Different alignments for different questions

  • Global alignment compares genes to genes, or proteins to proteins
    • We expect that both sequences are similar
  • Semi-global alignment compares genes to genomes
    • We expect that query is similar to part of subject
  • Local alignment compares genomes to genomes
    • We expect that part of the query is similar to part of subject

Global, Semi-Global and Local alignment

Global
all sequences must match.
Each gap is penalized
Semi-global
all sequences must match, but one may be shorter than the other.
external gaps are not penalized
Local
Some part of the sequence must match
external gaps are not penalized
can be with or without internal gaps

Global v/s local

Wikipedia

Part of query to part of subject

ABRACADABRA
CHUPACABRA

We have two alignments

      ABRACADABRA      ABRACADABRA
      ||||                    ||||
CHUPACABRA              CHUPACABRA

External gaps do not count

Dot plots show the alignments

Here there is no alignment

One ungapped alignment

Two ungapped alignments, or one gapped

Local alignment is not like global alignment

We found global alignment using distances

“Distance” means that smaller numbers are better

If the distance is 0, then the two sequences are identical

If the distance is small, the two sequences are similar

If the distance is big, the sequences are different

Local alignment is not a distance

Since external gaps do not count, we can always use them

In this case the smallest distance is always 0

The smallest cost is achieved taking one letter

         ABRACADABRA
         |
CHUPACABRA

We cannot find local alignments using small values

(it is not a minimization problem)

Score instead of distance

Instead of finding a minimum, we look for a maximum

  • Matching places get positive score
  • Mismatch and gaps get negative score

The philosophy is the same, but we look for big numbers instead of small numbers

We look for the Optimal Alignment

Dot plot becomes a matrix

Initially we placed 1 or 0 on each cell depending on match or mismatch

Now we put positive or negative numbers, depending of single-letter scores

\[D_{i,j} = \text{Score}(q_i,s_j)\]

We can find optimal alignment efficiently

Once the “dot plot matrix” is complete, it is easy to find the optimal score

  • Global alignment: find the largest sum from corner to corner

  • Semi-global alignment: find the largest sum from side to side

  • Local alignment: find the largest sum in any diagonal

Check Google Sheets

Local alignment score formula

We have three options as before, but not negative values

\[M_{i,j} = \max\begin{cases} M_{i,j} + \text{Score}(q_i,s_j)\\ M_{i-1,j} + \text{gap} \\ M_{i,j -1} + \text{gap}\\ 0\end{cases}\]

Notice we use \(\max\) instead of \(\min\)

Check Google Sheets

Gaps

Gap penalty

We prefer this alignment

GGGTAACCTACCTC
||| ||||| ||||
GGGCAACCTGCCTC

instead of this other alignment

GGGT-AACCTA-CCTC
|||  |||||  ||||
GGG-CAACCT-GCCTC

Thus, gap penalty must be greater than mismatch penalty

Long gaps instead of short ones

We prefer this alignment

TCAAAGAG---GATA
|||  |||   ||||
TCA--GAGGGGGATA

instead of this other alignment

TCAAAGA-G-G-ATA
|| | || | | |||
TC-A-GAGGGGGATA

We want few long gaps instead of many short gaps

Affine gaps

Gap values must reflect how real insertions and deletions occur in nature

We observe that, once an indel event starts, it can easily grow

If the polymerase jumps, then it can jump a long distance

To represent this, we use affine gaps

Linear v/s affine

So far we considered only linear gaps

The penalty of \(n\) consecutive gaps is \(n\cdot G\)
(\(G\) is the gap penalty)

Now we consider affine gaps, where the first gap is expensive, but the consecutive are cheap

The penalty of \(n\) consecutive gaps is \(I + n\cdot E\)

\(I\) is the initial gap penalty, \(E\) is the gap extension penalty

Traceback

Traceback

After we built the matrix, we must go back from the “optimal score” finding which was the path

There may be more than one solution

Some programs build the alignment at the same time they build the matrix, but that requires more memory

Example

Solution 1

GCAT-GCU
G-ATTACA

Solution 2

GCA-TGCU
G-ATTACA

Solution 3

GCATG-CU
G-ATTACA

Alignment score depends on Substitution matrix

Score can change

If mismatches and gaps have different cost, the score will change

Sometimes the optimal alignment changes

Therefore alignments are meaningless without knowing the scoring matrices

Later we will discuss how to choose the “best” scoring matrix for each case

What is the best score?

We want big scores

How big is big enough?

We need to make several hypothesis

The most common hypothesis is statistical

Larger scores, less hits

A hit is a subject with score over a threshold

Larger score thresholds give less hits

We can estimate the number of hits in a given database, assuming randomness

That is called Expected value

Expected value as a threshold

In practice, we choose a small Expected value

(usually called E-value)

Something like 10-5 or 10-20

What we find is not random
and maybe it is biologically meaningful

E-value depends on the database

The formula for E-value depends on

  • The score \(S\)
  • The query size \(m\)
  • The database size \(n\)
  • The substitution scoring matrix, via \(k\) and \(λ\)

\[E=kmn\exp(-λ S)\]

Same alignments in different databases have different E-value
but the same score

Use the smallest relevant database