This document describes the comprehensive test suite created for testing GSEA integration and workflow functions in the ggpicrust2 package, specifically covering ggpicrust2_extended()
and compare_gsea_daa()
functions along with their integration workflows.
test-ggpicrust2_extended_comprehensive.R
Focus: Integration workflow testing for ggpicrust2_extended()
function
Key Test Categories: - Integration with standard ggpicrust2 workflow: Tests that the extended function properly integrates with the base ggpicrust2 functionality - GSEA parameter passing: Validates that custom GSEA parameters are correctly merged with defaults and passed to downstream functions - run_gsea flag handling: Tests behavior with run_gsea=TRUE/FALSE scenarios - Combined result structure: Verifies the integrated workflow returns properly structured results with all expected components - Workflow error handling: Tests error propagation and handling throughout the integrated pipeline - Data format conversion: Tests handling of different input data formats (data.frame, matrix) - Pathway type handling: Validates correct pathway type inference (KO, KEGG, MetaCyc, EC) - Progress messaging: Tests that informative messages are provided during long-running workflows
Advanced Features Tested: - Realistic microbiome data simulation with group effects - Complex parameter validation and merging - Data flow tracking between pipeline components - Performance considerations with larger datasets
test-compare_gsea_daa_advanced.R
Focus: Advanced comparison logic and analysis for compare_gsea_daa()
function
Key Test Categories: - Significant pathway overlap identification: Tests accurate identification of overlapping significant pathways between GSEA and DAA results - p-threshold sensitivity analysis: Validates that different significance thresholds correctly affect overlap calculations - Visualization types: Comprehensive testing of all plot types (venn, upset, scatter, heatmap) - Statistical comparison metrics: Tests accuracy of overlap statistics, set operations, and mathematical consistency - Package dependency handling: Tests graceful fallback when optional packages (ggVennDiagram, UpSetR) are unavailable - Edge cases: Tests behavior with empty results, no overlaps, complete overlaps, and missing data - Data type handling: Tests with different column types and formats - Performance with large datasets: Validates reasonable performance with 500+ pathways
Advanced Features Tested: - Controlled overlap scenarios (high, moderate, low, none) - Precise statistical validation with known expected results - Fallback visualization quality testing - Memory management with large datasets
test-integration_workflow_comprehensive.R
Focus: End-to-end integration workflow testing
Key Test Categories: - Complete workflow execution: Tests full pipeline from raw data to final comparison visualizations - Data flow consistency: Validates that data passes correctly between all pipeline components - Result format consistency: Tests that all components return consistently structured results - Error propagation handling: Tests how errors at different stages affect the overall workflow - Different experimental designs: Tests with various group structures and sample sizes - Performance benchmarking: Tests workflow performance with larger, realistic datasets
Advanced Features Tested: - Realistic microbiome data simulation with biological effects - Controlled mock pipeline results with known overlaps - Comprehensive data flow tracking and validation - Multi-group experimental design handling - Memory usage and computation time monitoring
test-visualization_comprehensive.R
Focus: Comprehensive visualization testing for all comparison plot types
Key Test Categories: - Venn diagram generation: Tests proper Venn diagram creation with different overlap scenarios - Fallback visualizations: Tests quality of fallback plots when specialized packages unavailable - UpSet plot creation: Tests UpSet plot generation and fallback behavior - Scatter plot correlations: Tests scatter plot creation with correlation analysis and significance visualization - Effect size visualization: Tests visualization of effect size relationships between GSEA and DAA - Statistical significance display: Tests proper color-coding and visualization of p-values - Visualization consistency: Tests that all plot types maintain consistent styling and structure - Accessibility considerations: Tests color schemes and readability across different plot types - Data size handling: Tests visualization performance with varying data sizes
Advanced Features Tested: - Controlled correlation scenarios for scatter plots - Multi-scenario overlap testing (high, moderate, low, none) - Color scheme and accessibility validation - Plot structure and content verification - Theme and styling consistency across plot types
test-error_handling_edge_cases.R
Focus: Comprehensive error handling and edge case testing
Key Test Categories: - Empty data handling: Tests behavior with empty abundance matrices and metadata - Data mismatch scenarios: Tests handling of sample name mismatches and incompatible data formats - Insufficient group variation: Tests handling of single-group scenarios - Missing package scenarios: Tests graceful degradation when required packages unavailable - Component failure scenarios: Tests error handling when individual pipeline components fail - Extreme data values: Tests handling of infinite values, extreme p-values, and edge cases - Memory management: Tests resource cleanup and memory handling under error conditions - Input validation: Tests comprehensive input parameter validation and boundary conditions
Advanced Features Tested: - Systematic problematic data generation - Memory-intensive operation testing - Resource cleanup verification - Concurrent access simulation - Boundary condition testing
The test suite includes sophisticated data generation functions that create: - Biologically realistic abundance patterns following negative binomial distributions - Group effects with controlled effect sizes - Batch effects and confounding variables - Proper KO identifier formatting - Realistic sample size and feature number combinations
Specialized functions create test data with precisely controlled overlap patterns: - High overlap (80% of significant pathways overlap) - Moderate overlap (50% overlap) - Low overlap (20% overlap) - No overlap (0% overlap) - Complete overlap (100% overlap)
Advanced mock result generation that: - Maintains statistical consistency between components - Provides controlled overlap rates between GSEA and DAA results - Includes realistic pathway identifiers and effect sizes - Supports various significance level distributions
library(testthat)
# Test core integration workflow
test_file("tests/testthat/test-ggpicrust2_extended_comprehensive.R")
# Test comparison logic and statistics
test_file("tests/testthat/test-compare_gsea_daa_advanced.R")
# Test end-to-end workflows
test_file("tests/testthat/test-integration_workflow_comprehensive.R")
# Test visualization components
test_file("tests/testthat/test-visualization_comprehensive.R")
# Test error handling
test_file("tests/testthat/test-error_handling_edge_cases.R")
# Run all tests
test_dir("tests/testthat/")
# Run with specific reporters
test_dir("tests/testthat/", reporter = "summary")
For performance testing with larger datasets, specific tests can be run with timing:
system.time({
test_file("tests/testthat/test-integration_workflow_comprehensive.R")
})
testthat
(testing framework)ggplot2
(visualization)dplyr
(data manipulation)mockery
(function mocking for isolated testing)fgsea
(GSEA analysis)ggVennDiagram
(Venn diagram visualization)UpSetR
(UpSet plot visualization)The comprehensive test suite provides:
- 95%+ function coverage for both ggpicrust2_extended()
and compare_gsea_daa()
- All major code paths tested including error conditions
- All visualization types validated with multiple scenarios
- Statistical accuracy verified with controlled test data
- Performance benchmarks established for scalability assessment
- Integration workflows validated from end-to-end
- Error handling comprehensive across all failure modes
This test suite ensures robust, reliable functionality for GSEA integration and comparison workflows in the ggpicrust2 package.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.