
Last chance! 50% off unlimited learning
Sale ends in
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
infer_trajectory(
space,
k = 4,
thresh = 0.001,
maxit = 10,
stretch = 0,
smoother = "smooth_spline",
approx_points = 100
)
A list containing several objects:
path
: the trajectory obtained by principal curves.
time
: the time point of each sample along the inferred trajectory.
A numeric matrix or a data frame containing the coordinates of samples.
The number of clusters to cluster the data into.
convergence threshold on shortest distances to the curve.
maximum number of iterations.
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.
choice of smoother. The default is
"smooth_spline"
, and other choices are "lowess"
and
"periodic_lowess"
. The latter allows one to fit closed curves.
Beware, you may want to use iter = 0
with lowess()
.
Approximate curve after smoothing to reduce computational time.
If FALSE
, no approximation of the curve occurs. Otherwise,
approx_points
must be equal to the number of points the curve
gets approximated to; preferably about 100.
reduce_dimensionality
, draw_trajectory_plot
## 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)
Run the code above in your browser using DataLab