Skip to content

Principal-component correction for stratification

34 fully proved

Residualization on a span of axes

TheoremResiduals lie in the orthogonal complement#✓fully proved

Residuals are orthogonal to the adjustment subspace.

theorem adjusted_mem_orthogonal (V : Submodule ℝ E) (y : E) : adjusted V y ∈ Vᗮ
Uses 1 · Used by 1

TheoremResiduals are orthogonal to every axis#✓fully proved

Residuals are orthogonal to every vector of the subspace, in particular to every axis.

theorem inner_adjusted_eq_zero (V : Submodule ℝ E) {v : E} (hv : v ∈ V) (y : E) :
    ⟪v, adjusted V y⟫_ℝ = 0
Uses 2

TheoremResidual as projection onto the orthogonal complement#✓fully proved

The residual is the orthogonal projection onto Vᗮ.

theorem adjusted_eq_starProjection_orthogonal (V : Submodule ℝ E) (y : E) :
    adjusted V y = Vᗮ.starProjection y
Uses 1 · Used by 3

TheoremAdditivity of residualization#✓fully proved

Residualization is additive.

theorem adjusted_add (V : Submodule ℝ E) (y z : E) :
    adjusted V (y + z) = adjusted V y + adjusted V z
Uses 2 · Used by 1

TheoremHomogeneity of residualization#✓fully proved

Residualization is homogeneous.

theorem adjusted_smul (V : Submodule ℝ E) (c : ℝ) (y : E) :
    adjusted V (c • y) = c • adjusted V y
Uses 2

TheoremResidual vanishes exactly on the subspace#✓fully proved

The residual vanishes exactly on the subspace.

theorem adjusted_eq_zero_iff (V : Submodule ℝ E) (y : E) : adjusted V y = 0 ↔ y ∈ V
Uses 1 · Used by 2

TheoremStratification within the axis span does not change the residual#✓fully proved

Adding a vector of the subspace (stratification lying in the axis span) does not change the residual.

theorem adjusted_add_of_mem (V : Submodule ℝ E) {s : E} (hs : s ∈ V) (z : E) :
    adjusted V (s + z) = adjusted V z
Uses 3 · Used by 1

TheoremVectors orthogonal to the subspace are their own residuals#✓fully proved

Vectors orthogonal to the subspace are their own residuals: stratification outside the axis span is not removed.

theorem adjusted_of_mem_orthogonal (V : Submodule ℝ E) {y : E} (hy : y ∈ Vᗮ) :
    adjusted V y = y
Uses 2

TheoremResidual with respect to an orthonormal family of axes#✓fully proved

Regressing on an orthonormal family of axes one axis at a time gives the joint residual: y - ∑ₖ ⟪aₖ, y⟫ aₖ.

theorem adjusted_span_orthonormal {K : ℕ} (a : Fin K → E) (ha : Orthonormal ℝ a) (y : E) :
    adjusted (Submodule.span ℝ (Set.range a)) y = y - ∑ k, ⟪a k, y⟫_ℝ • a k
Uses 1

TheoremFrisch–Waugh–Lovell theorem, uniqueness#✓fully proved

Frisch–Waugh–Lovell, uniqueness: in any least-squares decomposition y = c + β g + e with c ∈ V and e ⊥ V ⊔ span {g}, the coefficient β is the coefficient of the regression of the residualized y on the residualized g, and the residual e is the residual of that regression.

theorem frischWaughLovell (V : Submodule ℝ E) (y g : E) (hg : adjusted V g ≠ 0) {c : E}
    (hc : c ∈ V) (β : ℝ) (he : y - c - β • g ∈ (V ⊔ Submodule.span ℝ {g})ᗮ) :
    β = ⟪adjusted V g, adjusted V y⟫_ℝ / ‖adjusted V g‖ ^ 2 ∧
      y - c - β • g = adjusted V y - β • adjusted V g
Uses 1

TheoremFrisch–Waugh–Lovell theorem, existence#✓fully proved

Frisch–Waugh–Lovell, existence: the coefficient of the residual-on-residual regression gives a least-squares decomposition of y on V ⊔ span {g}.

theorem exists_frischWaughLovell (V : Submodule ℝ E) (y g : E) :
    ∃ c ∈ V, y - c - (⟪adjusted V g, adjusted V y⟫_ℝ / ‖adjusted V g‖ ^ 2) • g ∈
      (V ⊔ Submodule.span ℝ {g})ᗮ
Uses 1

DefinitionEIGENSTRAT association statistic#✓fully proved

The EIGENSTRAT association statistic (N - K - 1) ⟪r_g, r_y⟫² / (‖r_g‖² ‖r_y‖²) of the adjusted genotype r_g and adjusted phenotype r_y: (N - K - 1) times their squared cosine, which is their squared sample correlation when both are centered (Price et al. 2006). When either adjusted vector is zero the ratio is the junk value 0.

noncomputable def chiSq (V : Submodule ℝ E) (K : ℕ) (y g : E) : ℝ :=
  ((N : ℝ) - K - 1) * (⟪adjusted V g, adjusted V y⟫_ℝ ^ 2 /
    (‖adjusted V g‖ ^ 2 * ‖adjusted V y‖ ^ 2))
Uses 1 · Used by 3

TheoremStratification in the axis span is removed#✓fully proved

Adding vectors of V to the phenotype and the genotype does not change the EIGENSTRAT statistic.

theorem chiSq_add_of_mem (V : Submodule ℝ E) (K : ℕ) {s t : E} (hs : s ∈ V) (ht : t ∈ V)
    (y g : E) : chiSq V K (s + y) (t + g) = chiSq V K y g
Uses 3

TheoremNonnegativity of the EIGENSTRAT statistic#✓fully proved

The EIGENSTRAT statistic is nonnegative when K + 1 ≤ N.

theorem chiSq_nonneg (V : Submodule ℝ E) {K : ℕ} (hK : K + 1 ≤ N) (y g : E) :
    0 ≤ chiSq V K y g
Uses 2

TheoremGenotypes in the axis span carry no signal after adjustment#✓fully proved

A genotype lying in the axis span carries no signal after adjustment (its residual is zero, and the statistic is the junk value 0 of the zero denominator).

theorem chiSq_of_mem (V : Submodule ℝ E) (K : ℕ) (y : E) {g : E} (hg : g ∈ V) :
    chiSq V K y g = 0
Uses 3

Patterson normalization and the axes of variation

DefinitionAllele-frequency estimate of a marker#✓fully proved

The allele-frequency estimate p̂ⱼ = μⱼ / 2 of marker j, where μⱼ is the mean variant-allele count of column j (autosomal diploid data, counts in {0, 1, 2}).

noncomputable def alleleFreq (C : Matrix (Fin N) (Fin M) ℝ) (j : Fin M) : ℝ :=
  colMean C j / 2
Uses 1 · Used by 2

DefinitionPatterson's normalized genotype matrix#✓fully proved

Patterson's normalized genotype matrix (C i j - μⱼ) / √(p̂ⱼ (1 - p̂ⱼ)). For a monomorphic marker (p̂ⱼ ∈ {0, 1}) the denominator is 0 and the column is the junk value 0; Patterson et al. use polymorphic markers only.

noncomputable def normalizedGenotype (C : Matrix (Fin N) (Fin M) ℝ) : Matrix (Fin N) (Fin M) ℝ :=
  Matrix.of fun i j => center C i j / √(alleleFreq C j * (1 - alleleFreq C j))
Uses 2 · Used by 3

DefinitionPatterson's relatedness matrix#✓fully proved

Patterson's N × N matrix Ψ = M Mᵀ / (number of markers) of the normalized genotypes, whose top eigenvectors are the axes of variation.

noncomputable def relatednessMatrix (C : Matrix (Fin N) (Fin M) ℝ) : Matrix (Fin N) (Fin N) ℝ :=
  (M : ℝ)⁻¹ • (normalizedGenotype C * (normalizedGenotype C)ᵀ)
Uses 1 · Used by 4

TheoremPatterson's relatedness matrix is positive semidefinite#✓fully proved

Patterson's matrix Ψ is positive semidefinite.

theorem relatednessMatrix_posSemidef (C : Matrix (Fin N) (Fin M) ℝ) :
    (relatednessMatrix C).PosSemidef
Uses 2 · Used by 2

TheoremAll-ones vector lies in the kernel of the relatedness matrix#✓fully proved

The all-ones vector is in the kernel of Ψ (columns of the normalized matrix are centered), so at most N - 1 eigenvalues are nonzero.

theorem relatednessMatrix_mulVec_one (C : Matrix (Fin N) (Fin M) ℝ) (hN : 0 < N) :
    relatednessMatrix C *ᵥ 1 = 0
Uses 5

DefinitionAxes of variation#✓fully proved

The axes of variation: an orthonormal eigenbasis of Ψ, in decreasing eigenvalue order.

noncomputable def axes (C : Matrix (Fin N) (Fin M) ℝ) :
    OrthonormalBasis (Fin N) ℝ (EuclideanSpace ℝ (Fin N)) :=
  orderedEigenbasis (relatednessMatrix_posSemidef C).isHermitian
Uses 3 · Used by 3

DefinitionEigenvalues of the axes of variation#✓fully proved

The eigenvalues of Ψ in decreasing order, matching axes.

noncomputable def axisEigenvalues (C : Matrix (Fin N) (Fin M) ℝ) : Fin N → ℝ :=
  orderedEigenvalues (relatednessMatrix_posSemidef C).isHermitian
Uses 3

DefinitionSpan of the top axes of variation#✓fully proved

The span of the top K axes of variation, the subspace EIGENSTRAT adjusts for.

noncomputable def topAxesSpan (C : Matrix (Fin N) (Fin M) ℝ) (K : ℕ) :
    Submodule ℝ (EuclideanSpace ℝ (Fin N)) :=
  Submodule.span ℝ (axes C '' {i | i.val < K})
Uses 1 · Used by 2

TheoremEach top axis lies in the span of the top axes#✓fully proved

Each of the top K axes lies in their span.

theorem axes_mem_topAxesSpan (C : Matrix (Fin N) (Fin M) ℝ) {K : ℕ} {i : Fin N} (hi : i.val < K) :
    axes C i ∈ topAxesSpan C K
Uses 2

TheoremDimension of the span of the top axes#✓fully proved

The top K axes span a K-dimensional subspace.

theorem finrank_topAxesSpan (C : Matrix (Fin N) (Fin M) ℝ) {K : ℕ} (hK : K ≤ N) :
    Module.finrank ℝ (topAxesSpan C K) = K
Uses 2

Number of significant axes

DefinitionSequential count of significant axes#✓fully proved

Patterson's sequential count of significant axes: among the first K statistics, the length of the leading run of statistics exceeding the threshold t (testing stops at the first non-significant one).

noncomputable def numSignificant (stat : ℕ → ℝ) (t : ℝ) : ℕ → ℕ
  | 0 => 0
  | K + 1 => open Classical in
      if numSignificant stat t K = K ∧ t < stat K then K + 1 else numSignificant stat t K
Used by 7

TheoremAt most K axes are declared significant#✓fully proved

At most K axes are declared significant.

theorem numSignificant_le (stat : ℕ → ℝ) (t : ℝ) (K : ℕ) : numSignificant stat t K ≤ K
Uses 1 · Used by 1

TheoremCharacterization of the axes counted as significant#✓fully proved

The first numSignificant stat t K indices are exactly those k < K whose statistics and all earlier ones exceed the threshold.

theorem lt_numSignificant_iff {stat : ℕ → ℝ} {t : ℝ} {K k : ℕ} :
    k < numSignificant stat t K ↔ k < K ∧ ∀ i ≤ k, t < stat i
Uses 2 · Used by 4

TheoremSignificant axes have statistics above the threshold#✓fully proved

Every axis counted as significant has a statistic above the threshold.

theorem lt_stat_of_lt_numSignificant {stat : ℕ → ℝ} {t : ℝ} {K k : ℕ}
    (h : k < numSignificant stat t K) : t < stat k
Uses 2 · Used by 1

TheoremCriterion for at least one significant axis#✓fully proved

At least one axis is significant iff the leading statistic exceeds the threshold.

theorem numSignificant_pos_iff {stat : ℕ → ℝ} {t : ℝ} {K : ℕ} :
    0 < numSignificant stat t K ↔ 0 < K ∧ t < stat 0
Uses 2

TheoremCount of significant axes decreases with the threshold#✓fully proved

A higher threshold declares no more axes significant.

theorem numSignificant_antitone {stat : ℕ → ℝ} {t t' : ℝ} (htt : t ≤ t') (K : ℕ) :
    numSignificant stat t' K ≤ numSignificant stat t K
Uses 2

TheoremSignificant-axis count for decreasing statistics#✓fully proved

For decreasing statistics (such as ordered eigenvalues compared with a fixed threshold) the sequential count is the number of statistics above the threshold.

theorem numSignificant_eq_card_of_antitone {stat : ℕ → ℝ} (h : Antitone stat) (t : ℝ) (K : ℕ) :
    numSignificant stat t K = ((Finset.range K).filter fun k => t < stat k).card
Uses 2

TheoremConditional error bound#✓fully proved

If, under the null hypothesis, the k-th statistic exceeds t with probability at most 1 - F t (the Tracy–Widom approximation with F the TW₁ distribution function, taken here as a hypothesis), then the rule declares more than k significant axes with probability at most 1 - F t.

theorem measure_lt_numSignificant_le {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω)
    (stat : Ω → ℕ → ℝ) (F : ℝ → ℝ) (t : ℝ) (K k : ℕ)
    (hnull : P {ω | t < stat ω k} ≤ ENNReal.ofReal (1 - F t)) :
    P {ω | k < numSignificant (stat ω) t K} ≤ ENNReal.ofReal (1 - F t)
Uses 2

The dependency explorer needs JavaScript and its graph data.

Download the complete graph data.