embedCurves {slingshot} | R Documentation

## Embed trajectory in new space

### Description

This function takes the output of `slingshot` (or `getCurves`) and attempts to embed the curves in a different coordinate space than the one in which they were constructed. This should be considered a visualization tool, only.

### Usage

    embedCurves(x, newDimRed, ...)

    ## S4 method for signature 'PseudotimeOrdering,matrix'
    embedCurves(
      x,
      newDimRed,
      shrink = NULL,
      stretch = NULL,
      approx_points = NULL,
      smoother = NULL,
      shrink.method = NULL,
      ...
    )

    ## S4 method for signature 'SingleCellExperiment,matrix'
    embedCurves(
      x,
      newDimRed,
      shrink = NULL,
      stretch = NULL,
      approx_points = NULL,
      smoother = NULL,
      shrink.method = NULL,
      ...
    )

    ## S4 method for signature 'SingleCellExperiment,character'
    embedCurves(
      x,
      newDimRed,
      shrink = NULL,
      stretch = NULL,
      approx_points = NULL,
      smoother = NULL,
      shrink.method = NULL,
      ...
    )

### Arguments

`x` | an object containing `slingshot` output.
`newDimRed` | a matrix representing the new coordinate space in which to embed the curves.
`...` | Additional parameters to pass to scatter plot smoothing function, `smoother`.
`shrink` | logical or numeric between 0 and 1, determines whether and how much to shrink branching lineages toward their average prior to the split.
`stretch` | numeric factor by which curves can be extrapolated beyond endpoints. Default is `2`, see `principal_curve`.
`approx_points` | numeric, whether curves should be approximated by a fixed number of points. If `FALSE` (or 0), no approximation will be performed and curves will contain as many points as the input data. If numeric, curves will be approximated by this number of points; preferably about 100 (see `principal_curve`).
`smoother,` | choice of scatter plot smoother. Same as `principal_curve`, but `"lowess"` option is replaced with `"loess"` for additional flexibility.
`shrink.method` | character denoting how to determine the appropriate amount of shrinkage for a branching lineage. Accepted values are the same as for `kernel` in `density` (default is `"cosine"`), as well as `"tricube"` and `"density"`. See 'Details' for more.

### Details

Many of the same parameters are used here as in `getCurves`. This function attempts to translate curves from one reduced dimensional space to another by predicting each dimension as a function of pseudotime (ie. the new curve is determined by a series of scatterplot smoothers predicting the coordinates in the new space as a function of pseudotime). Because the pseudotime values are not changed, this amounts to a single iteration of the iterative curve-fitting process used by `getCurves`.

Note that non-linear dimensionality reduction techniques (such as tSNE and UMAP) may produce discontinuities not observed in other spaces. Use caution when embedding curves in these spaces.

### Value

a `PseudotimeOrdering` object containing curves in the new space.

### Examples

    data("slingshotExample")
    rd <- slingshotExample$rd
    cl <- slingshotExample$cl
    pto <- slingshot(rd, cl, start.clus = '1')
    rd2 <- cbind(rd[,2] + rnorm(nrow(rd)), -rd[,1] + rnorm(nrow(rd)))
    pto.new <- embedCurves(pto, rd2)
    pto.new

    plot(rd2, col = cl, asp = 1)
    lines(SlingshotDataSet(pto.new), lwd = 3)

[Package slingshot version 2.2.1 Index]