Implements the comprehensive server-side logic for the NLDR visualization tool. This function handles all reactive computations, data processing, visualization generation, and user interactions for the multi-tab NLDR analysis application.
nldr_viz_server(input, output, session)Invisible NULL. The function sets up reactive expressions and observers that handle all server-side logic. The actual outputs are managed through the shiny reactive system and sent to the client via the output object.
The shiny input object containing all user interface inputs. This includes form controls, button clicks, plot selections, and file uploads.
The shiny output object for sending rendered content to the UI. Used for plots, tables, text outputs, and dynamic UI elements.
The shiny session object for managing client-server communication. Provides access to session state, input updates, and client information.
The server maintains several key reactive values:
dataset: Current active dataset
vis_results: NLDR computation results
shared_vis_data: Crosstalk-enabled data for linked brushing
nldr_datasets: Storage for multiple NLDR results
optimal_config: Best binwidth configuration from optimization
quollr_results: Quality assessment results
color_palette: Current color scheme for visualizations
is_running_*: Boolean flags for operation status tracking
Comprehensive error handling includes:
File upload validation with user-friendly error messages
NLDR computation error catching with fallback options
Memory management for large datasets
Network timeout handling for async operations
Graceful degradation when optional features are unavailable
Asynchronous computations prevent UI blocking
Efficient data structures for large datasets
Caching of expensive computations
Memory cleanup and garbage collection
Optimized reactive dependency management
GSoC Contributor
The server function manages several key areas of functionality:
Data Management:
File upload validation and CSV parsing with error handling
Built-in dataset loading (four_clusters, pdfsense)
Empty cell detection and data quality validation
Column selection and filtering capabilities
Dynamic dataset storage and retrieval system
NLDR Computations:
t-SNE implementation with parameter validation and auto-adjustment
UMAP processing with neighbor and distance parameter controls
Asynchronous computation using future package for responsiveness
Progress tracking and user feedback during long computations
Result caching and session management
Interactive Visualizations:
Plotly-based interactive scatter plots with zoom, pan, and selection
Color mapping with automatic palette generation
Linked brushing across multiple visualizations
Responsive plot sizing and layout management
Hover tooltips and selection feedback
Dynamic Tours:
Integration with detourr package for animated projections
Multiple display types: Scatter, Sage, and Slice projections
5-nearest neighbor graph construction and visualization
Real-time parameter adjustment and tour customization
Coordinated views between static and dynamic visualizations
Quality Assessment (Quollr Integration):
Automated binwidth optimization using RMSE minimization
Hexagonal binning and centroid extraction
High-dimensional model fitting and validation
Prediction error analysis and visualization
3D model tours using langevitour integration
Method Comparison:
Side-by-side visualization comparison with linked brushing
RMSE-based parameter optimization comparison
Best configuration identification and reporting
Interactive comparison plot generation
State Management:
Reactive value system for maintaining application state
Session-based data persistence and cleanup
Asynchronous operation tracking and user feedback
Memory management for large datasets
Parallel Processing: The server automatically configures parallel processing:
Uses multicore on supported systems, multisession otherwise
Configures 2 worker processes for optimal performance
Proper cleanup on session end to prevent memory leaks
Future-based asynchronous computation for UI responsiveness
nldr_viz_ui for the corresponding user interface
run_nldr_viz for launching the complete application
load_custom_datasets for data loading utilities
shinyServer for shiny server function details
plan for parallel processing configuration