| infer_trajectory {SCORPIUS} | R Documentation | 
Infer linear trajectory through space
Description
infer_trajectory infers a trajectory through samples in a given space in a four-step process:
- Perform k-means clustering 
- Calculate distance matrix between cluster centers using a custom distance function 
- Find the shortest path connecting all cluster centers using the custom distance matrix 
- Iteratively fit a curve to the given data using principal curves 
Usage
infer_trajectory(
  space,
  k = 4,
  thresh = 0.001,
  maxit = 10,
  stretch = 0,
  smoother = "smooth_spline",
  approx_points = 100
)
Arguments
| space | A numeric matrix or a data frame containing the coordinates of samples. | 
| k | The number of clusters to cluster the data into. | 
| thresh | convergence threshold on shortest distances to the curve. | 
| maxit | maximum number of iterations. | 
| stretch | A stretch factor for the endpoints of the curve, allowing the curve to grow to avoid bunching at the end. Must be a numeric value between 0 and 2. | 
| smoother | choice of smoother. The default is
 | 
| approx_points | Approximate curve after smoothing to reduce computational time.
If  | 
Value
A list containing several objects:
-  path: the trajectory obtained by principal curves.
-  time: the time point of each sample along the inferred trajectory.
See Also
reduce_dimensionality, draw_trajectory_plot
Examples
## Generate an example dataset and visualise it
dataset <- generate_dataset(num_genes = 200, num_samples = 400, num_groups = 4)
space <- reduce_dimensionality(dataset$expression, ndim = 2)
draw_trajectory_plot(space, progression_group = dataset$sample_info$group_name)
## Infer a trajectory through this space
traj <- infer_trajectory(space)
## Visualise the trajectory
draw_trajectory_plot(space, path=traj$path, progression_group = dataset$sample_info$group_name)