Link a 2-d embedding with a tour

limn_tour_link(
  embed_data,
  tour_data,
  cols = NULL,
  color = NULL,
  tour_path = tourr::grand_tour(),
  rescale = clamp,
  morph = "center",
  gadget_mode = TRUE
)

Arguments

embed_data

A data.frame representing embedding coordinates

tour_data

a data.frame to tour

cols

Columns to tour. This can use a tidyselect specification such as tidyselect::starts_with().

color

A variable mapping to the color aesthetic, if NULL points will be colored black.

tour_path

the tour path to take, the default is tourr::grand_tour() but also works with tourr::guided_tour().

rescale

A function that rescales cols, the default is to clamp() the data to lie in the hyperdimensional unit cube. To not perform any scaling use identity().

morph

One of c("center", "centre", "identity", "radial") that rescales each projection along the tour path. The default is to center the projections and divide by half range. See morph_center() for details.

gadget_mode

Run the app as a shiny::runGadget() which will load the app in the RStudio Viewer pane or a browser (default = TRUE). If FALSE will return a regular shiny app object that could be used to deploy the app elsewhere.

Value

After pressing the Done button on the interface, a list of artefacts is returned to the R session.

  • selected_basis: A matrix of the current projection

  • tour_brush_box: A list containing the bounding box of the tour brush

  • embed_brush_box: A list containing the bounding box of the embed brush

  • tour_half_range: The current value of the half range

Details

All controls for the app can be obtained by clicking on the help button, in the bottom panel. More details are described below:

  • The tour view on the left is a dynamic and interactive scatterplot. Brushing on the tour view is activated with the shift key plus a mouse drag. By default it will highlight corresponding points in the xy view and pause the animation.

  • The xy view on the right is an interactive scatterplot. Brushing on the xy view will highlight points in the tour view and is activated via a mouse drag, the type of highlighting depends on the brush mode selected.

  • There is a play button, that when pressed will start the tour.

  • The half range which is the maximum squared Euclidean distance between points in the tour view. The half range is a scale factor for projections and can be thought of as a way of zooming in and out on points. It can be dynamically modified by scrolling (via a mouse-wheel). To reset double click the tour view.

  • The legend can be toggled to highlight groups of points with shift+mouse-click. Multiple groups can be selected in this way. To reset double click the legend title.

Examples

if (interactive()) {
  # tour the first ten columns of the fake tree data and link to the
  # another layout based on t-SNE
  # loads the default interface
  if (requireNamespace("Rtsne", quietly = TRUE)) {
    set.seed(2020)
    tsne <- Rtsne::Rtsne(dplyr::select(fake_trees, dplyr::starts_with("dim")))
    tsne_df <- data.frame(tsneX = tsne$Y[, 1], tsneY = tsne$Y[, 2])
    limn_tour_link(
      tsne_df,
      fake_trees,
      cols = dim1:dim10,
      color = branches
    )
    # assigning to an object will return a list of artefacts after clicking
    # done in the upper right hand corner
    res <- limn_tour_link(tsne_df, fake_trees, cols = dim1:dim10, color = branches)
  }
}