kmerseek explainer · part 3 · measured, not modelled

What every alphabet can see

Part 1 set out how a k-mer match earns a score and an E-value, and Part 2 worked out how much evidence a reduced alphabet can carry. This page measures it: when three proteins are searched against all 19_732 canonical human proteins with each of kmerseek's 19 alphabets, what does each alphabet see? Every dot below is a real search. Pick an alphabet, a test case and a ranking metric; every figure and every number on the page answers to those three choices. Sections 7 and 8 then ask whether the best ranks beat what a random query gets, and whether a model trained on known Pfam domains combines the alphabets better.

Part 1, how a region gets an E-value · Part 2, what two letters can carry · results notebook 241 in 2024-kmerseek-analysis #46, notebooks 242 and 243 in #48

scienceThree test cases, one background

Each query is searched against the same database, the 19_732 canonical human proteins of GENCODE v49 (11_347_201 residues). The two proteins we are looking for, BCL2 and CD47, are both in it, so the search that finds BHF's partners is the search that has to find them.

For every alphabet the seed length k is set so one seed carries 16 to 44 bits, where bits per position is the entropy of the alphabet's class shares measured on this proteome. That makes a 2-letter k=24 seed and a 20-letter k=6 seed the same amount of information, and it is why the x axis everywhere is bits, not k. Each index was built with region extension at the alphabet's own mismatch penalty and a Karlin-Altschul fit; every metric kmerseek writes was kept for every region, with no threshold.

What the five metrics measure, and how a rank is counted

E-value: matches this good expected by chance in the whole search, from the fitted lambda and K. Mean IDF: how rare the region's k-mers are in the database, averaged. tf-idf: those rarities summed over the region. Enrichment: shared k-mers divided by the number expected by chance. Poisson p-value: the chance of at least this many shared k-mers under a Poisson model.

A target is one human protein, scored by its best region under the metric. The partner's rank is 1 plus the number of targets strictly better; the number tied with it is shown separately, so rank 1 with 40 tied means "tied for first with 39 others", not found.

stairsThe ladder for

Hover any arm for its numbers. The bits axis is the same on every figure of this page.

stacked_line_chartAll five ranking metrics for

One line per metric: where the partner ranks at each arm. The thick pale line under them is last place, the number of human proteins hit at that arm, so a metric can never sit below it. A metric with no mark at an arm either lost the partner there or, for the E-value, has no Karlin-Altschul fit at that arm.

Best rank of the partner, every alphabet under every metric

Each cell is the best rank over all k for that alphabet and metric; the best cell in each row is bold. Click a row to select the alphabet.

grid_onAll 19 alphabets at once

account_balance_walletThe bits budget

highest seed information at which the partner is still among the hits (any metric)about what an E-value of 1 needs on this database for this querythe selected alphabet

\[\text{bits needed} = \log_2\!\left(\frac{m \cdot n}{E}\right)\]

with m the query length, n the residues in the database and K taken as 1. The fitted K is smaller, which lowers the bar by a few bits; the gap does not close.

blockWhy so many regions have no E-value

share of an arm's regions with no E-valueno region at this arm

Left: for every arm of the selected alphabet, the share of matched regions whose E-value is infinite. Right: identity. The chance identity of two unrelated sequences under this alphabet is p; a region whose own identity is above C / (1 + C) gets lambda 0 and no E-value.

\[\text{identity limit} = \frac{C}{1+C}, \qquad \text{chance drift} = p - C\,(1-p)\]

Two things follow. First, the limit removes the best-matching regions first, because it is the regions that match well that cross it. Second, the kappa-optimal penalty was derived assuming equal class shares (1 / classes), but the real chance identity p is the sum of the squared shares, and for gbmr7, hp_lehninger_hpc3 and gbmr4 it is high enough that a chance position scores at or above zero. There no lambda exists at any k. Deriving C from the measured shares fixes that; the identity limit needs a change to how lambda is solved.

casinoWould a random protein do as well?

A best rank of 213 out of 19_732 sounds good, but it is the best of 152 arms and five metrics. To see what that is worth, 300 random human proteins of about the query's length (within 25%) were searched in the query's place, with every arm, against the same database. Bcl-2 family proteins and CD47 were left out of the random set. If random proteins rank BCL2 as well as Ced9 does, the rank says nothing about Ced9.

one of the 300 random human proteins, searched in place of the querythe real query (Ced9 or P66)p share of random proteins that rank the partner as well or better, (1 + count) / 301

How "combined" ranks are computed, and why the random proteins get the same arms

For "best single arm", each query keeps the partner's best rank over every arm of the 19 alphabets, the same choice Ced9 and P66 get. For "all 19 alphabets combined", each alphabet contributes the partner's rank at its lowest-information arm. The 19 ranks are combined by their geometric mean: divided by 19_732, multiplied, and the 19th root of the product scaled back to a rank. A query that does not hit the partner at an arm gets the middle of the tied bottom ranks.

Picking the best alphabets after seeing the answer

Ranked by mean IDF. A combination's score is the geometric mean of the partner's ranks in its alphabets. Every random protein picks its own best combination, so it gets the same head start as the real query.

model_trainingA model trained on known domains

Instead of picking alphabets by hand, a logistic regression (a model that weighs each feature and turns the sum into a probability) learned how to combine them. It was trained on 998 human proteins with a Pfam domain, each searched against all the others with every one of the 152 arms. A match between two proteins counts as correct when both matched stretches fall in the same Pfam family, each covering at least 20% of the stretch. The model was trained on half of the Pfam families and tested on the other half, which it never saw. The Bcl-2 family is only in the test half, so Ced9 → BCL2 is a test the model was not fitted to.

What the model sees for each match

Matches from different arms that lie on the same diagonal (within 10 residues) and overlap on the query are pooled into one candidate match. For each of the 19 alphabets the model sees five values: whether any of its arms found the match, the highest seed information at which one still did, the best mean IDF divided by ln(number of proteins in the database), the best bit score and the most shared k-mers. It also sees the length of the matched stretch, the lengths of both proteins, and how many alphabets and arms found the match. Last, it counts on each side the membrane-helix-like windows: 19 residues with at least 14 of A, I, L, M, F, V, W. Each arm was searched with the same setting, extended or exact regions, as in the human search above, so a feature means the same thing in training and in use.

Precision: the share of matches kept that are correct. Recall: the share of all correct matches that are kept. Average precision is the area under a curve. Recall is on a log scale because every curve has fallen close to chance by 30% recall.

The trained model on the three test cases

The model was then applied to the searches of Ced9, P66 and BHF against the 19_732 human proteins in the sections above. A human protein's score is the probability of its best candidate match.

the trained model, all 19 alphabetsone feature alone, for comparisonthe same two marks for Ced9 → CD47, a pair with no known link (the control)

abcThe 19 alphabets

Click a row to select it. Bits per position is the entropy of the class shares on the human proteome; p is the chance that two unrelated positions fall in the same class, the sum of the squared shares.

menu_bookGlossary

Arm
One alphabet at one seed length k, searched once.
Bits per seed
k times the bits per position of the alphabet: how much information one exact k-mer match carries.
Bits per position
The entropy of the alphabet's class shares on the database; below log2 of the class count whenever the classes are unequal.
Chance identity p
The probability that two unrelated positions fall in the same class: the sum over classes of the share squared.
Chance drift
The expected score of one chance position, +1 with probability p and −C otherwise. Karlin-Altschul statistics need it below zero.
Identity limit
C / (1 + C): the identity above which a match no longer counts as evidence at penalty C, and above which this build gives a region no E-value.
Average precision
The area under a precision-recall curve: 1 when every correct match is ranked above every wrong one, and the share of matches that are correct when the order is random.
Candidate match
Matches between the same two proteins, from any arm, that lie on the same diagonal (within 10 residues) and overlap on the query, pooled into one.
Held-out families
The half of the Pfam families the model was tested on and never trained on.
Precision and recall
Precision: the share of kept matches that are correct. Recall: the share of all correct matches that are kept.
p (random queries)
(1 + the number of 300 random human proteins that rank the partner as well or better) / 301.
Random query
A human protein within 25% of the real query's length, not in the Bcl-2 family and not CD47, searched in the query's place.
Rank
1 plus the number of human proteins whose best region beats the partner's under the metric; ties are counted separately.
Region
A run of shared k-mers on one diagonal, extended past its exact seed with a mismatch penalty.