A comprehensive Shiny application for analyzing behavioral data from nitroglycerin (NTG) studies, featuring advanced preprocessing, machine learning, and statistical analysis capabilities. This application is designed for researchers studying the effects of different NTG doses on mouse behavioral patterns.
NitroglycerinDataAnalysisApp_v0.1/
βββ π data/ # Data files
β βββ NTG_final_curated_nextflow_dataset.csv # Main NTG dataset
β βββ RettApp_ControlData.csv # Control data for testing
β βββ RettApp_ComprehensiveTestData.csv # Generated test data
βββ π docs/ # Documentation
β βββ README.md # This file
β βββ COMPLETE_TESTING_DOCUMENTATION.md # Comprehensive testing guide
β βββ Software Requirements Specification.md
β βββ To Do list.md
βββ π§ͺ tests/ # Comprehensive testing framework
β βββ data_generation/ # Test data creation scripts
β β βββ create_comprehensive_test_data_DOCUMENTED.R
β β βββ create_comprehensive_test_data.R
β β βββ create_test_data.py
β βββ unit/ # Unit tests
β β βββ run_simple_tests_DOCUMENTED.R
β β βββ run_detailed_tests_DOCUMENTED.R
β β βββ setup_continuous_testing_DOCUMENTED.R
β βββ integration/ # Integration tests
β β βββ test-server.R
β β βββ test-preprocessing.R
β β βββ test-lda-sanity.R
β β βββ test-server-edge-cases.R
β β βββ test-integration.R
β βββ testthat.R # Test runner
βββ ποΈ Archive/ # Archived/old files
β βββ IntermediateCode/ # Previous versions
β βββ NextflowViewer_v0.3.R
βββ π¨ www/ # Static assets
β βββ app_icon.png
β βββ 3dmouse.png
βββ π± server_tabs/ # Modular server components
β βββ tab_data_exploration_server.R
β βββ tab_lda_server.R
β βββ tab_pca_server.R
β βββ tab_ml_server.R
β βββ tab_correlation_server.R
β βββ tab_summary_server.R
βββ π ui.R # User interface
βββ βοΈ server.R # Main server logic
βββ π§ global.R # Global configuration
βββ π LICENSE # License file
βββ π VisualizeTestChamber.R # Test chamber visualization
βββ π LL test location.pdf # Test location documentation
βββ π LLUnit.pdf # Unit documentation
- R (version 4.0 or higher)
- Required R packages (automatically installed by the app)
# Load the Shiny app
shinyApp(ui = ui, server = server)
The application follows a structured workflow across 5 tabs:
- Load Data: Upload your CSV file and select feature columns
- Select Subsets: Choose treatment doses (Tx) and timepoints to analyze
- Preprocessing Options:
- Remove features with zero variance
- Choose outlier detection method (None, IQR, Z-score)
- Decide on outlier action (flag or remove)
- Select data transformation (None, Log, Square Root, Box-Cox)
- Run Preprocessing: Click "Run Preprocessing" to apply changes
- Review Results: Check preprocessing log and visualization plots
- Explore feature correlations with interactive heatmaps
- Create two-feature scatter plots with customizable faceting
- Download correlation plots as PDF
- View animal count summaries by treatment and timepoint
- Access data overview statistics
- Perform PCA on preprocessed features for each timepoint
- Choose feature selection method (variance explained or number of components)
- Generate scree plots, PC scatter plots, and loadings plots
- Download PCA results as PDF
- Use PCs from PCA tab to discriminate between treatment doses
- Automatically uses PCs accounting for 95% variance
- Generate 1D/2D scatter plots, univariate plots, and accuracy comparisons
- Cross-validation with configurable folds
- Download LDA results as PDF
# Generate comprehensive test data
source("tests/data_generation/create_comprehensive_test_data_DOCUMENTED.R")
# Run the app and upload: data/RettApp_ComprehensiveTestData.csv
# Or use the main NTG dataset: data/NTG_final_curated_nextflow_dataset.csv
# Run basic functionality tests
source("tests/unit/run_simple_tests_DOCUMENTED.R")
# Run comprehensive tests
source("tests/unit/run_detailed_tests_DOCUMENTED.R")
# Set up automatic testing (monitors files for changes)
source("tests/unit/setup_continuous_testing_DOCUMENTED.R")
-
Data Exploration & Preprocessing
- Comprehensive workflow instructions and guidance
- Intelligent column name fuzzy matching for data compatibility
- Zero-variance feature removal
- Outlier detection and handling (IQR, Z-score methods)
- Data transformation options (Log, Square Root, Box-Cox)
- Interactive feature visualization with EDA plots
- Preprocessing log and summary reporting
-
Correlation Analysis
- Interactive correlation heatmaps with automatic clustering
- Two-feature scatter plots with customizable faceting
- Color and shape customization by treatment or timepoint
- PDF export capabilities for all plots
-
Data Summary
- Animal count tables by dose and timepoint
- Data quality metrics and preprocessing summaries
- Export capabilities for results and tables
-
Principal Component Analysis (PCA)
- Flexible feature selection (variance explained or number of components)
- Scree plots with variance explained for each timepoint
- 2D PCA scatter plots with dose-level coloring
- Component loading analysis with top feature identification
- PDF export for all PCA visualizations
-
Linear Discriminant Analysis (LDA)
- Automatic use of PCs accounting for 95% variance from PCA
- 1D jittered plots for 2-dose groups, 2D scatter plots for 3+ groups
- Univariate density and box plots by treatment
- Cross-validation with configurable folds (3-10)
- Comprehensive accuracy metrics with chance comparisons
- Confidence intervals and model reliability assessment
- PDF export for all LDA visualizations
- NTG dose level definitions (0, 2.5, 5, 10 mg/kg)
- Correlation cutoff thresholds (0.90)
- Package management and conflict resolution
- Robust data preparation functions
- MouseID: Mouse identifier column
- Timepoint: Timepoint column (e.g., Day 1, Day 2, etc.)
- Tx: Treatment column (NTG dose levels: 0, 2.5, 5, 10)
- Numeric features: Behavioral measurements
- Optional metadata: Sex, Pen_ID, Cohort, DOB, Date, etc.
- CSV files with flexible column naming (fuzzy matching enabled)
- Automatic detection of feature vs. metadata columns
- Support for various timepoint and dose level formats
- Complete Testing Guide:
docs/COMPLETE_TESTING_DOCUMENTATION.md
- Comprehensive testing framework documentation - Software Requirements:
docs/Software Requirements Specification.md
- Detailed technical specifications - To Do List:
docs/To Do list.md
- Project development roadmap - Prompt Documentation:
docs/Promopt.md
- Development guidelines and specifications
- Package Installation: The app automatically installs required packages
- Data Format: Ensure CSV files have correct column names (fuzzy matching helps with variations)
- File Paths: Use relative paths from project root
- Column Selection: Make sure to select appropriate feature column ranges
- Memory Issues: For large datasets, consider filtering by timepoint first
- Check the comprehensive testing documentation
- Run the test scripts to identify issues
- Review console output for error messages
- Use the built-in fuzzy matching for column name issues
- Check the troubleshooting section in the testing documentation
See LICENSE
file for details.
- Follow the existing code structure
- Add tests for new features
- Update documentation
- Use the testing framework to validate changes
Note: This app is designed for behavioral data analysis in nitroglycerin (NTG) research studies. The application supports analysis of different NTG dose levels (0, 2.5, 5, 10 mg/kg) and their effects on mouse behavioral patterns. Ensure you have appropriate data and follow ethical guidelines for animal research.