Weighted Alignment

Weighted alignment methods in GWProt allow for optimal superposition of two point clouds (e.g., protein structures) using a correspondence as weights. This is particularly useful for comparing structures after GW or FGW alignment, where the correspondence encodes the correspondence between residues.

Weighted RMSD Alignment

GWProt.weighted_alignment.weighted_RMSD(X: array, Y: array, T: array) tuple[numpy.array, numpy.array, numpy.array]

This method uses the Kabsch algorithm to find a rigid, orientation-preserving transformation that minimizes weighted RMSD.

Parameters
  • X – A np.array of shape (n,3) representing the n row vectors in R^3 defining X

  • Y – A np.array of shape (m,3) representing the m row vectors in R^3 defining Y

  • T – A np.array of shape (n,m) representing the correspondence or weights for the alignment. Its entries must be non-negative.

So T[i,j] defines how strongly the distance between X[i,:] and Y[j,:] should be weighted in the minimization. :return: -y_mean, rot, x_mean, where rot is a 3x3 matrix.

This function finds a special orthogonal matrix \(S\) that minimizes the weighted sum of squared distances:

\[\sum_{i,j} |(x_i - x') - S(y_j - y')|^2 \cdot T_{i,j}\]

where \(x'\) is the weighted mean of the \(x_i\) and \(y'\) is the weighted mean of the \(y_j\), and \(T_{i,j}\) is the correspondence (e.g., from GW alignment).

Note: In general, there may not be a unique solution matrix \(S\) that minimizes this expression.

After alignment, (Y - y_mean) @ rot + x_mean and X should be superimposed. If n == m and T is the identity matrix, this reduces to the classic Kabsch algorithm for minimizing RMSD between X and Y.

This approach is especially useful for visualizing and quantifying structural similarity after optimal transport-based alignments, and can be used in conjunction with LGD analysis.