Problemintro
Median string problem
Also called motif median string.
Find a string of length l with the smallest total Hamming distance to its closest window in each sequence. It is equivalent to motif finding with the total Hamming distance score only.
The median string problem asks for a string of length that is close to all of a set of sequences at once: for each sequence, take the Hamming distance from to its closest window, and add these distances. A string with the smallest sum is a median string. The problem has the same optimum as motif finding with the total Hamming distance score, and it turns a search over choices of sites into a search over strings. With other scores, such as information content, the two problems differ.
In plain words
Think of a candidate word of length . Slide it along each sequence and find the place where it fits best, the place with the fewest different letters. Write down that number of different letters for each sequence and add them up. That sum says how well the word fits all the sequences.
The median string is the word with the smallest sum. You can find it by trying all the words of length . That is a lot of words when is large, but it is far fewer than all the ways to pick one window in each sequence, because the number of words does not grow with the number of sequences.
Definition
Input. Sequences over , each of length , and a length . Each has windows , . Positions are 1-based on this page.
Distance to a sequence. For a string of length , let .
Total distance. .
The question. Find a string with the smallest . Such a is a median string. The decision form asks whether some has .
The median is any string of length ; it does not have to occur in any sequence.
Variants
- Over the windows only. Restrict to the windows of the input. This takes time, but the result can be worse than the true median.
- The largest distance. Replace the sum by . This is the closest substring problem, the core of the planted motif problem.
- A median under edit distance. In string algorithms, a median string of whole strings often means a string with the smallest sum of edit distances to them. That is a different problem with no windows, and it is not the subject of this page.
Examples
Take the five sequences of Rosalind problem BA2D with : GGCGTTCAGGCA, AAGAATCAGTCA, CAAGGAGTTCGC, CACGTCAATCAC and CAATAATATTCG. A computation of for all 64 strings gives this distribution:
| 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
|---|---|---|---|---|---|---|---|
| strings | 3 | 8 | 7 | 17 | 17 | 6 | 6 |
The three median strings, with , are:
| first closest windows (start) | ||
|---|---|---|
| CAA | 1, 1, 0, 0, 0 | CAG (7), GAA (3), CAA (1), CAA (6), CAA (1) |
| TCA | 0, 0, 1, 0, 1 | TCA (6), TCA (6), TCG (9), TCA (5), TAA (4) |
| TTC | 0, 1, 0, 1, 0 | TTC (5), ATC (5), TTC (8), GTC (4), TTC (9) |
TCA has no exact copy in or , and CAA has none in or . CAG occurs exactly in and but has . The windows CAG, CAG, CAA, CAA, CAA of the greedy motif search have the consensus CAA and the score 2, so they are optimal sites, and their consensus is a median string.
Known algorithms
| method | type | time | source |
|---|---|---|---|
| all strings, each scored against all windows | exact | Jones and Pevzner, Section 4.9; Compeau and Pevzner, Section 2.4 | |
| the same on the tree of prefixes, one column per tree node | exact | Jones and Pevzner, Sections 4.7 to 4.9 | |
| branch and bound on the tree of prefixes | exact | worst case, often less | Jones and Pevzner, Section 4.9 |
| the windows of the input as candidates | heuristic | folklore |
On the tree of prefixes, a node of depth keeps for each window the number of mismatches of its first letters with the prefix. A child adds one column, which takes time, and the tree has fewer than nodes. This gives the bound.
Bounds
Theorem (equivalence). Let be the motif score of a choice of sites , as on the motif finding page. Then . A consensus of an optimal choice is a median string, and the closest windows of a median string are an optimal choice.
Proof. For a choice with windows and any string , column adds mismatches to . So , with equality when is a consensus of .
First, let be any string and let pick a closest window of in each sequence. Then . So .
Second, let be any choice and a consensus of . Each , so . So , and the two minima are equal.
If is optimal, its consensus has , so is a median string. If is a median string, , so is optimal.
- NP-hard. The proof maps each instance to itself and keeps the optimal value, so the decision forms "is " and "is " are the same question. The second is Consensus Patterns, which Li, Ma and Wang (2002) proved NP-hard, so the median string problem with in the input is NP-hard. See NP-hard.
- Fixed . The enumeration takes time, which is linear in the input size for a fixed .
- A lower bound for each prefix. For a prefix of length , every extension has , because the mismatches of the first letters never go away. This is the bound of the branch and bound search.
Reductions
- From motif finding. By the theorem, any motif finding method for the total score gives median strings, and back, with extra time to find the closest windows or the consensus.
- To the planted motif problem. A planted motif has . If the total distance of the planted motif is the smallest, the median string recovers it. On random data with subtle signals this can fail, because other strings can have a smaller sum while some sequence has no window within of them.
- To exact pattern counting. The question whether some has asks for a k-mer that occurs exactly in all sequences. A hash set of the windows of each sequence answers it in time.
Applications
- Exact motif finding for short motifs. For short motifs the strings can be enumerated (), and the median string gives the optimal sites under the total score.
- Seeds for other methods. A median string or the best strings of the enumeration can start a Gibbs sampler or an EM method such as MEME.
- Teaching. The problem is the standard example of how a change of the search space, from sites to strings, makes an exponential search practical.
References
- Neil C. Jones and Pavel A. Pevzner, An Introduction to Bioinformatics Algorithms, MIT Press, 2004, Chapter 4, Section 4.9 (finding a median string), with the problem statements of Section 4.6 and the search trees of Sections 4.7 and 4.8
- Phillip Compeau and Pavel Pevzner, Bioinformatics Algorithms, An Active Learning Approach, Volume I, 2nd edition, Active Learning Publishers, 2015, Chapter 2, Section 2.4, from motif finding to finding a median string
- Ming Li, Bin Ma and Lusheng Wang, Finding similar regions in many sequences, Journal of Computer and System Sciences 65(1), 2002, NP-hardness of Consensus Patterns, the same problem under the total Hamming distance
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag BJR06Z Edit this page History Report an error Markdown