Medical stat tool
2.6K
Important
**๐ค FOR AI AGENTS & BOTS (Antigravity, Cursor, etc.)**:
- Architecture First: ALWAYS Read docs/ARCHITECTURE.mdโ to understand the Styling System and Data Processing Pipeline before editing.
- Environment: This project requires Python 3.12+. Versions < 3.12 will cause SyntaxErrors due to the use of PEP 695 (Type Parameter Syntax/Type Aliases).
- Context: See docs/deep-ai-bot-optimization.mdโ for detailed implementation rules.
Requirement Version Python โฅ 3.12 Environment .venv
Available StatioMed:
๐ HuggingFace Spaceโ
๐ Posit Cloudโ
[--- REPOSITORY-TREE-START ---]
๐ Repository Contents (File Structure)
This content reflects the repository structure (updated by GitHub Actions):
|-- AI_CONTEXT.md
|-- ARCHITECTURE.md
|-- DESIGN.md
|-- Dockerfile
|-- app.py
|-- asgi.py
|-- config.py
|-- docker-compose.yml
|-- docs /
| |-- .DS_Store
| `-- assets /
| |-- .DS_Store
| `-- navigation_sequence.png
|-- logger.py
|-- pyproject.toml
|-- pytest.ini
|-- python_results /
| |-- benchmark_firth_cox.csv
| |-- benchmark_firth_logistic.csv
| |-- dataset_breast.csv
| `-- dataset_sex2.csv
|-- requirements-causal.txt
|-- requirements-prod.txt
|-- requirements.txt
|-- static /
| |-- js /
| | `-- custom_handlers.js
| |-- styles.css
| `-- styles.min.css
|-- tabs /
| |-- __init__.py
| |-- _common.py
| |-- _dataset_mixin.py
| |-- _styling.py
| |-- _tvc_components.py
| |-- tab_advanced_inference.py
| |-- tab_advanced_stats.py
| |-- tab_agreement.py
| |-- tab_baseline_matching.py
| |-- tab_causal_inference.py
| |-- tab_core_regression.py
| |-- tab_corr.py
| |-- tab_data.py
| |-- tab_diag.py
| |-- tab_home.py
| |-- tab_meta_analysis.py
| |-- tab_sample_size.py
| |-- tab_settings.py
| `-- tab_survival.py
|-- tests /
| |-- benchmarks /
| | |-- python_results /
| | | |-- benchmark_firth_cox.csv
| | | |-- benchmark_firth_logistic.csv
| | | |-- dataset_breast.csv
| | | `-- dataset_sex2.csv
| | `-- r_scripts /
| | `-- test_firth.R
| |-- conftest.py
| |-- e2e /
| | |-- test_app_flow.py
| | |-- test_load_example_data.py
| | `-- test_smart_defaults.py
| |-- integration /
| | |-- test_advanced_features.py
| | |-- test_corr_cleaning.py
| | |-- test_corr_pipeline.py
| | |-- test_data_cleaning_pipeline.py
| | |-- test_diag_cleaning.py
| | |-- test_diag_pipeline.py
| | |-- test_forest_plot_lib.py
| | |-- test_interaction_pipeline.py
| | |-- test_logic_pipeline.py
| | |-- test_poisson_cleaning.py
| | |-- test_poisson_pipeline.py
| | |-- test_psm_pipeline.py
| | |-- test_robustness_check.py
| | |-- test_subgroup_pipeline.py
| | |-- test_survival_cleaning.py
| | |-- test_survival_landmark.py
| | |-- test_survival_pipeline.py
| | `-- test_table_one_pipeline.py
| `-- unit /
| |-- output /
| | `-- test_output_2.html
| |-- test_advanced_stats.py
| |-- test_bland_altman.py
| |-- test_calibration_ici.py
| |-- test_causal.py
| |-- test_chi_html.py
| |-- test_collinearity.py
| |-- test_color_palette.py
| |-- test_correlation_returns.py
| |-- test_data_cleaning.py
| |-- test_data_cleaning_advanced.py
| |-- test_data_cleaning_workflow.py
| |-- test_data_quality.py
| |-- test_data_quality_report.py
| |-- test_dca.py
| |-- test_diag_returns.py
| |-- test_diagnostic_advanced.py
| |-- test_download_helpers.py
| |-- test_effect_sizes.py
| |-- test_fagan_nomogram.py
| |-- test_firth_regression.py
| |-- test_formatting.py
| |-- test_formatting_styles.py
| |-- test_glm.py
| |-- test_heterogeneity.py
| |-- test_linear_lib.py
| |-- test_mediation.py
| |-- test_medical_edge_cases.py
| |-- test_meta_analysis.py
| |-- test_mi_reporting.py
| |-- test_missing_data.py
| |-- test_model_diagnostics.py
| |-- test_model_diagnostics_plots.py
| |-- test_multiple_imputation.py
| |-- test_pdf_helpers.py
| |-- test_phase3_features.py
| |-- test_plotly_html_rendering.py
| |-- test_poisson_lib.py
| |-- test_regression_publication.py
| |-- test_repeated_measures.py
| |-- test_reporting_checklists.py
| |-- test_sample_size.py
| |-- test_sensitivity.py
| |-- test_sensitivity_fixes.py
| |-- test_statistical_assumptions.py
| |-- test_statistics.py
| |-- test_survival_assumptions.py
| |-- test_survival_lib_patch.py
| |-- test_tab_diag_html_logic.py
| |-- test_tvc_lib.py
| |-- test_ui_ux_styles.py
| `-- verify_table_one.py
|-- utils /
| |-- .DS_Store
| |-- __init__.py
| |-- advanced_stats_lib.py
| |-- agreement_lib.py
| |-- calibration_lib.py
| |-- collinearity_lib.py
| |-- correlation.py
| |-- data_cleaning.py
| |-- data_quality.py
| |-- decision_curve_lib.py
| |-- diag_test.py
| |-- diagnostic_advanced_lib.py
| |-- download_helpers.py
| |-- effect_sizes.py
| |-- fagan_nomogram_lib.py
| |-- forest_plot_lib.py
| |-- formatting.py
| |-- heterogeneity_lib.py
| |-- interaction_lib.py
| |-- linear_lib.py
| |-- logic.py
| |-- mediation_lib.py
| |-- meta_analysis_lib.py
| |-- mi_helpers.py
| |-- model_diagnostics_lib.py
| |-- multiple_imputation.py
| |-- pdf_helpers.py
| |-- plotly_html_renderer.py
| |-- poisson_lib.py
| |-- psm_lib.py
| |-- rcs_lib.py
| |-- repeated_measures_lib.py
| |-- reporting_checklists.py
| |-- sample_size_lib.py
| |-- sensitivity_lib.py
| |-- statistical_assumptions.py
| |-- stratified_lib.py
| |-- subgroup_analysis_module.py
| |-- survival_lib.py
| |-- table_one.py
| |-- table_one_advanced.py
| |-- tvc_lib.py
| |-- ui_helpers.py
| |-- update_css.py
| `-- visualizations.py
`-- uv.lock
[--- REPOSITORY-TREE-END ---]
A comprehensive, interactive web application for medical statistical analysis, built with Shiny for Pythonโ . This tool simplifies the process of data management, cohort matching, and advanced statistical modeling for medical researchers.
This application is a complete statistical workbench organized into modular tabs:
utils/data_quality.py for:
"<5", ">10", or currency.The application is built with a modular architecture that separates styling, data processing, and statistical logic to ensure scalability and consistency.
The application uses a centralized styling system to ensure visual consistency across all modules.
| File | Role | Description |
|---|---|---|
tabs/_common.py | Source of Truth | Defines the central get_color_palette() and common UI constants. |
tabs/_styling.py | CSS Generator | Main injector that generates CSS using the palette from _common.py. |
static/styles.css | Compiled CSS | Auto-generated output from _styling.py. Used for performance and deployment. |
utils/update_css.py | Sync Utility | Script to update static/styles.css whenever _styling.py changes. |
static/js/custom_handlers.js | JS Hooks | Shiny custom message handlers for dynamic client-side styling. |
Visual Consistency & Formatting:
utils/plotly_html_renderer.py and forest_plot_lib.py sync interactive charts with the central palette and "Inter" typography.utils/formatting.py standardizes P-value styling and badge generation across all statistical outputs.Every statistical analysis follows a rigorous, standardized data flow to ensure reliable results:
tab_data.py): Immediate identification of missingness and data types upon upload or example loading.utils/data_cleaning.py): Before analysis, data is passed through prepare_data_for_analysis() which handles exclusion logic and logging.utils/download_helpers.py & utils/pdf_helpers.py): All @render.download handlers use safe_download_html() / safe_report_generation() for HTML, or safe_download_pdf() / safe_pdf_report_generation() for PDF output. Both layers guarantee valid output (or a styled error page) and show user-facing notifications (โ
success, โ ๏ธ no results, โ generation error). PDF conversion uses Playwright (requires playwright install chromium).utils/formatting.py): Missing data statistics are automatically analyzed and included in the final report for every module._common.py match branding.tests/unit/test_ui_ux_styles.py.Ensure you have Python 3.12+ installed (required for PEP 695 type parameter syntax).
Clone the repository:
git clone https://huggingface.co/spaces/ntwkkm/shinystat
cd shinystat
Install dependencies: It is recommended to use a virtual environment.
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
Run the app:
shiny run app.py --port 7860
The app will be available at http://localhost:7860.
To run the test suite, ensure you use the pytest from your virtual environment (assuming venv is named .venv):
# Run all tests
.venv/bin/pytest
# Or if using a different venv name/activation:
# python -m pytest
# Run specific test
.venv/bin/pytest tests/unit/test_statistics.py
This project is containerized for easy deployment and local development. An automated image is published to Docker Hub on every update to the main branch.
Pull and run from Docker Hub (Easiest):
docker run -p 7860:7860 ntwkkm/statiomed:latest
Local Development with Docker Compose (Live Reload): This method mounts your local code into the container, allowing for real-time updates as you edit files.
docker compose up --build
Standard Local Build:
# Build the image
docker build -t medical-stat-tool .
# Run the container
docker run -p 7860:7860 medical-stat-tool
Access the app at http://localhost:7860.
If you use VS Code, you can open the project in a pre-configured Dev Containerโ :
Ctrl+Shift+P / Cmd+Shift+P) and search for Dev Containers: Reopen in Container.This application is designed for enterprise and restricted environments:
requirements-prod.txt) vs Development (requirements.txt).This project is intended for educational and research purposes. Please ensure data privacy compliance when using with patient data.
Content type
Image
Digest
sha256:1161bb613โฆ
Size
937.2 MB
Last updated
about 1 month ago
docker pull ntwkkm/statiomed