PhyloCSF coding classifier
DefinitionLeaf data of an alignment column#✓fully proved
The leaf data of an alignment column col : L → S: the indicator of the observed codon at
each leaf.
def leafData (col : L → S) (l : L) (s : S) : ℝ := if col l = s then 1 else 0
DefinitionLikelihood of one alignment column#✓fully proved
The likelihood of one alignment column under the model (t, π).
noncomputable def siteLik (t : Tree L S ℝ) (π : S → ℝ) (col : L → S) : ℝ :=
likelihood (leafData col) t π
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
def likelihood (t : Tree L S R) (π : S → R) : R :=
∑ s, π s * bruteLik obs t s
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:147
def leafData (col : L → S) (l : L) (s : S) : ℝ := if col l = s then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:71
Uses 3 · Used by 5
DefinitionLikelihood of an alignment of independent columns#✓fully proved
The likelihood of an alignment of m independent columns: the product of the site
likelihoods.
noncomputable def alignLik (t : Tree L S ℝ) (π : S → ℝ) (A : Fin m → L → S) : ℝ :=
∏ k, siteLik t π (A k)
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def siteLik (t : Tree L S ℝ) (π : S → ℝ) (col : L → S) : ℝ :=
likelihood (leafData col) t π
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:74
DefinitionThe PhyloCSF score#✓fully proved
The PhyloCSF score (natural-log scale): the sum over the columns of the
log-likelihood ratio of the coding model (tC, πC) against the non-coding model
(tN, πN). The published PhyloCSF score is reported in decibans; see score_decibans
for the conversion. Thresholds for this score are in natural-log units.
noncomputable def score (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(A : Fin m → L → S) : ℝ :=
∑ k, log (siteLik tC πC (A k) / siteLik tN πN (A k))
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def siteLik (t : Tree L S ℝ) (π : S → ℝ) (col : L → S) : ℝ :=
likelihood (leafData col) t π
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:74
Uses 2 · Used by 5
DefinitionThe published PhyloCSF score in decibans#✓fully proved
10 * log₁₀(L_C / L_N), i.e.
(10 / log 10) * score, since log₁₀ x = log x / log 10.
noncomputable def score_decibans (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(A : Fin m → L → S) : ℝ :=
(10 / log 10) * score tC πC tN πN A
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def score (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(A : Fin m → L → S) : ℝ :=
∑ k, log (siteLik tC πC (A k) / siteLik tN πN (A k))
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:86
Uses 2 · Used by 1
TheoremDeciban score as a rescaled natural-log score#✓fully proved
Decibans are the natural-log score rescaled by 10 / log 10.
theorem score_decibans_eq (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(A : Fin m → L → S) :
score_decibans tC πC tN πN A = (10 / log 10) * score tC πC tN πN A
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def score_decibans (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(A : Fin m → L → S) : ℝ :=
(10 / log 10) * score tC πC tN πN A
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:92
noncomputable def score (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(A : Fin m → L → S) : ℝ :=
∑ k, log (siteLik tC πC (A k) / siteLik tN πN (A k))
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:86
Uses 3
TheoremSite likelihood by Felsenstein's pruning algorithm#✓fully proved
Each site likelihood is computed by Felsenstein's pruning algorithm.
theorem siteLik_eq_sum_prune (t : Tree L S ℝ) (π : S → ℝ) (col : L → S) :
siteLik t π col = ∑ s, π s * prune (leafData col) t s
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def siteLik (t : Tree L S ℝ) (π : S → ℝ) (col : L → S) : ℝ :=
likelihood (leafData col) t π
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:74
def prune : Tree L S R → S → R
| leaf l, s => obs l s
| node P l Q r, s => (∑ a, P s a * prune l a) * (∑ b, Q s b * prune r b)
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:152
def leafData (col : L → S) (l : L) (s : S) : ℝ := if col l = s then 1 else 0
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:71
TheoremThe score is the log-likelihood ratio of the alignment#✓fully proved
The score is the log-likelihood ratio of the alignment when all site likelihoods are positive.
theorem score_eq_log_div {tC tN : Tree L S ℝ} {πC πN : S → ℝ} {A : Fin m → L → S}
(hC : ∀ k, 0 < siteLik tC πC (A k)) (hN : ∀ k, 0 < siteLik tN πN (A k)) :
score tC πC tN πN A = log (alignLik tC πC A / alignLik tN πN A)
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def siteLik (t : Tree L S ℝ) (π : S → ℝ) (col : L → S) : ℝ :=
likelihood (leafData col) t π
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:74
noncomputable def score (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(A : Fin m → L → S) : ℝ :=
∑ k, log (siteLik tC πC (A k) / siteLik tN πN (A k))
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:86
noncomputable def alignLik (t : Tree L S ℝ) (π : S → ℝ) (A : Fin m → L → S) : ℝ :=
∏ k, siteLik t π (A k)
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:79
DefinitionScore threshold test for calling an alignment coding#✓fully proved
The threshold test on the score: call the alignment coding (1) iff the score exceeds the
cutoff c.
noncomputable def scoreTest (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(c : ℝ) (A : Fin m → L → S) : Set.Icc (0 : ℝ) 1 :=
if c < score tC πC tN πN A then ⟨1, by norm_num, le_rfl⟩ else ⟨0, le_rfl, by norm_num⟩
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def score (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(A : Fin m → L → S) : ℝ :=
∑ k, log (siteLik tC πC (A k) / siteLik tN πN (A k))
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:86
Uses 2 · Used by 1
TheoremPhyloCSF's score threshold test is most powerful for unnormalized weights#✓fully proved
With
positive site likelihoods under both models, a randomized test φ whose weighted size under
the non-coding weights is at most that of scoreTest c has at most its weighted power under
the coding weights. This is the dominated Neyman–Pearson inequality for the unnormalized
alignment weights alignLik; it becomes a statement about statistical size and power only
under additional normalization hypotheses (∑ A, alignLik = 1 for each model).
theorem weighted_power_le_scoreTest {tC tN : Tree L S ℝ} {πC πN : S → ℝ}
(hC : ∀ col, 0 < siteLik tC πC col) (hN : ∀ col, 0 < siteLik tN πN col) (c : ℝ)
(φ : (Fin m → L → S) → Set.Icc (0 : ℝ) 1)
(hsize : ∑ A, (φ A).val * alignLik tN πN A ≤
∑ A : Fin m → L → S, (scoreTest tC πC tN πN c A).val * alignLik tN πN A) :
∑ A, (φ A).val * alignLik tC πC A ≤
∑ A : Fin m → L → S, (scoreTest tC πC tN πN c A).val * alignLik tC πC A
inductive Tree (L : Type u) (S : Type v) (R : Type w) where
/-- A leaf with label `l`. -/
| leaf : L → Tree L S R
/-- An internal node with transition weights `P` to the left child and `Q` to the right one. -/
| node : (S → S → R) → Tree L S R → (S → S → R) → Tree L S R → Tree L S R
CSLibExt/Bioinformatics/Phylogenetics/FelsensteinPruning.lean:75
noncomputable def siteLik (t : Tree L S ℝ) (π : S → ℝ) (col : L → S) : ℝ :=
likelihood (leafData col) t π
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:74
noncomputable def alignLik (t : Tree L S ℝ) (π : S → ℝ) (A : Fin m → L → S) : ℝ :=
∏ k, siteLik t π (A k)
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:79
noncomputable def scoreTest (tC : Tree L S ℝ) (πC : S → ℝ) (tN : Tree L S ℝ) (πN : S → ℝ)
(c : ℝ) (A : Fin m → L → S) : Set.Icc (0 : ℝ) 1 :=
if c < score tC πC tN πN A then ⟨1, by norm_num, le_rfl⟩ else ⟨0, le_rfl, by norm_num⟩
CSLibExt/Bioinformatics/Phylogenetics/PhyloCSF.lean:117
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.