plot3d-SlingshotDataSet {traviz} | R Documentation

## Plot Slingshot output in 3D

### Description

Tools for visualizing lineages inferred by `slingshot`.

### Usage

    ## S3 method for class 'SlingshotDataSet'
    plot3d(
      x,
      type = NULL,
      linInd = NULL,
      add = FALSE,
      dims = seq_len(3),
      aspect = "iso",
      size = 10,
      col = 1,
      ...
    )

### Arguments

`x` | a `SlingshotDataSet` with results to be plotted.
`type` | character, the type of output to be plotted, can be one of `"lineages"`, `curves`, or `both` (by partial matching), see Details for more.
`linInd` | integer, an index indicating which lineages should be plotted (default is to plot all lineages). If `col` is a vector, it will be subsetted by `linInd`.
`add` | logical, indicates whether the output should be added to an existing plot.
`dims` | numeric, which dimensions to plot (default is `1:3`).
`aspect` | either a logical indicating whether to adjust the aspect ratio or a new ratio, see `plot3d`.
`size` | numeric, size of points for MST (default is `10`), see `plot3d`.
`col` | character or numeric, color(s) for lines, see `par`.
`...` | additional parameters to be passed to `lines3d`.

### Details

If `type == 'lineages'`, straight line connectors between cluster centers will be plotted. If `type == 'curves'`, simultaneous principal curves will be plotted.

When `type` is not specified, the function will first check the `curves` slot and plot the curves, if present. Otherwise, `lineages` will be plotted, if present.

### Value

returns `NULL`.

### Examples

    library(rgl)
    library(slingshot)
    data("crv", package="traviz")
    rd <- slingReducedDim(crv)
    rd <- cbind(rd, rnorm(nrow(rd), sd=.1))
    cl <- apply(slingClusterLabels(crv), 1, which.max)
    sds <- slingshot::slingshot(rd, clusterLabels=cl, start.clus=1)
    slingshot::plot3d.SlingshotDataSet(as.SlingshotDataSet(sds), type = 'b')

    # add to existing plot
    plot3d(rd, col = cl, aspect = 'iso')
    slingshot::plot3d.SlingshotDataSet(as.SlingshotDataSet(sds), lwd = 3, add = TRUE)

[Package traviz version 1.0.0 Index]