fitTrajectory {CellTrails} | R Documentation

## Align samples to trajectory

### Description

Orthogonal projection of each sample to the trajectory backbone.

### Usage

    fitTrajectory(sce)

### Arguments

`sce` | A `SingleCellExperiment` object

### Details

The previously selected component (with k states) defines the trajectory backbone. With this function CellTrails embeds the trajectory structure in the latent space by computing k-1 straight lines passing through k mediancentres (Bedall & Zimmermann, 1979) of adjacent states. Then, a fitting function is learned. Each sample is projected to its most proximal straight line passing through the mediancentre of its assigned state. Here, whenever possible, projections on line segments between two mediancentres are preferred. Residuals (fitting deviations) are given by the Euclidean distance between the sample's location and the straight line. Finally, a weighted acyclic trajectory graph can be constructed based on each sample’s position along its straight line. In addition, data vectors are connected to mediancentres to enable the proper determination of branching points. Each edge is weighted by the distance between each node (sample) after orthogonal projection.
Of note, the fitting function implies potential side branches in the trajectory graph; those could be caused due to technical variance or encompass samples that were statistically indistinguishable from the main trajectory given the selected genes used for trajectory reconstruction.
Diagnostic messages
An error is thrown if an trajectory graph component was not computed or selected yet; functions `connectStates` and `selectTrajectory` need to be run first.

### Value

An updated `SingleCellExperiment` object

### Author(s)

Daniel C. Ellwanger

### References

Bedall, F.K., and Zimmermann, H. (1979). Algorithm AS143. The mediancentre. Appl Statist 28, 325-328.

### See Also

`connectStates` `selectTrajectory`

### Examples

    # Example data
    data(exSCE)

    # Align samples to trajectory
    exSCE <- fitTrajectory(exSCE)

[Package CellTrails version 1.8.0 Index]