Tutorials › Multi-Omics Data Integration › Matching Factors Under Sign And Permutation Ambiguity

Latent Factor Models and Their Interpretation · Tutorial 243 of 597

Matching Factors Under Sign And Permutation Ambiguity

Learn to align factor columns using sign-invariant loading similarities and a globally optimal one-to-one assignment.

Advanced 10 min read

What You'll Learn

  • Explain why factor signs and column order can change without changing a fitted factor model.
  • Compute cosine similarities between loading profiles on a common feature set.
  • Choose signs and factor matches by maximizing total similarity over one-to-one assignments.
  • Distinguish a clear match from a weak or ambiguous match.
  • Identify when rotation, different feature sets, or different factor counts limit interpretation.

Why Factor Matches Need Alignment

Two fits of a latent factor model can describe similar structure while listing factors in different orders or with opposite signs. Neither change necessarily reflects a biological difference: permuting factor columns and applying a corresponding permutation to scores leaves the model representation unchanged, while reversing a factor’s sign in both its scores and loadings also leaves the fitted signal unchanged. Directly comparing “factor 1” from one fit with “factor 1” from another can therefore be misleading.

The task here is to match factors across two fitted solutions using their loading profiles. A loading profile is the vector of feature loadings for one factor. The comparison requires the same features, in the same order, in both profiles. This tutorial focuses on sign reversals and permutations; it does not treat general rotations that mix several factors together.

Definition: Let \(L^{(A)}\) and \(L^{(B)}\) be loading matrices from two fits, with \(p\) shared features and \(K_A\) and \(K_B\) factors. Rows represent the same features in the same order; columns are factors. Write \(l^{(A)}_a\) and \(l^{(B)}_b\) for their respective loading columns. A factor match pairs one column from fit A with one column from fit B. A sign reversal changes a column \(l\) to \(-l\); a permutation changes the order of columns.

Before calculating similarities, confirm that the two fits use comparable loading scales and the same feature definitions. If features were transformed or standardized differently, apparent differences may reflect preprocessing rather than factors. Restrict both profiles to the same shared features, aligned in the same order. A factor with a zero loading vector cannot be compared by cosine similarity.

Measuring Similarity While Allowing Sign Reversal

A useful scale-invariant comparison is cosine similarity. It is the dot product of two loading vectors divided by the product of their Euclidean lengths. Cosine similarity is \(1\) for identical directions, \(-1\) for opposite directions, and \(0\) for orthogonal vectors. Since opposite signs can represent the same factor, use its absolute value when assessing a potential match.

$$ c_{ab} = \frac{\left(l^{(A)}_a\right)^{T}l^{(B)}_b} {\left\|l^{(A)}_a\right\|_2\left\|l^{(B)}_b\right\|_2}, \qquad s_{ab}=|c_{ab}|. $$

Here \(c_{ab}\) is the signed cosine and \(s_{ab}\), between 0 and 1, is the sign-invariant similarity. When a pair is matched, choose the sign that makes its signed cosine nonnegative: retain \(l^{(B)}_b\) if \(c_{ab}\geq 0\), and replace it by \(-l^{(B)}_b\) if \(c_{ab}<0\). This convention aligns loading directions; the corresponding factor scores must also have their signs reversed if the fitted representation is to remain unchanged.

Cosine similarity compares directions and ignores overall magnitude. That is helpful when fits have different factor scales, but it also means that a small loading vector can appear highly similar to a large one. If magnitudes are scientifically meaningful and the fits use comparable scales, record them separately rather than expecting cosine similarity to assess them. Correlation between loading columns is another option when similarity of centered feature patterns is the target. It centers each vector before comparison, so it answers a different question and can be unstable when a centered vector has very little variation.

Worked Example: Correcting a Sign Reversal and a Swap

Suppose three shared features have the following hypothetical loading columns: \(l^{(A)}_1=(0.8,0.6,0)^T\), \(l^{(A)}_2=(0,0.6,0.8)^T\), \(l^{(B)}_1=(0, -0.6,-0.8)^T\), and \(l^{(B)}_2=(0.8,0.6,0)^T\). Each vector has length 1, so the signed cosine is just the dot product.

For A factor 1 against B factor 1, the dot product is \(0(0.8)+0.6(-0.6)+0(-0.8)=-0.36\). For A factor 1 against B factor 2, it is \(0.8(0.8)+0.6(0.6)+0(0)=0.64+0.36=1\). For A factor 2 against B factor 1, it is \(0(0)+0.6(-0.6)+0.8(-0.8)=-0.36-0.64=-1\). For A factor 2 against B factor 2, it is \(0(0.8)+0.6(0.6)+0.8(0)=0.36\).

Thus the matrix of absolute similarities, with A factors as rows and B factors as columns, is \(\begin{pmatrix}0.36&1\\1&0.36\end{pmatrix}\). The best pairing is A factor 1 with B factor 2, and A factor 2 with B factor 1. The second pair has signed cosine \(-1\), so reverse B factor 1’s sign. The factors then agree exactly. Comparing columns in their original order would have obscured this match.

One-to-One Assignment

After computing all pairwise similarities, choose the matching that maximizes their total. A one-to-one assignment means each factor is used at most once: one factor in fit B cannot be assigned to two factors in fit A. For equal factor counts \(K\), let \(\pi\) be a permutation of \(1,\ldots,K\), where A factor \(a\) is matched to B factor \(\pi(a)\). Choose the permutation maximizing the sum of absolute cosines.

$$ \hat{\pi} = \arg\max_{\pi} \sum_{a=1}^{K}s_{a,\pi(a)}. $$

This is a linear assignment problem and can be solved by the Hungarian algorithm. The objective is a global sum, not a sequence of independent choices of the largest entry in each row. For unequal numbers of factors, a rectangular assignment can match every factor on the smaller side to a distinct factor on the larger side. If the scientific goal is to permit unmatched factors on either side, add dummy assignments with a prespecified score or use an explicit match threshold; report that choice because it changes which pairings are allowed.

Justification: For a fixed pairing \(a\leftrightarrow b\), choosing the sign \(d\in\{-1,+1\}\) for B’s loading column gives signed agreement \(d\,c_{ab}\). Its maximum over the two possible signs is \(|c_{ab}|=s_{ab}\). Since each pair’s sign can be selected independently, maximizing total signed agreement over both signs and one-to-one pairings reduces to maximizing \(\sum_a s_{a,\pi(a)}\) over permutations. Thus the absolute-similarity assignment finds the best pairing under this objective, and each matched sign is then set from its signed cosine.

Worked Example: Why the Global Assignment Matters

Consider this hypothetical absolute-similarity matrix, with rows A1 and A2 and columns B1 and B2: \(\begin{pmatrix}0.80&0.70\\0.75&0.10\end{pmatrix}\). A greedy rule that first chooses the largest entry selects A1–B1 at 0.80. It must then assign A2–B2 at 0.10, for a total of \(0.80+0.10=0.90\).

The other one-to-one assignment pairs A1–B2 and A2–B1, for a total of \(0.70+0.75=1.45\). Since \(1.45>0.90\), the global optimum is the crossed assignment. A locally largest pair can prevent a better overall match. In an actual analysis, the assignment algorithm compares feasible permutations rather than relying on this greedy choice.

Interpreting Match Quality and Its Limits

The assignment returns a best pairing under the chosen similarity measure; it does not certify that the pairing is strong or uniquely interpretable. Inspect the signed and absolute similarity matrices, the selected similarities, and plausible competing assignments. A selected similarity close to 1 indicates similar loading directions on the shared features. A low selected value means the best available match is still weak. Similar totals for two different assignments indicate ambiguity even if every selected pair looks moderately similar.

Do not treat a universal cutoff as a definition of a valid factor match. What counts as adequate similarity depends on the number and type of shared features, loading sparsity, noise, and the intended interpretation. A factor may also look different because its signal is distributed across several columns in one fit. Sign-and-permutation matching cannot resolve that case: it only tests whether one column resembles another up to sign.

Worked Example: Recognizing a Weak Match

Suppose two fits each have two factors, and their hypothetical absolute-similarity matrix is \(\begin{pmatrix}0.62&0.59\\0.60&0.58\end{pmatrix}\). The diagonal assignment totals \(0.62+0.58=1.20\); the crossed assignment totals \(0.59+0.60=1.19\). The diagonal is the formal optimum, but the difference in totals is only \(1.20-1.19=0.01\), and its selected similarities are only 0.62 and 0.58.

The result supports a tentative pairing, not a clear identification of corresponding factors. The near-tie means the assignment is sensitive to small changes in the loading estimates. It would be misleading to report the diagonal matches as unambiguous simply because the algorithm returns one optimum.

The main alternative to a one-to-one assignment is manual or independent pairwise matching. It can be useful for small problems and for inspecting biologically meaningful loading patterns, but independent comparisons can assign the same factor twice and need not maximize overall agreement. A correlation-based similarity may better suit centered pattern comparison, while a signed dot product on a common scale retains both direction and magnitude; each changes the target of matching. Whatever measure is chosen, use it consistently and state it.

General rotations are a more substantial limitation. If two solutions differ by a rotation that mixes factors, no permutation and sign changes alone need align their columns. That situation calls for a method designed to compare subspaces or to align rotated solutions, not a claim that a poor one-to-one match demonstrates absence of shared structure. Matching also does not establish biological identity or causal meaning; it is a descriptive comparison of fitted loading profiles.

Practical Alignment and Diagnostics

1
Establish comparability.
Confirm that features have the same definitions and order, and restrict both loading matrices to the same shared feature set. Check that preprocessing and factor scaling do not make the intended comparison incoherent.
2
Compute the similarity matrix.
For every candidate pair, calculate signed cosine and its absolute value. Flag zero-norm columns and inspect whether a few features dominate the comparison.
3
Find a one-to-one assignment.
Maximize the sum of the chosen similarities with a linear assignment algorithm. State how unequal factor counts or unmatched factors were handled.
4
Orient and assess matches.
Reverse the sign of each matched B column when its signed cosine is negative, and make the corresponding score change. Report selected similarities and inspect competing assignments and weak matches.

Common warning signs include inconsistent feature ordering, incomparable transformations, near-tied assignments, low similarities, zero or nearly zero loading columns, and matches driven by a small number of features. If several fits are being compared, a reference fit and consistent preprocessing can make results easier to describe, but the chosen reference can affect the labels. Matching is an alignment step, not a substitute for examining the loading patterns or the fitted model.

Key takeaway: To handle sign and order ambiguity, compare loading columns on common features, use a sign-invariant similarity such as absolute cosine, and find a globally optimal one-to-one assignment. Then report match strength and ambiguity, not only the returned factor labels.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions below.

  1. If a matched pair has signed cosine \(-0.84\), what absolute similarity is used for assignment, and what sign adjustment aligns the loading columns?
  2. A two-factor similarity matrix is \(\begin{pmatrix}0.9&0.8\\0.85&0.1\end{pmatrix}\). Which assignment maximizes the total similarity?
  3. Why can a high cosine similarity fail to show that two factors have similar loading magnitudes?
  4. What does a near tie between the best and second-best assignment totals suggest?
  5. Can sign-and-permutation matching generally align factors when one solution is a rotation mixing several columns? Explain.

Solutions. (1) The assignment similarity is \(|-0.84|=0.84\). Reverse the sign of one matched loading column; if the full factor representation is retained, reverse its scores as well. (2) The diagonal total is \(0.9+0.1=1.00\); the crossed total is \(0.8+0.85=1.65\), so the crossed pairing is optimal. (3) Cosine depends on direction and divides by both vector lengths, so multiplying either loading vector by a positive constant leaves the cosine unchanged. (4) The matching is ambiguous: small changes could alter which assignment is optimal, so the selected pairs should not be presented as definitive. (5) Generally not. A permutation and sign changes only reorder or reverse individual columns; a general rotation mixes columns, requiring a comparison method that allows rotated or subspace-level agreement.

Clinical Biostats