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.
Arguments
- input
The shiny input object containing all user interface inputs. This includes form controls, button clicks, plot selections, and file uploads.
- output
The shiny output object for sending rendered content to the UI. Used for plots, tables, text outputs, and dynamic UI elements.
- session
The shiny session object for managing client-server communication. Provides access to session state, input updates, and client information.
Value
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.
Details
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
Note
This function requires several packages to be available:
Core: shiny, magrittr
Visualization: plotly, ggplot2, DT, scales
NLDR: Rtsne, umap, FNN
Quality: quollr (with all its dependencies)
Tours: detourr, tourr
Data: dplyr, crosstalk
Async: future
Utils: stats, utils, tools
Reactive Values
The server maintains several key reactive values:
dataset
: Current active datasetvis_results
: NLDR computation resultsshared_vis_data
: Crosstalk-enabled data for linked brushingnldr_datasets
: Storage for multiple NLDR resultsoptimal_config
: Best binwidth configuration from optimizationquollr_results
: Quality assessment resultscolor_palette
: Current color scheme for visualizationsis_running_*
: Boolean flags for operation status tracking
Error Handling
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
Performance Considerations
Asynchronous computations prevent UI blocking
Efficient data structures for large datasets
Caching of expensive computations
Memory cleanup and garbage collection
Optimized reactive dependency management
See also
nldr_viz_ui
for the corresponding user interfacerun_nldr_viz
for launching the complete applicationload_custom_datasets
for data loading utilitiesshinyServer
for shiny server function detailsplan
for parallel processing configuration