The site is undergoing significant updates in preparation for the start of the Spring semester (end of Jan).
Major update: You can now carry out all course work directly in your browser without downloading any software! Click on webR in the main menu to get started. Course videos will be updated soon.
Sign in to track your progress and access the AI assistant.
OR
High-Performance Graphics & Visualization Pipeline in WebR
# High-Performance Graphics & Visualization Pipeline in WebR
This document outlines the technical architecture, GPU acceleration strategies, and memory optimization mechanisms used in the **DIY Transcriptomics** WebR workspace for rendering large, complex, and high-dimensional scientific visualizations.
---
## 1. The Challenge of High-Dimensional Genomic Visualizations
In RNA-seq data analysis, standard visualizations frequently operate on tens of thousands of data points simultaneously:
* **Volcano Plots:** Plotting $\log_2(\text{Fold Change})$ vs. $-\log_{10}(\text{FDR})$ for 15,000 to 50,000 genes.
* **PCA / MDS Plots:** Projecting multi-sample variance across multiple coordinate dimensions.
* **Genomic DataTables:** Interactive browsing of large expression matrices and differential hit lists.
### Traditional Desktop Bottleneck (RStudio / Desktop R)
When rendering interactive widgets like `ggplotly()` or `DT::datatable()` on a desktop machine:
1. R serializes the data into heavy standalone HTML/JS files.
2. The file is written to a temporary folder on the local hard drive (`tempdir()`).
3. An internal background web server (`httpuv`) hosts the file on `http://localhost:`.
4. RStudio's internal desktop browser (QtWebEngine / Electron) makes HTTP requests over localhost, reads the assets from disk, parses the dependencies, and renders standard SVG vector elements on the CPU.
When dealing with 15,000–40,000 genes, this architecture causes significant latency, CPU-bound DOM hit-testing, and frequent stutter or freezing during hover interactions.
---
## 2. The Three-Tier WebR Rendering Architecture
The DIY Transcriptomics webR workspace bypasses local disk writes and server overhead entirely by running a **direct in-memory WebAssembly-to-DOM graphics pipeline**:
```
┌────────────────────────────────────────────────────────┐
│ R Code Execution in WebAssembly │
└───────────────────────────┬────────────────────────────┘
│
┌────────────────┼────────────────┐
▼ ▼ ▼
[ Static Graphics ] [ Plotly HTML ] [ DataTables / gt ]
ggplot2 / Base R ggplotly(vplot) DT::datatable(df)
│ │ │
▼ ▼ ▼
HTML5