langevitour is an HTML widget that randomly tours projections of ahigh-dimensional dataset with an animated scatter-plot. The user canmanipulate the plot to use specified axes, or turn on Guided Tour modeto performprojectionpursuit, finding an informative projection of the data. Groupswithin the data can be hidden or shown, as can particular axes. Knownprojections of interest can be added as “extra axes” and alsomanipulated. The widget can be used from within R or Python, or includedin a self-contained Rmarkdown document, or a Shiny app, or used directlyfrom Javascript.
langevitour is a twist on the “tour” concept from software such asXGobi,GGobi,tourr,ferrn,liminal,detourr,spinifex, andloon.tour.The new element in langevitour is the use ofLangevinDynamics to generate the sequence of projections.
langevitour is described in:
Harrison, Paul. 2023. “langevitour: Smooth Interactive Touring ofHigh Dimensions, Demonstrated with scRNA-Seq Data.”The RJournal 15 (2): 206–219.https://doi.org/10.32614/RJ-2023-046.
Further material:
ABACBS Conference 2022poster(large image) anddemo
ABACBS Seminar 2022slides
useR! 2022 conferenceslides andvideo (extendededition)
IASC-ARS 2023slides andshort videoforVisualising high-dimensional genomics data: what Non-LinearDimension Reduction hides and misrepresents. Demonstrates someadvanced tricks setting the state of the widget using buttons in aQuarto presentation.
Release version:
install.packages("langevitour")Development version:
remotes::install_github("pfh/langevitour")To build the documentation site:
install.packages(c("devtools","pkgdown","BiocManager"))devtools::install_dev_deps()BiocManager::install(c("airway","org.Hs.eg.db","edgeR","limma"))pkgdown::build_site()Example:
library(langevitour)data(zeiselPC)langevitour(zeiselPC[,-1], zeiselPC$type)The minified and bundled version can be found ininst/htmlwidgets/lib/langevitour-pack.js.
If usingnode andnpmfor development, langevitour can be added with:
npm install langevitourThis provides the widget as a modern ESM module. In your HTML pageyou can import it with:
<script type="module">import { Langevitour } from "langevitour";// ...</script>You’ll need to use a packager such asparcel orwebpack to use this. Please tell meif you run into any problems, I am fairly new to Javascriptdevelopment.
To avoid using npm, you could useskypack.dev. You will still need toserve your page with some sort of web-server, such aspython3 -m http.server.
<script type="module">import { Langevitour } from "https://cdn.skypack.dev/langevitour";// ...</script>Here is anexample using skypack in an Observable Notebook.
langevitour is written in TypeScript, which is compiled to JavaScipt,and then Webpack is used to produce a minified and bundled version. Tomake changes to the JavaScript side of langevitour, you will need toinstallnode, which includes thenpm package manager.npm can then install thenecessary build tools and dependencies. Build scripts are defined inpackage.json and used as below.
git clone https://github.com/pfh/langevitour.gitcd langevitour# Install required packagesnpm install# ... edit source in src/ directory ...# Compile TypeScript modules in src/ to JavaScript modules in lib/.# Produce minified bundle inst/htmlwidgets/lib/langevitour.jsnpm run js-build# Complete Javascript+R build and documentation process.npm run buildFor example, to define a new guide you would:
ts/guides.ts.gradTable ints/guides.ts.guideSelect select box ints/langevitour.ts.npm run js-build and the new guide should appearwhen you loadexample.html.pip install langevitourimport numpyas npfrom langevitourimport Langevitour# Generate a sample datasetX= []group= []n=20000def r():return np.random.normal(0,0.02)for iinrange(n): a= i/n* np.pi*2 X.append([10+ np.sin(a)/3+ r(),20+ np.sin(a*2)/3+ r(),30+ np.sin(a*3)/3,40+ np.sin(a*4)/3,50+ np.sin(a*5)/3 ]) group.append(int(i*4/n))# Extra axes (specified as columns of a matrix)extra_axes= [[1], [2], [0], [0], [0]]extra_axes_names= ["V1+2*V2"]tour= Langevitour( X, group=group, extra_axes=extra_axes, extra_axes_names=extra_axes_names, point_size=1,)tour.write_html("langevitour_plot.html")langevitour also works injupyternotebooks.
The Javascript and R package are written by Paul Harrison. The Pythonpackage was kindly contributed by Wytamma Wirth.
Langevitour is free software made available under theMITlicense. Included librariesjStat andSVD-JS are alsoprovided under the MIT license. Included libraryD3 is provided under theISC license.