| """ | |
| Runtime test: verify the rpy2-limma bridge is functional. | |
| Run this in the Space terminal or locally after installing R and rpy2: | |
| python scripts/check_limma_runtime.py | |
| Expected output: | |
| R version: R version 4.x.x (...) | |
| limma version: x.x.x | |
| rpy2-limma bridge OK | |
| """ | |
| import sys | |
| try: | |
| import rpy2.robjects as ro | |
| except ImportError: | |
| print("FAIL: rpy2 is not installed. Add 'rpy2' to requirements.txt.", file=sys.stderr) | |
| sys.exit(1) | |
| try: | |
| ro.r("suppressPackageStartupMessages(library(limma))") | |
| except Exception as exc: | |
| print(f"FAIL: could not load limma in R: {exc}", file=sys.stderr) | |
| print("Run scripts/install_r_packages.R via Rscript to install limma.", file=sys.stderr) | |
| sys.exit(1) | |
| print("R version:", ro.r("R.version.string")[0]) | |
| print("limma version:", ro.r("as.character(packageVersion('limma'))")[0]) | |
| print("rpy2-limma bridge OK") | |