Datums and shorelines¶
An archive is a map of the trees a survey reached, one elite per niche. A study that compares genes must read each gene's map at one common level, and it must know that each map is complete at that level. This page gives the scale on which Hifuku compares the elites of an archive, the test for whether an archive is complete at a level, and the range of levels that a study's archives allow. The halt rule decides when a survey stops (see the theory overview, Section 6). The functions on this page report what the archive holds when it stops, and leave the choice of a level to the user.
1. The common scale¶
Each archive has a best tree, the elite with the highest log-likelihood. Each other elite lies some number of nats below it, its height \(H = L_{\text{best}} - L\). A height in nats does not compare across genes: a log-likelihood is a sum over sites, so the same height means less on a long alignment than on a short one.
Kishino and Hasegawa (1989, eq. 12) estimate the variance of the difference of two trees' log-likelihoods from the per-site differences. With \(d_h = l_h(\text{best}) - l_h(\text{tree})\) at site \(h\) of \(n\) sites,
Hifuku gives each elite the statistic
so the best tree has \(z = 0\), and \(z\) counts standard errors below it. The standard error is the tree's own, against the best tree. A tree near the best tree differs from it at few sites, so its per-site differences are small. A tree far below it differs at many sites, so its per-site differences are large. One standard error per gene lies between the two. Divided by it, a tree near the best tree gets a smaller \(z\) than its own standard error gives, and a tree far from it a larger one. One standard error per gene would therefore put the trees near the best tree too near it, and the trees far from it too far below it.
Hifuku stores site patterns, each with the number of sites that show it. The
sum over sites becomes a sum over patterns weighted by those counts. The
weighted form, its value of zero for the best tree, and its invariance to a
shift common to both trees at every site are verified in
docs/theory/algebra/kishino1989logl-pattern-weighted-se.py.
The levels of this scale are nominal. Kishino and Hasegawa compare two trees, one of them fixed in advance. Here the best tree is selected from the same data as the trees it is compared with, and Shimodaira and Hasegawa (1999) show that such a comparison is overconfident. A value \(z = 1.96\) is therefore not a 5% test. The scale orders the elites of an archive and puts the archives of different genes on one axis. It does not give a confidence set.
2. Shorelines¶
Read the archive as a surface over the chart, with the best tree at its summit and each filled niche at the depth \(z\) below it. A datum is a value \(d\) on the common scale. The filled niches with \(z < d\) form a region, and the boundary of that region is the shoreline at \(d\). A smaller datum gives a smaller region, nearer the best tree.
A shoreline is known only where both of its sides are known. An empty niche has no measured log-likelihood, so treat it as outside the region at every datum. An edge elite is a filled niche with at least one empty niche among its eight neighbors. An empty niche inside the filled region counts. When an edge elite is in the region, the shoreline runs between it and an empty niche, across ground the survey did not measure. When no edge elite is in the region, the shoreline consists only of closed loops between filled niches, and the archive holds every tree of the region together with the trees around it. The lowest \(z\) of an edge elite is the edge z. Every shoreline of the archive closes at a datum at or below the edge z, and in this sense the shorelines close below it.
The survey's log-likelihood gate admits a new niche only for a tree within a
margin of the best tree. A gate margin of \(G\) nats corresponds to a value on
the common scale: the median \(z\) of the trees whose height lies within
SHORELINE_GATE_BAND of \(G\), the gate z. The survey made no new niche for
a tree beyond the gate, so the gate z is the depth to which each gene's survey
bounds its own archive. It is reported only when at least
SHORELINE_GATE_MIN_ELITES trees lie in that band, and not at all under an
absolute floor, whose height below the best tree changes as the best tree
rises.
3. The datum range of a study¶
A study takes one archive per gene. Every shoreline of every archive closes at a datum at or below the lowest edge z over the genes, the cap. The gene or genes whose edge z equals the cap constrain the study: a datum above the cap needs more survey of those genes.
Hifuku proposes a default datum, the largest of DATUM_LEVELS strictly below
the cap.
The levels are 1.0, 1.645 and 1.96, the two-sided standard-normal points for
about 68%, 90% and 95%. Kishino and Hasegawa (1989, eq. 13) build their 95%
interval from \(\pm 1.96\) standard errors. Section 1 gives the reason these
levels are nominal here. When the cap is 1.0 or less, there is no default.
The choice of a datum, and of further survey effort, belongs to the user.
4. Shorelines in the survey log and the analysis API¶
- The survey log ends each survey with its shoreline. An example of the format,
with illustrative values:
shorelines close below z = 1.22 (edge niche (31, 40)); gate at z = 4.43. The line is a report and is not written into the survey file. hifuku.analysis.kh_scalegives the height, standard error and \(z\) of each elite of an archive.hifuku.analysis.shorelinegives an archive's edge z, the niche that sets it, the number of edge elites and the gate z.hifuku.analysis.datum_rangegives the cap, the constraining genes, the default datum and a table with one row per gene.hifuku.analysis.halt_statusgives whether and where a survey halted, and, for a survey that did not, the projected variations to the halt.
Sources
- Kishino, H., & Hasegawa, M. (1989). Evaluation of the maximum likelihood estimate of the evolutionary tree topologies from DNA sequence data, and the branching order in Hominoidea. Journal of Molecular Evolution, 29(2), 170-179. Equation 12 (the variance of a difference of log-likelihoods); equation 13 (the 95% interval).
- DOI
- Shimodaira, H., & Hasegawa, M. (1999). Multiple comparisons of log-likelihoods with applications to phylogenetic inference. Molecular Biology and Evolution, 16(8), 1114-1116. The selection of the best tree from the same data.
- DOI
- Kishino & Hasegawa 1989 · Shimodaira & Hasegawa 1999 · Stopping a survey
- The pattern-weighted form of equation 12 is verified in
docs/theory/algebra/kishino1989logl-pattern-weighted-se.py. -
kh_scale·shoreline·datum_range·halt_status