Why Center and Normalize a Patient Kernel?
A patient kernel matrix records pairwise similarities in a common matrix: rows and columns correspond to patients, and entry \(K_{ij}\) measures similarity between patients \(i\) and \(j\). Even when two kernels describe the same patients and have a similar pattern of entries, their overall scales can differ. One may also contain a common feature-space offset that makes similarities reflect the overall mean profile rather than deviations around it.
Centering removes that common offset across patients. Normalization then controls scale, but different normalizations answer different questions. Diagonal normalization rescales each patient to have unit kernel norm, making entries comparable as cosine-like similarities. Trace normalization rescales the whole matrix by one number, preserving all relative entry sizes and the centered geometry up to a common scale.
Assume throughout that \(K\) is a real, symmetric, positive semidefinite \(n \times n\) kernel matrix for the same \(n\) patients in a fixed order. Positive semidefiniteness means \(a^\mathsf{T}Ka \geq 0\) for every vector \(a\). As established in the earlier material on Positive Semidefinite Kernels, such a matrix can be represented as inner products of feature vectors. The operations below are applied to patients, so the centering acts across the patient rows and columns, not across omics variables.
Centering Across Patients
The matrix \(H\) subtracts the average across patients. It is symmetric and idempotent: \(H^\mathsf{T}=H\) and \(H^2=H\). Consequently, the centered matrix is symmetric, and its row and column sums are zero: \(K_c\mathbf{1}=0\) and \(\mathbf{1}^\mathsf{T}K_c=0\). These zero sums are an important implementation check.
If \(K_{ij}=\langle \phi_i,\phi_j\rangle\) for feature vectors \(\phi_i\), centering the matrix is equivalent to replacing each feature vector by \(\phi_i-\bar\phi\), where \(\bar\phi=n^{-1}\sum_i\phi_i\). Thus \(K_c\) measures inner products of deviations from the across-patient feature mean. It remains positive semidefinite: for any \(a\), \(a^\mathsf{T}K_ca=(Ha)^\mathsf{T}K(Ha)\geq0\). Centering does not guarantee that every off-diagonal entry is positive; negative entries can represent opposing centered feature deviations.
Worked Example: Centering a Three-Patient Kernel
Suppose a hypothetical kernel for three patients is \(K=\begin{pmatrix}2&1&0\\1&2&1\\0&1&2\end{pmatrix}\). It is symmetric and positive semidefinite (its eigenvalues are approximately \(0.586\), \(2\), and \(3.414\)), so it meets the kernel assumption. The row means are \(1,\;4/3,\;1\), and the grand mean is \(10/9\).
For example, the centered entry for patients 1 and 3 is \((K_c)_{13}=0-1-1+10/9=-8/9\). Applying the same formula to every entry gives
Each row sums to zero, and the trace is \(10/9+4/9+10/9=8/3\). The negative centered similarity between patients 1 and 3 is not an error: after centering, their feature deviations point in opposing directions.
Two Normalizations, Two Interpretations
Both normalizations below are applied to the centered matrix unless stated otherwise. This order makes the target explicit: first remove the patient-wide feature mean, then choose how to control the scale. The diagonal of \(K_c\) contains squared lengths of the centered feature vectors, while its trace is the sum of those squared lengths.
The diagonal-normalized entry is \((K_c)_{ij}/\sqrt{(K_c)_{ii}(K_c)_{jj}}\). In feature terms, it is the cosine similarity between the two centered patient feature vectors. The diagonal entries become one, and the off-diagonal values lie between \(-1\) and \(1\). This removes differences in individual centered feature-vector lengths. It does not mean that all patients have equal information or equal measurement precision.
Trace normalization divides every entry by the same positive scalar. It therefore preserves all entry ratios, signs, and relative geometry; only the overall scale changes. The resulting trace is one, so the sum of its eigenvalues is one. Unlike diagonal normalization, trace normalization generally leaves unequal diagonal entries. It retains the differences in centered feature-vector lengths while fixing their total squared length.
Worked Example: Comparing Diagonal and Trace Normalization
Continue with the hypothetical centered matrix above. Its diagonal entries are \(10/9,\;4/9,\;10/9\), all positive, and its trace is \(8/3\). Therefore both normalizations are defined.
For diagonal normalization, the entry for patients 1 and 2 is \[ \frac{-2/9}{\sqrt{(10/9)(4/9)}}=\frac{-2}{\sqrt{40}}\approx -0.3162, \] and the entry for patients 1 and 3 is \[ \frac{-8/9}{\sqrt{(10/9)(10/9)}}=-0.8000. \] The normalized matrix is approximately
For trace normalization, divide every entry by \(8/3\). For instance, the first diagonal entry is \((10/9)/(8/3)=5/12\), and the \((1,3)\) entry is \((-8/9)/(8/3)=-1/3\). Thus
The diagonal-normalized matrix has unit diagonal, but its rows no longer sum to zero. Trace normalization preserves the zero row sums, because it multiplies the centered matrix by a scalar. The two results are therefore not interchangeable: one reports pairwise angles between centered feature vectors, while the other retains centered inner products on a common total-scale convention.
Why the Properties Hold
The main properties follow directly from the matrix definitions. For diagonal normalization, \(D^{-1/2}\) exists when every diagonal entry is positive. For any vector \(a\),
Thus diagonal normalization preserves positive semidefiniteness. Its diagonal entries equal \((K_c)_{ii}/(K_c)_{ii}=1\). For trace normalization, positive semidefiniteness is preserved because \(a^\mathsf{T}K_{\mathrm{trace}}a=(a^\mathsf{T}K_ca)/\operatorname{tr}(K_c)\), and the denominator is positive. The trace becomes one by construction. In either case, these operations cannot repair a matrix that was not a valid symmetric positive semidefinite kernel.
There is a trade-off. Diagonal normalization rescales each row and column according to that patient’s centered norm. This may be useful when those norm differences are nuisance scale variation, but it changes relative magnitudes across pairs. Trace normalization is a single global rescaling, so it preserves those relative magnitudes and the centered row-sum property. It cannot remove a large scale difference between individual patients.
| Operation | Scale controlled | Property retained | Interpretation |
|---|---|---|---|
| Centering only | Neither individual nor total scale | Zero row and column sums | Inner products of deviations from the patient mean |
| Diagonal normalization after centering | Each patient’s centered feature norm | Positive semidefiniteness; unit diagonal when defined | Cosines between centered feature vectors |
| Trace normalization after centering | Total centered feature energy | Relative entries and zero row sums | Centered kernel on a unit-trace scale |
Worked Example: A Zero Diagonal and an Undefined Cosine
Suppose three hypothetical patients have scalar feature values \(-1,\;0,\;1\), and use the linear kernel, so \(K_{ij}=x_ix_j\). The feature mean is zero, so this kernel is already centered:
Trace normalization is defined and gives \(K_{\mathrm{trace}}=K_c/2\), with trace one. Diagonal normalization is not defined for patient 2, because its centered feature vector has length zero and the denominator for any pair involving that patient is zero. A cosine involving a zero vector has no defined direction.
The appropriate response is to investigate why the patient has zero centered norm and decide whether the intended analysis permits excluding that patient or requires another explicitly justified treatment. Adding an arbitrary small constant to the diagonal creates a different operation and changes the meaning of the similarities; it should not be treated as a harmless numerical fix.
Diagnostics, Order, and Common Pitfalls
A careful implementation checks the assumptions and the output at each stage. Confirm that the matrix is symmetric up to numerical tolerance, that its rows and columns refer to the same patients in the same order, and that it is positive semidefinite up to small floating-point error. After centering, check that row sums are approximately zero and that the trace is nonnegative. If the trace is zero, all centered feature vectors have zero total squared length, so trace normalization is undefined.
- Negative centered entries are not automatically a failure. Check symmetry, positive semidefiniteness, and the centering sums rather than requiring every similarity to be nonnegative.
- Diagonal normalization requires positive centered diagonals. Inspect very small values as well as exact zeros; near-zero norms can make normalized entries numerically unstable.
- Centering and diagonal normalization do not generally commute. Normalizing an uncentered kernel and then centering it does not generally produce the same matrix as centering first and then normalizing. The final matrix need not have both zero row sums and unit diagonal.
- Do not confuse a unit trace with a unit diagonal. Trace normalization constrains the sum of diagonal entries, not each diagonal entry separately.
A common mistake is to say, “The centered kernel has zero row sums, so diagonal normalization must preserve that property.” This is false: diagonal normalization multiplies each row and column by patient-specific factors, not by one common scalar. The correction is to check the desired properties after the final operation. If preserving centering is essential, trace normalization preserves it; diagonal normalization generally does not.
The choice depends on the scientific purpose. Use diagonal normalization when the target comparison is angular similarity after removing patient-specific centered norms, provided all norms are positive and meaningful. Use trace normalization when the matrix should retain its relative inner-product structure while its total scale is standardized. Neither choice is universally preferable, and neither addresses differences in sample composition, missingness, or measurement quality by itself. Those issues require separate analysis.
Worked Example: Rescaling a Kernel Without Changing Its Pattern
Let the hypothetical centered matrix from the first example be multiplied by three, giving \(\widetilde K_c=3K_c\). Its trace is \(3(8/3)=8\), and its \((1,3)\) entry is \(-8/3\). Trace normalization gives \(\widetilde K_c/8\); for that entry, \((-8/3)/8=-1/3\), exactly the \((1,3)\) value obtained by trace-normalizing \(K_c\).
Diagonal normalization also gives the same result as before: both the numerator and the product of diagonal terms scale by three, so \[ \frac{3(K_c)_{ij}}{\sqrt{3(K_c)_{ii}\,3(K_c)_{jj}}} =\frac{(K_c)_{ij}}{\sqrt{(K_c)_{ii}(K_c)_{jj}}}. \] Thus either normalization removes a positive global multiplier. Their substantive difference is not global-scale invariance; it is that diagonal normalization also changes the relative scale of pairs involving patients with different centered norms.
Check Your Understanding
Answer each question, then compare with the solutions below.
- What two properties of \(H\) imply that \(K_c=HKH\) remains positive semidefinite?
- After centering, the diagonal entries are \(2,\;8\) and the off-diagonal entry is \(-2\). What is the diagonal-normalized off-diagonal entry?
- If a centered kernel has trace \(10\), what does trace normalization do to its trace, and does it necessarily make every diagonal entry equal?
- Why can diagonal normalization destroy the zero row sums produced by centering?
Solutions. (1) \(H\) is symmetric, and \(a^\mathsf{T}HKHa=(Ha)^\mathsf{T}K(Ha)\geq0\) because \(K\) is positive semidefinite. (2) The value is \(-2/\sqrt{2\cdot8}=-0.5000\). (3) It divides all entries by \(10\), producing trace one; the diagonal entries need not be equal. (4) It applies different scale factors to different patients’ rows and columns, rather than multiplying the whole matrix by one scalar, so the original row sums need not remain zero.