langevitour: Langevin Tour

View source: R/langevitour.R

langevitourR Documentation

Langevin Tour

Description

Make a Langevin Tour HTML widget, which can be used to explore high-dimensional numerical datasets.

Usage

langevitour(
  X,
  group = NULL,
  name = NULL,
  center = NULL,
  scale = NULL,
  extraAxes = NULL,
  lineFrom = NULL,
  lineTo = NULL,
  lineColors = NULL,
  axisColors = NULL,
  levelColors = NULL,
  colorVariation = 0.1,
  pointSize = 1,
  subsample = NULL,
  state = NULL,
  width = NULL,
  height = NULL,
  elementId = NULL,
  link = NULL,
  link_filter = TRUE
)

Arguments

X

The data to plot. A matrix of numeric data, or something that can be cast to a matrix. Rows will be shown as points in the widget. Columns are the variables of your data.

group

A group for each row in X, will be used to color points. A factor, or something that can be cast to a factor.

name

A name for each row in X.

center

Center for each variable. If omitted, the column means will be used.

scale

Scale for each variable. Scale +/- center will be the range of guaranteed visible data. If omitted, a reasonable default will be chosen, equal for all variables. (The default is the largest singular value of the centered X times 2.5.)

extraAxes

A matrix with each column defining a projection of interest. The columns of X %*% extraAxes will be presented as extra "variables".

lineFrom

A vector of row numbers. Draw lines starting at these rows.

lineTo

A vector of row numbers. Draw lines ending at these rows.

lineColors

Character vector. A CSS color for each line.

axisColors

Character vector. CSS colors for each variable and then each extra axis.

levelColors

Character vector. CSS colors for each level of group.

colorVariation

Number between 0 and 1. Individual points are given slightly different brightnesses. How strong should this effect be?

pointSize

Point radius in pixels. A single number, or a number for each row in X.

subsample

For speed, randomly subsample down to this many rows.

state

A JSON string, or an object that htmlwidgets will convert to the correct JSON. Initial widget state settings. The state of a widget can be obtained from its "further controls and information" pane. I am not going to guarantee that states will be compatible between versions of langevitour. Hint: Since JSON uses double quotes, surround the string in single quotes.

width

Width of widget in CSS units, for example "700px" or "100%".

height

Height of widget in CSS units, for example "600px" or "75vh".

elementId

An element ID for the widget, see htmlwidgets::createWidget.

link

A SharedData object from the crosstalk package to share selections and filters with other htmlwidgets. The data in this object is not used, just the keys and group name. The rows of link$origData() should correspond to the rows of X.

link_filter

TRUE or FALSE. If using crosstalk, should hiding groups in langevitour also cause them to be filtered in linked widgets?

Details

The only required argument is X, the high-dimensional collection of points. The group argument is also commonly used so that groups of points can be distinguished by color. Further arguments adjust the appearance or provide advanced features.

langevitour will by default not scale variables individually. If you want variables to be individually scaled, use something like scale=apply(X,2,sd)*4. Using the scale argument rather than modifying X directly ensures the plot axes within the widgets retain the original units.

In Javascript, the langevitour object can be obtained using document.getElementById(elementId).langevitour. For example you could have a button that sets the state of a widget using document.getElementById(elementId).langevitour.setState(desiredState).

Value

An htmlwidget object.

Examples

library(palmerpenguins)

completePenguins <- na.omit(penguins[,c(1,3,4,5,6)])
scale <- apply(completePenguins[,-1], 2, sd)*4

langevitour(
    completePenguins[,-1], 
    completePenguins$species, 
    scale=scale, pointSize=2)


# An example setting the widget's initial state
 
langevitour(
    completePenguins[,-1], 
    completePenguins$species, 
    scale=scale, pointSize=2,
    state='{"guideType":"pca","labelInactive":["bill_length_mm"]}')


langevitour documentation built on May 29, 2024, 8:21 a.m.