From Projections to a Fitted Curve
A principal curve is not specified by a single straight direction: its shape is estimated from the observations themselves. Fitting it therefore requires two linked operations. Given a current curve, project each observation onto it to obtain a curve position; given those positions, smooth the observations to update the curve. Repeating these operations produces an iterative fit.
Assume observations \(x_1,\ldots,x_n\) lie in a Euclidean feature space, such as a chosen low-dimensional representation of cells. The distance used for projection is the Euclidean distance in that space. The feature coordinates and their scaling must be meaningful for that distance: a coordinate measured on a much larger numerical scale can otherwise dominate the projection. Let \(f(t)\) denote a curve parameterized by arc length, so differences in \(t\) measure distance traveled along the curve. For observation \(x_i\), its projection parameter on the current curve \(f^{(r)}\) is a value minimizing its squared distance to the curve.
There may be more than one minimizing value, for example when an observation is equally close to two parts of a curve. The fitting procedure must use a consistent rule for choosing among ties. In computations, the curve is represented by a finite set of points or a smooth basis, so projection and smoothing are implemented numerically rather than over every possible curve.
Why the Smoothing Step Is Natural
Once projection parameters have been assigned, the curve is treated as a function of position along itself. At a given parameter value, the target curve location is the conditional mean of observations having that projection position. The mean arises because it minimizes expected squared Euclidean error. To see this, let \(m=E[X\mid\lambda=t]\) and consider any candidate vector \(a\). Expanding the squared distance and using \(E[X-m\mid\lambda=t]=0\) gives:
The second term is nonnegative and is zero only when \(a=m\). Thus the conditional mean is the least-squares target at each curve position. With finite observations, there are usually too few observations at any exact value of \(t\) to estimate that conditional mean directly. Instead, smooth each coordinate against the projected parameters. A local regression, spline smoother, or another suitable regression smoother can be used. The choice controls how much the fitted curve can bend.
After smoothing, the resulting path may need to be reparameterized by arc length before the next projection step. This keeps the parameter's interpretation consistent: equal increments represent equal distances along the fitted path. A practical implementation may also approximate the smoothed path by a polyline for projection.
The Alternating Updates
For every \(x_i\), find a closest point on the current curve and record its parameter \(\lambda_i^{(r)}\). Use the same distance metric and tie rule throughout the fit.
Regress each coordinate of \(x_i\) on \(\lambda_i^{(r)}\). Evaluate the resulting smooth functions over the parameter range to form a new curve.
Parameterize the updated path by arc length, then check how much the curve and the projection-based fit criterion have changed.
Use the updated curve for the next projection step. Stop when prespecified changes are small, while still checking for unstable assignments or an inadequate shape.
This is an alternating procedure, not a guarantee that every choice of smoother will decrease one single objective at every update. Projection reduces distances to a fixed curve, but smoothing may trade local fit for smoothness. Even when updates stabilize, that only shows that the chosen numerical procedure has settled; it does not establish that the curve is globally best among all possible curves.
Worked Example: One Projection and Smoothing Update
Consider three hypothetical observations in two dimensions: \(x_1=(0,0)\), \(x_2=(1,1)\), and \(x_3=(2,0)\). Begin with the horizontal curve \(f^{(0)}(t)=(t,0)\), represented over \(0\leq t\leq2\). The closest point on this curve has the same first coordinate as each observation, so the projection parameters are \(0,1,2\), respectively. Suppose the chosen graph smoother leaves the parameter coordinate \(t\) fixed and uses these local averages for the second coordinate: average the first two observations at \(t=0\), all three at \(t=1\), and the last two at \(t=2\).
At \(t=0\), the smoothed second coordinate is \((0+1)/2=0.5\). At \(t=1\), it is \((0+1+0)/3=0.3333\). At \(t=2\), it is \((1+0)/2=0.5\). The updated graph, joined by straight segments between knots, therefore passes through \((0,0.5)\), \((1,0.3333)\), and \((2,0.5)\). This update has turned the initial horizontal path into a shallow curved path following the local averages of the observations.
This calculation illustrates a graph-constrained smoother: it smooths the response coordinate while holding the parameter coordinate fixed. A general principal-curve implementation may smooth every coordinate and reparameterize the resulting path. The graph constraint is useful for this small calculation, but it is not appropriate when the curve cannot be represented as a single-valued function of the chosen horizontal coordinate.
Worked Example: Computing a Projection on an Updated Segment
Use the first segment of the updated curve above, from \(a=(0,0.5)\) to \(b=(1,0.3333)\), to project \(x_1=(0,0)\). For a segment, write \(v=b-a\), calculate the scalar projection fraction, and truncate that fraction to the interval \([0,1]\) if the closest point would fall beyond an endpoint.
Since \(u\) is between zero and one, the closest point on this segment is \(a+uv\), approximately \((0.0811,0.4865)\). Its squared distance from \(x_1\) is approximately \(0.0811^2+0.4865^2=0.2433\). The other segments of the curve must also be considered; a projection onto a whole polyline is the closest among its segment-wise projections. This illustrates why the projections must be recomputed after a smoothing update: the original value \(t=0\) need not remain the closest position on the updated curve.
Worked Example: Checking Whether Updates Have Stabilized
Suppose a numerical implementation records the sum of squared distances from the observations to their closest points on the curve after each complete projection-and-smoothing cycle. For a hypothetical run, the recorded values are \(12.40\), \(8.10\), and \(7.92\). The relative decrease from the first to the second cycle is \((12.40-8.10)/12.40=0.3468\), or about 34.7%. From the second to the third, it is \((8.10-7.92)/8.10=0.02222\), or about 2.22%.
If a prespecified stopping rule requires a relative decrease below 1%, these values alone do not meet the rule: 2.22% is greater than 1%. If the next cycle yields \(7.88\), its relative decrease is \((7.92-7.88)/7.92=0.005051\), or about 0.505%, and the criterion is met. This is evidence of small change in that recorded criterion, not proof that the curve represents the biology correctly. A run should also monitor movement of the curve itself and changes in the projection assignments.
Assumptions, Diagnostics, and Alternatives
The interpretation of these updates depends on several choices. The observations must be represented in a space where Euclidean distance is meaningful for the intended analysis. The smoother must be appropriate for the number and distribution of projected observations: a very flexible smoother can chase noise, while an overly rigid one can flatten genuine curvature. Projection assignments should be stable enough that smoothing against them is informative. Finally, a single smooth path is a modeling choice. It may be unsuitable when the cell states form distinct paths or when the geometry is not well represented by one curve.
Useful diagnostics include plotting observations and the curve in the fitted feature space, checking the distribution of projection parameters, tracking changes in the curve and the fit criterion across iterations, and inspecting whether a few observations have unusually large distances. Repeated large jumps in projection positions or a curve that oscillates between updates can indicate that the smoothing and projection steps are not settling reliably. A flat-looking curve despite visibly curved data may indicate excessive smoothing; sharp bends that follow individual observations may indicate too little smoothing.
A principal component line is a simpler alternative: it summarizes variation along a straight direction and does not adapt its shape to curved structure. A spline fitted against a fixed external ordering is another alternative, but it assumes that the ordering is supplied independently rather than recalculated as closest positions on the curve. Principal-curve fitting combines a flexible path with data-dependent projection positions, at the cost of iterative computation and sensitivity to the representation and smoothing choices.
- Mistake: Treating a small change in the distance criterion as proof that the inferred trajectory is correct. Correction: Small change indicates numerical stabilization under the chosen representation and smoother; it does not validate the model or the biological interpretation.
- Mistake: Smoothing once and keeping the original projection parameters for all later calculations. Correction: Each updated curve changes the closest points, so recompute projections before the next smoothing update.
- Mistake: Assuming the squared-distance criterion must fall at every step. Correction: The projection step minimizes distances for a fixed curve, but a smoother may impose regularization or otherwise trade fit for smoothness. Monitor the actual procedure rather than assuming monotone improvement.
Check Your Understanding
Answer each question, then compare with the solutions below.
- What are the two alternating operations in principal-curve fitting?
- Why does the conditional mean provide the least-squares target for the curve at a fixed projection position?
- After smoothing changes the curve, why should projection parameters be recalculated?
- A run's fit criterion changes very little over several cycles. What does this establish, and what does it not establish?
- Name one way a smoother can make the fitted curve misleading, and give the corresponding diagnostic.
Solutions. (1) Project observations onto the current curve, then smooth their coordinates as functions of the projection parameters to update the curve. (2) For any candidate point \(a\), the conditional expected squared distance equals the conditional variance term plus \(\|a-E[X\mid\lambda=t]\|^2\), which is minimized at the conditional mean. (3) Moving the curve changes which points are closest, so the old projection parameters may no longer minimize distance. (4) It supports numerical stabilization for the chosen procedure; it does not prove global optimality, model adequacy, or biological validity. (5) Excessive flexibility can create sharp bends that follow noise; inspect the curve against the observations and consider whether the bends are supported across nearby observations.