Skip to contents

This function estimates a (possibly closed) parametric curve passing through spatial transcriptomics data and uses this curve to define morphologically relevant coordinates `t` and `r`.

Usage

CurveFinder(xy, knn = 5, prune.outlier = NULL, loop = FALSE)

Arguments

xy

A numeric matrix or data frame with two columns representing the x and y coordinates of the data points.

knn

An integer specifying the number of nearest neighbors used to construct the KNN graph. Default is 5.

prune.outlier

A numeric threshold for pruning outliers based on the distance to the k+1 nearest neighbor. Outliers are removed if their distance exceeds `prune.outlier * median(nnk)`. Defaults to NULL (no pruning).

loop

A logical value indicating whether the curve should be treated as a loop (closed curve). Default is FALSE.

Value

A list containing:

xyt

A data frame with x and y coordinates, fitted curve parameters (`t` and `r`), and fitted values for x and y (`f1` abd `f2`).

curve.plot

A ggplot object showing the original data with the fitted curve overlaid.

coordinate.plot

A ggplot object displaying the data points color-coded by their fitted `t` values.

residuals.plot

A ggplot object displaying the data points color-coded by their fitted `r` values.

Details

To-do

References

Kraemer G, Reichstein M, Mahecha MD (2018). “dimRed and coRanking—Unifying Dimensionality Reduction in R.” _The R Journal_, *10*(1), 342-358.