















Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!
















The process of puzzling together a complete genome sequence of an organism for which “shotgun sequencing” has been
performed is referred to as genome assembly.
The Poisson distribution expresses the probability of a given number of events occurring in a fixed interval of time
and/or space if these events are iid (independent and identically distributed).
−𝜆
𝑘
k refers to number of reads that overlap a certain genomic position (“coverage”)
𝝀: mean sequencing depth (average number of reads covering each base in the genome)
G : genome size
L : read length
N : number of reads
𝒃
: total number of sequenced bases
𝑏
𝑏
k-mers: subsequences with k nucleotides
In general, there are L-k+1 k-mer subsequences in a sequence of length L.
If we have N reads, each of which has L-k+1 k-mer subsequences, total number of k-mers:
𝑘
The coverage depth for k-mers is: 𝑑
𝑘
𝑛
𝑘
𝐺
The ratio between the coverage depth for bases and that for k-mers is:
𝜆
𝑑
𝑘
𝑛
𝑏
𝐺
𝑛
𝑘
𝐺
𝐿
𝐿−𝑘+ 1
We can estimate the genome size: 𝐺 ≈
𝑛 𝑘
𝑑 𝑘
We can estimate the average base coverage: 𝜆 ≈
𝐿
𝐿−𝑘+ 1
𝑘
We can now use the mean base coverage estimate l to estimate the probability that a given base will not be covered:
−𝜆
Therefore, the probability of seeing at least one read at a given position is: 𝑃(𝑋 > 0 ) = 1 − 𝑒
−𝜆
Contigs: combinations of overlapping reads that represent contiguous sequence.
In a genome of length G, a read of length L can start anywhere. Approximation for the expected number of reads
starting at a specific genomic location (base) i: 𝑁
𝑖
𝑁
𝐺
Consider an interval I that is as long as a read (L nucleotides) the expected number of reads that start in I is:
𝑁
𝐺
= 𝜆 → the probability that no read starts in I is 𝑒
−𝜆
and that at least one read starts in I is 1 − 𝑒
−𝜆
We can estimate the number of nucleotides in gaps across the entire assembly as 𝐺 × 𝑒
−𝜆
. Correspondingly, the
number of nucleotides included in contigs is 𝐺 × ( 1 − 𝑒
−𝜆
) → The fraction of the genome which will be covered
by contigs depends on the “sequencing depth”.
The number of contigs must be equal to the number of rightmost reads. Thus, the expected number of contigs
is 𝑁 × 𝑒
−𝜆
and the excepted number of reads per contigs is then
1
𝑒
−𝜆
→ the excepted size of a contig is
( 1 −𝑒
−𝜆
)𝐺
𝑁𝑒
−𝜆
𝜽: refer to the minimum portion of L that is required to detect an overlap
The expected number of contigs is then N (number of reads) times the probability that a read is the rightmost
read of an island, which is equivalent to their being no reads starting in
−
( 1 −𝜃
) 𝐿𝑁/𝐺
Put each of the k-mers into the node of a graph and connect the graph by edges.
A Hamiltonian path is a path in an undirected or directed graph that visits each vertex exactly once.
Instead of labeling the nodes with the k-mer subsequences, let us label the edges with these k-mers, we will then label
the nodes with the (k-1)-mers. Let us now merge identically labeled nodes in this graph: we will merge identical nodes
whilst retaining the edges. Eulerian path problem: find a path to visit each edge exactly once.
The de Bruijn graph of a collection of k-mers is a representation of every k-mer as an edge between its prefix and its
suffix. The nodes of the graph are thus the (k-1)-mer suffixes and prefixes. All nodes with identical labels are merged,
preserving edges. Finally (and optionally), unambiguous paths can be compressed by uniting their nodes.
A Eulerian cycle is a path that traverses every edge exactly once and returns at the end of the traversal to the start node.
A traversable graph is one that can be drawn without taking a pen from the paper and without retracing the same edge.
In such a case the graph is said to have an Eulerian path (a trail in a graph which visits every edge exactly once).
The pattern is related to the degrees of the vertices of the graph (degree = number of edges ending/starting at the vertex).
When the degree of all the vertices is even, the graph is traversable and we can draw it starting at any vertex
(Eulerian cycle). In directed graphs: all vertices have the same number of incoming and outgoing edges.
If there are exactly two vertices of odd degree and all other vertices are of even degree, there is a Eulerian path
(starting at one of the odd vertices), but no cycle. In directed graphs: one vertex has degree in
= 1, one
vertex has degree in
= - 1, all other vertices have degree in
If there are more than two odd vertices the graph cannot be traversed without repeating an edge.
We have constructed a de Bruijn graph from our sequencing data (k-mers taken from our sequenced reads), now we
need to find a Eulerian path (visit all edges once) to reconstruct the genome.
For directed graphs: start at the vertex with one more outgoing edge, end at the vertex with one more incoming edge.
Hierholzer’s algorithm
Yes: pop u from tpath and push it to epath
No: select a random outgoing edge (u;x); push x to tpath and delete the edge (u;x) from the set of edges E
➔ The Eulerian path will be in epath (with the starting vertex on the TOP and the end vertex on the BOTTOM)
To summarize:
Given strings 𝑎 = 𝑎
1
2
𝑛
(rows) and 𝑏 = 𝑏
1
2
𝑚
(columns)
Diagonal move from cell (i, j) to cell (i- 1 , j-1): align a i
with b j
Vertical move from cell (i, j) to cell (i- 1 , j): align a i
with - (gap)
Horizontal move from cell (i, j) to cell (i, j-1): align b j
with - (gap)
Efficient backtracking:
No need to perform all calculations again; we just need to keep track of what choice we made every time we fill
a cell in the original computation.
Every cell will have a “pointer” to the previous cell giving it the best solution. This way, backtracking will just
be a walk from cell (n, m) to cell (0, 0), following the pointers.
“Weighted” edit distance
Given two strings a and b on an alphabet Σ, the edit distance E(a, b) can be also defined as the minimum-weight
series of edit operations that transforms a into b.
) = min
𝑖𝑑
𝑖𝑑
𝑖
𝑗
𝑖
𝑗
𝑖
𝑗
We can use the same weight w id
for insertions and deletions, and for substitutions the weight w(a i
, b j
) depends
on the symbols.
Weights are positive; high weight = strong penalization of the edit operation.
Instead of measuring the distance between strings, evaluate their similarity.
Percent identity: after alignment, determine percentage (fraction of positions) of the alignment which does not indicate
and edit operation.
Subsequence: derived by deleting some, all or no characters; the order of the remaining elements remains unchanged.
Longest common subsequence (LCS) problem
𝐿𝐶𝑆(𝑎(𝑖), 𝑏(𝑗)) = max
𝑖
𝑗
𝑖
𝑗
LCS will be the maximum number of matching symbols without changing the order (minimum number of gaps
and mismatches).
Prepare a matrix with |a|+1 rows and |b|+1 columns
Each row and column is labeled with one character of a and b, respectively
Set the first row and column to 0, because 𝐿𝐶𝑆(𝑎(𝑖), 𝜖) = 0 ∀𝑖 and 𝐿𝐶𝑆(𝜖, 𝑏(𝑗)) = 0 ∀𝑗
Fill the cells progessively: cell (I, j) will contain LCS(a(i), b(j))
Take the best preceeding cell (horizontal, vertical or diagonal) and add 1 if a i
= b j
We can trace back the path to rebuild the solution string (LCS)
We find a character/symbol belonging to the solution every time we have a diagonal move with a score increased
by 1.
Different paths regard cells with equal score contribution; LCS doesn’t change.
We have seen two symmetrical approaches for comparing sequences/strings
Edit distance: measures the number of differences between two strings, where the edit operations used reproduce what
makes sequences different.
Longest common subsequence: measures the number of characters in the strings which have been “conserved”, that is,
unchanged from an evolutionary point of view.
Define a similarity measure for two strings a and b such that
“differences” have a negative effect (negative weight for insertion, deletion, substitution/mismatch)
“conserved letters” have a positive effect (positive weight for match)
) = max
𝑑
𝑑
𝑚
𝑖
𝑗
𝑠
𝑖
𝑗
w d
< 0: negative gap penalty for insertions/deletions
w s
< 0: negative mismatch penalty for substitutions
w m
0: positive match score for the same symbol
Prepare a matrix as for edit distance and LCS:
Set cell (0,0) = 0
Initialize cells (i,0) of the first column with 𝑖 × 𝑤
𝑑
Initialize cells (0, j) of the first row with j × 𝑤
𝑑
If we know the weights used when applying the algorithm we can determine the final score of an alignment directly
from the alignment itself: each column of the alignment represents a match or an edit operation, associate with each
column its score and sum over all individual scores.
Using a substitution matrix 𝜎: 𝜎(𝑠 𝑖
𝑗
𝑗
𝑖
) = the weight of the substituting 𝑠
𝑖
by 𝑠
𝑗
in an alignment.
Needleman – Wunsch algorithm
Cells E(0, j) of the first row will have scores 𝑗 × 𝑤
𝑑
(linear gap penalty)
Cells E(i, 0) of the first column will have scores 𝑖 × 𝑤
𝑑
(linear gap penalty)
𝐸(𝑎(𝑖), 𝑏(𝑗)) = max {
𝑑
𝑑
𝑖
𝑗
w d
< 0: negative gap penalty for insertions/deletions
𝑖
𝑗
): substitution score for 𝑎
𝑖
and 𝑏
𝑗
→ matches and mismatches are included in 𝜎
Considering DNA sequencing data, referenced-based assembly follows the goal of finding the differences between an
individual’s genome and the reference genome for the corresponding species, rather than characterizing the genome of
that species in the first place.
Faster search algorithms are based on preprocessing of the text (genome) to build a substring index. A substring index
is a data structure which gives substring search in a text or text collection in sublinear time.
String matching algorithms identify the positions where one or multiple strings are found as substrings of a larger string.
We will first assume that the search pattern (read) matches perfectly to a substring in the full text (genome).
The simplest string algorithm would simply slide the pattern across the genome, extending it letter for letter as long as
there is a match.
A trie (from retrieval), is a multi-way tree structure useful for storing strings over an alphabet.
A trie is defined as the smallest tree over an alphabet Σ such that:
correspondence to a path from the root to a leaf).
Constructing a trie:
Let us now use the trie to map reads to the genome:
Runtime of the trie algorithm is Θ(𝐿 × 𝐺) for matching, and Θ(𝑛
𝑏
) for trie construction.
Amount of memory required for the trie is in the worst case proportional to the total length of the reads: Θ(𝑛
𝑏
Each path from the root to a leaf represents a suffix, and each suffix is represented by a path from the root to a leaf
(including the full string and the empty suffix “$”).
The nodes have implicit labels that reflect the string of characters on the path from the root to the node.
Each substring of T is represented by a path from the root, every substring is a prefix of some suffix of T.
Thus to search for a substring S, start at the root and follow the edges labeled with the characters of S. If at some point
there is no outgoing edge for the next character of S, then S is not a substring of T.
A string S is a suffix of T if it is a substring and the final node on the walk has an outgoing edge labeled $.
How many times does some substring S occur in T? Follow the path for S, if we finish at some node n, then S occurs
the same number of times as the number of leaf nodes in the subtree rooted at n.
What is the longest repeated substring S of T? This is the deepest node with 2 or more children.
Constructing a suffix trie:
Searching a suffix trie:
followPath returns the node at the end of the path or
null if there is no path
hasSubstring checks if followPath does not ‘fall off’ the tree
and return null
Size complexity (𝑚 = |𝑇|):
Simplest case: a string of minimum complexity – repetition of the same character → Θ(𝑚) nodes
The worst case is → Θ(𝑚
2
) nodes
Height: length of the longest suffix (original string + 1 ($)) = m+
Maximum width: maximum number of leaf nodes (number of suffixes) = m
The suffix array, at least in its simplest incarnation, requires only 4 bytes per character of the input sequence.
We will refer to our string T as T[0…N-1]. The suffixes of this strings are: T [ 0 …N-1], T [ 1 …N- 1 ], …, T [N- 1 …N-1]
A naive implementation of the suffix array basically manipulates an array of pointers to the suffixes of T.
Hot to build a suffix array (naive):
Form all possible suffixes from the input string T, with each suffix associate its position in the original string.
Sort lexicographically, the termination symbol $ comes before all other symbols: we keep only the array of
indices, not the suffixes.
Effect: we bring repeated substrings together.
Longest repeated substring problem:
We have a suffix array of the input string: scan through the list to find neighbors with the longest common
prefix. In the suffix array the occurrences of the longest repeated substring will always be consecutive
(lexicographically sorted).
How to build suffix array (Manber and Myers):
Initialization: sort only the first character of the suffixes.
Recursive phase (i): given an array of suffixes sorted on the first 2
𝑖− 1
characters, create an array of suffixes
sorted on the first 2
𝑖
characters.
N.b. To sort by 8-mers we can reuse information we have from sorting 4-mers. The first four chars are sorted,
se we only need to care about the last four chars, but these last four chars were sorted previously (they are
prefixes of other suffixes).
The BWT applies a reversible transformation to a block of input text. The transformation does not itself compress the
data but reorders it to make it easy to compress with simple algorithms such as move-to-front coding.
First step: form all rotations of the input text T. Note that we append a termination character $ to the end of the text.
Second step: sort the rotated strings lexicographically.
➔ The result is the Burrows Wheeler matrix
Third step: the Burrows Wheeler Transform is simply the last column of the Burrows Wheeler matrix. Note: since we
rotated all characters, the last row contains the same set of characters as T.
Algorithm to create BWT(T) from the suffix array SA(T) of T: position i of the BWT corresponds to the character that,
in the original string, is just to the left of the i-th suffix in the SA, this is exactly the character that has been “rotated” to
the back of the BW matrix.
SA[i] is the position/offset in T of the i-th sorted suffix
Constructing a BWT from a Suffix Array:
If we want to get the original string back, we need to i) reverse the compression procedure (in case we compressed the
BWT) ii) get the original string back from the BWT.
The reversibility of the BWT depends on the LF Mapping property: for any character, the T-ranking of characters in the
first column (F) of the BW matrix is the same as order of characters in the last column (L).
The T-ranking of the character at any given position is the number of times that an identical character has
preceded it in T.
The relative T-ranks of the characters in column F are determined by the lexicographic ranks of the strings to
the right of the characters.
The relative T-ranks of the characters in column L must reflect the lexicographic ranks of the strings to the
“rotated” right of the characters.
The B-ranking of a character at a specific position is the number of that times the same character has occurred in the F
column “above” the current position: it’s a cumulative count of the characters. Just a re-labeling of identical characters,
so also the B-ranking is the same for the F and L columns.
Column F structure: chunks of identical characters with ascending B-ranks (they are lexicographically sorted).
We will first try to reconstruct the first column of the BWM:
Consider 𝑐
0
: we know that the $, all the “a”s, all the “b”s, but not any of the “d”s must precede 𝑐
0
in the first
column. The number of identical characters in F is the same as in L, so we can simply count them in the BWT.
We will refer to this as the cumulative index property : this will help us to find a particular character (with a
specific B-ranking) in the F column.
Reconstructing the full F column: sort the L column lexicographically.
We will reconstruct the original string T backwards, from right to left: we know the last character is $, so we
initialize our reconstructed string accordingly.
The character that precedes the $ in T is now in the last column (L): because of the rotation we know that the
character preceding the $ must be the last character in the row which starts with $.
We can do everything starting only from the BWT(T), which corresponds to the L column. If we count the number of
each character in BWT(T), we can easily reconstruct the “chunks” of characters in the first (F) column of the BWM.
The FM index uses the BWT and some other auxilliary data structures to generate a fast an efficient index for search
for small patterns within a larger string T.
The main data structures of the FM index are the F column and the L column (=BWT) from the BWM. Note that F can
be represented as an array of integers (one per character of our alphabet).
Search a particular substring: the substring we’re looking for should be the prefix of a suffix in the BWM, we will try
to reconstruct the prefixes of suffixes which fit the searched substring.
Search for the string P in our “genome” T:
Look for all rows of BWM(T) that have P as a prefix.
We successively look for the longer suffixes which have prefix P, starting with the last character of P. It’s easy
to find the chunk of the BWM(T) that starts with a given character using the cumulative index property.
Once we have found all rows that begin with the last letter of P, we can look in L to identify those rows whose
last letter corresponds to the second to last letter in P: due to rotation, the last letter in the row (column L) must
come right before the first letter (column F) in the original string.
Read off the B-ranks of these characters and use the LF mapping to find the rows in F that begin with these
characters: we are guaranteed to have consecutive B-ranks for the second letter because we’re looking at a set
of adjacent rows.
Finally, we look up in the F column to find the rows of the BWM that begin with our full query string.
𝑘
𝑘
𝑘
) = number of chars in T[0, n-2] that are lexicographically smaller than 𝑎
𝑘
𝑘
, 𝑖) = number of occurrences of 𝑎
𝑘
in BWT[0, i]
Initialization: 𝑊 𝑚
Burrows Wheeler Aligner – Inexact matching
CalculateD(W): precalculates lower bounds of the number of
mismatches.
InexRecur(W, i, z, k, l): returns the SA intervals of substrings in T
that match W with no more than z differences.
D(i) = lower bound of the number of differences in W[0…i] to the
best match in T.
Example: start with z = i = j = 0; check W[0…0]:
If W[0…0] is in T: D(0) = 0; increase i and check W[0…1]
If W[0…0] is not in T: increase z; set j = i +1; D(0) = 1;
increase i and check W[1…1]
CalculateD(W) is a heuristic that allows to stop the DFS early.
Lines 1- 3
If the lower bound on the number of differences in
W[0… i] is already more than the maximum number of
(still) allowed mismatches z, give up. Return null (no
match for W[0…i] found).
Lines 4 - 5
If i < 0 then we are arriving from a recursive call where
we have finished matching W. We return the SA interval
{k, l} representing the found hits.
Line 7 : for this recursion, initialize the current interval I
to the empty set.
Line 8 : loop over all nucleotides (A,C,G,T), looking for
a match.
Line 9- 11
Figure out the interval in F where the current nucleotide
b would be. Check whether this interval is empty.
Lines 12- 15
If we have a match, then decrement i and keep going,
checking W[0… i- 1 ]. If we have a mismatch, then
decrement i and also z and keep going, thus allowing one
less mismatch for W[0… i-1].
Hash table without collisions: one row per substring of length k → n
k
rows: takes more space but reports the exact
occurrences of each substring.
Hash table with collisions: one row every two substrings of length k → n
k
/2 rows: takes less space, but we do not know
which of the two substrings each occurrence of the list corresponds to.
The table without collisions is better but takes more space. The more substrings we make “collide” in the same row, the
less space it will take, but the more “false positive matches” it will return, and for each one we have to match the whole
pattern.
The choice depends on how much memory space we have for the table, and the size k of the substring to index.
If k is small, the table will be smaller – do not use collisions.
If k is large, the table will be larger – better use collisions.
Input: k strings S 1
2
k
Compute the pairwise alignment of every pair of input strings
Let A(S i
j
) be the score of the alignment of strings S i
j
Let 𝑆𝑃(𝑆
𝑖
𝑖
𝑗
𝑗≠𝑖
Choose S i
with the maximum SP(S i
) value, that is, the string that is “more similar” globally to the other ones of
the set → S i
is the “center of the star”
The alignment is built by starting with S i
, and adding each of the other strings one by one, as they were aligned
to S i
in the initial step
Complexity: k strings of equal length n
At the first step, we compute
𝑘− 1
𝑖= 1
alignments → O(k
2
) alignments
Each of the alignments takes O(n
2
) time and space
The overall complexity of the first step is thus O(n
2
k
2
Choosing the center string and building the final alignment costs O(nk) time
➔ Hence, the overall time/space complexity is O(n
2
k
2
We can re-formalize the problem, and instead of defining that it maximizes the overall similarity as sum of pairs,
minimizes the overall distance as sum of distances.
If the triangle inequality holds for the distance we employ (and for edit distance it does), then we can prove that
it is an approximation algorithm with 𝜖 = 2 – that is, the ratio between the distance found by the algorithm and
the “minimum” (optimal) distance is always equal or lower than 2.
In the worst case, thus, the alignment found by “center star” has an overall distance among sequences (the
function to be optimize) that is two times the optimal one.
In practice, we do not actually compare all the strings to one another, we just compare all the strings to the same one.
Gaps will be found in the global alignment in the same positions where we put them: “once a gap, always a gap” – each
gap in pairwise alignments will be not corrected in the multiple one.
One very useful way of describing a multiple alignment is to represent it with its profile. It represents, column by
column, the frequency with which we find each symbol of the alphabet, plus the “gap” (-) in each column. Frequencies
in each column sum to 1.
Profiles are way of representing a MSA in a compact way - the drawback is that we lose the information about which
sequence each character belongs to.
We still fill a dynamic programming matrix, as if it was a normal global alignment. We still have the string to add on
rows. But on columns we have the profile, not single letters but all the letters of the alphabet with their frequency.
We will fill the matrix with a “weighted” version of the global alignment rule: we compare a character to a column of
the profile, with the frequency of each letter.
Initialization of the first row: it becomes “weighted” too since the profile contains gaps.
Score of matching character x with column j of the profile: 𝑃
𝑐∈Σ
: cost of the aligning x with c
: frequency of char c in column j
𝑖
𝑖
By using the “weighted” version, we can fill the matrix as we did in the global alignment of two strings.
Keep track of the cell that gave the best choice at each step
At the end cell (n,m) will contain the value of the optimal alignment
The alignment will be build with a traceback
Update the alignment profile by adding to it the string just aligned.
The same principle can be applied to the alignment of two profiles.
On the rows and columns of the matrix we will have two profiles instead of two strings
The update of the cells will be performed with a “double weighted” version of the rule for global alignment
Algorithms of this kind are in general known as building a progressive multiple alignment.
The key is having the “guide-tree” telling us the order of operations in which the alignment has to be built.
Before proceeding with the alignments, we build the guide tree ourselves, that is, we try to guess the evolutionary
history behind the sequences.
The general principle behind the tree is: “The more two strings are similar, the more recent is the evolutionary event
that produced them”.
Idea to build the tree: going back in time → we start from the final sequences and derive their common ancestors.
We start again by comparing all pairs of sequences and compute their distance.
We choose the pair with minimal distance – align them and build their profile.
Suppose that the closest pair is S1-S2: we have the first node of the tree, and call A(S1, S2) their alignment
The alignment represents the ancestor, and it will be part of the final multiple alignment
At the second step, we have three objects: Alignment A(S1,S2), String S3, String S
We choose again the closest pair among the three possibilities: Distance between A(S1,S2) and S3 | Distance
between A(S1,S2) and S4 | Distance between S3 and S
Suppose that the best choice is the third. We align S3 and S4, and add the node to the tree
At the third step, we have two objects left: Alignment A(S1,S2), Alignment A(S3,S4)
We align the two alignments, represented by their profile
The result is A(S1,S2,S3,S4) which is the final alignment we wanted to build
From another point of view, we performed a hierarchical clustering of our strings - replace align with cluster in what
we have seen so far:
Every time we align two strings, we put them in the same cluster
Every time we align a string to a profile, we add it to the cluster
Every time we align two profiles, we merge two clusters
At the end, we will have one single cluster comprising all strings
At each step, we decide to join the two closest objects: two strings | one strings and an alignment (a cluster) | two
alignments (two clusters)
For measuring the distance between two strings, we just take the distance given us by their alignment
How do we measure the distance between one string and an alignment or between two alignments?
In clustering: define a distance measure between a point and a cluster and define a distance measure
between two clusters.
Local multiple alignment problem: find the combination of substrings, one per input strings, that produces the multiple
alignment with highest score.
The typical situation: a large set of strings and the substrings forming the “biologically optimal” solutions differ only
by substitutions, not insertions/deletions.
Formalization:
A set of input strings S 1
2
k
A substring length w
A function f(x) for the evaluation of the multiple alignment
Problem: find the set of k substrings of length w, one per input string, that produces the alignment of maximum score
according to function f(x). Problem also known as motif finding.
The problem becomes a typical problem of “combinatorial optimization”, that is, finding the “optimal object” (the best
combination of substrings) among a finite set of objects (all possible combinations of substrings).
Here computing the number of objects is straightforward: they are (𝑛 − 𝑤 + 1 )
𝑘
solutions.
Since we have the length w of the substrings as input and we know that the alignment has no gaps, any candidate solution
can be simply described by a vector of integers, corresponding to the position of the substring included in the solution
in each of the input strings. The alignment will simply be the substrings written one under the other, with no gaps. For
any set of substrings, the alignment is unique.
We describe a solution with the corresponding profile:
The profile has always w columns (no gaps in the alignment).
The profile has one row per symbol of the alphabet (no need to include the gap, as in the global MSA).
𝑖,𝑗
is the frequency of letter i of the alphabet in column j of the alignment.
Column frequencies sum to 1.
𝑖,𝑗
log
2
𝑖,𝑗
𝑤
𝑗= 1
4
𝑖= 1
The log compares the frequencies of the letters of each column to ¼: that is, the frequencies we would find if the profile
was built with “random substrings” with “random equiprobable” letters.
It is maximum if there is one 𝑓
𝑖,𝑗
= 1 in each column (= 2 for each column times w)
It is minimum if all 𝑓
𝑖,𝑗
= ¼ (= 0 in each column)
Given a set of input strings S 1
2
k
of equal length n, a substring length w, the “information content” score for the
evaluation of the multiple alignment described as a profile; find the combination of substrings of length w, one per input
string, that aligned with no gaps produce the profile with maximum IC score.
The “logo” is a very intuitive way of representing the profile: it is the information content contribution of every letter
in every column (in bits).
Height of each letter in logo: 𝐻 𝑖
𝑖,𝑥
(log
2
𝑖,𝑥
log
2
𝑖,𝑥
𝑥=𝐴,𝐶,𝐺,𝑇
Align every substring of string S1 to every substring of S2 – we obtain O(n
2
) profiles
Align every substring of string S3 to the S1xS2 profiles – we obtain O(n
3
) profiles
Align every substring of string Sk to the S1xS2xS3x...S(k-1) profiles – we obtain O(n
k
) profiles
Find the profile of maximum IC score
In this way we generate all possible solutions – complexity: 𝑂(𝐿 − 𝑤 + 1 )
𝑘
𝑘
Align every substring of string S1 to every substring of S2 – we obtain O(n
2
) profiles – keep only the best n
profiles according to the IC score.
Align every substring of string S3 to the S1xS2 n best profiles – we obtain O(n
2
) profiles - keep only the best n
profiles according to the IC score.
Align every substring of string Sk to the S1xS2xS3x...S(k-1) n best profiles – we obtain O(n
2
) profiles
Find the profile of maximum IC score.
In this way we do not explore all the solutions, by only a polynomial subset of them.
The algorithm is greedy, in the sense that at each step keeps only what are “locally” the best solutions. There is no longer
the guarantee that we will find the optimal solution.
It might seem that the greedy approach is like some algorithms we have just seen (Longest increasing subsequences).
The difference is that with dynamic programming we could prove that the step-by-step approach could yield the optimal
solution. With the greedy approach we cannot prove it anymore: it is simply an heuristic algorithm. Notice that some
NP-hard can indeed be solved by dynamic programming, but the time complexity is exponential.
The multiple local alignment is basically the problem of finding a common “motif”, that is, a substring that appears in
all the strings of the set with little or no variation in its instances.
A profile is defined with the frequencies of the four letters in each of the columns of the alignment. Each column sums
to one: we can see the profile as a “random source” of strings of length w, with probabilities estimated by the frequencies
in the column.
With IC-score, we compare this model to a background one, emitting all letters with the same probability ¼.