RPuGB (Raeumliche Perturbations- und Gewebesimulations-Bibliothek) is a scientific Python library for spatial perturbation analysis, causal bystander decoupling, and in silico tissue simulation in functional genomics. Staged as a software Resource for functional genomics, RPuGB decouples non-cell-autonomous microenvironmental bystander effects from cell-autonomous responses in spatial CRISPR screens, models spatiotemporal pharmacodynamics via anisotropic reaction-diffusion partial differential equations, synthesizes counterfactual tissue states with generative graph diffusion transformers, and programmatically audits execution against 51 binding European Union, Finnish national, and Nordic cross-border statutory instruments.
RPuGB is organized into fourteen specialized Lanthanide engines (Module 58 Cerium to Module 71 Lutetium). Each engine is mapped to the lanthanide element whose physical or optical properties parallel the computational phase it executes:
| Element | Engine Name | Subpackage | Functional Scope and Biophysical Analogy |
|---|---|---|---|
| 58 Ce | Cerium | rpugb.ce |
Optical barcode decoding, maximum likelihood guide assignment, and SpatialData Zarr synchronization. (Cerium is used in precision optical glass polishing). |
| 59 Pr | Praseodymium | rpugb.pr |
Spatial QC filtering, illumination depth normalization, serial slice alignment, and optical crosstalk deconvolution. (Praseodymium filters spectral light). |
| 60 Nd | Neodymium | rpugb.nd |
Spatial graph topologies (Delaunay, |
| 61 Pm | Promethium | rpugb.pm |
Robinson Double Machine Learning (DML), spatial propensity fitting, DAG causal discovery, and bystander field decoupling. (Promethium emits radiating energy). |
| 62 Sm | Samarium | rpugb.sm |
Spatially lagged ligand-receptor rewiring, paracrine gradient attenuation distance, and niche remodeling scoring. (Samarium captures neutrons in nuclear reactors). |
| 63 Eu | Europium | rpugb.eu |
Spatial response cartography, radial phenotypic profiles, causal effect distributions, and Nature Biotechnology vector exports. (Europium produces vivid red phosphorescence). |
| 64 Gd | Gadolinium | rpugb.gd |
Multichannel contrast enhancement, 3D volumetric tissue slicing, and interactive Napari polygon ROI selection. (Gadolinium provides contrast in medical imaging). |
| 65 Tb | Terbium | rpugb.tb |
Tissue interface gradient detection, tumor margin displacement velocity, and immune infiltration flux modeling. (Terbium detects magneto-acoustic structural phase shifts). |
| 66 Dy | Dysprosium | rpugb.dy |
Finite-volume reaction-diffusion PDEs, anisotropic permeability tensors, and spatial Hill equation dose-response. (Dysprosium maintains stability under extreme thermal gradients). |
| 67 Ho | Holmium | rpugb.ho |
Targeted in silico CRISPR knockouts, combinatorial disruption screens, and sequence guide efficiency calibration. (Holmium lasers execute microscopic surgical cuts). |
| 68 Er | Erbium | rpugb.er |
Spatial Graph Diffusion Transformers, Latent Spatial VAEs, counterfactual slice sampling, and Wasserstein-1 fidelity metrics. (Erbium amplifiers regenerate optical signals). |
| 69 Tm | Thulium | rpugb.tm |
Precision benchmarking against Mixscape, scMAGeCK, and Pertpy, calculating spatial SNR and causal recovery rates. (Thulium provides precise calibration standards). |
| 70 Yb | Ytterbium | rpugb.yb |
Custom PyTorch CUDA kernels, AMD ROCm LUMI supercomputer optimization, multi-GPU distributed tensors, and Slurm synthesis. (Ytterbium powers accurate atomic clocks). |
| 71 Lu | Lutetium | rpugb.lu |
In silico synthetic lethality prediction, theranostic window scoring ( |
RPuGB supports Linux x86_64, Linux aarch64, macOS Apple Silicon (ARM64), and Microsoft Windows under Python 3.10, 3.11, and 3.12.
pip install rpugb# GPU acceleration (PyTorch, PyG)
pip install rpugb[gpu]
# Interactive 3D visualization with Napari
pip install rpugb[viz]
# Spatial ecosystem and SpatialData bridge
pip install rpugb[spatial]
# Complete development and documentation suite
pip install rpugb[all]git clone https://github.com/olaflaitinen/rpugb.git
cd rpugb
pip install -e ".[all]"conda env create -f environment.yml
conda activate rpugbThe following minimal example demonstrates spatial graph construction, continuous distance decay kernel evaluation, and Robinson Double Machine Learning causal bystander decoupling on a synthetic annular perturbation field:
import anndata as ad
import numpy as np
import rpugb
import rpugb.nd as nd
import rpugb.pm as pm
from rpugb.utils.datasets import generate_synthetic_perturbation_field
# 1. Generate synthetic annular perturbation field (1,000 cells, 100 genes)
adata = generate_synthetic_perturbation_field(n_cells=1000, n_genes=100, seed=42)
# 2. Construct spatial Delaunay graph and compute continuous Gaussian distance decay weights
nd.build_spatial_graph(adata, method="delaunay")
nd.compute_niche_weights(adata, decay_function="gaussian", bandwidth=50.0)
# 3. Decouple cell-autonomous effects from radiating bystander influence fields
pm.decouple_bystander_effects(
adata,
target_col="perturbation_status",
control_label="non_targeting",
spatial_key="spatial",
n_folds=5,
)
# 4. Inspect decoupled effect matrices in AnnData
print("Autonomous Effect Matrix Shape:", adata.obsm["rpugb_autonomous_effect"].shape)
print("Bystander Effect Matrix Shape: ", adata.obsm["rpugb_bystander_effect"].shape)The complete end-to-end workflow from raw multiplexed image ingestion to combinatorial knockout modeling and Slurm batch submission is provided in examples/crispr_screen_end_to_end.py.
In accordance with Nature Portfolio reporting standards, all mathematical methods and statistical estimators implemented in RPuGB are formally derived below:
Promethium estimates unconfounded Average Treatment Effects (ATE) under localized spatial confounding by executing Robinson's semi-parametric transformation over cross-fitting folds
where
Neodymium quantifies spatial gene expression patterning and coordinate clustering via the global Moran's
where
Dysprosium models spatiotemporal drug diffusion, vascular clearance, and therapeutic consumption over irregular tissue meshes using non-linear finite-volume PDE integration:
where
where
Lutetium prioritizes therapeutic targets and combinatorial CRISPR disruptions by computing the in silico theranostic window index:
where
Samarium calculates the cell-specific intercellular communication potential for a ligand-receptor pair
The condition-level differential rewiring score between perturbed cells
Terbium tracks morphological boundary displacement velocities across histological compartments between consecutive time points
where
Erbium evaluates the biological distributional fidelity of generative counterfactual tissue states against observed ground-truth manifolds using the Wasserstein-1 distance and Maximum Mean Discrepancy (
where
RPuGB enforces automated nightly benchmarking via Thulium (rpugb.tm) against single-cell and spatial baselines:
- Comparative Accuracy: Demonstrates a minimum 35% improvement in True Positive Causal Gene Detection over non-spatial baseline frameworks (Mixscape, scMAGeCK linear modeling, Pertpy GLMs) under spatially autocorrelated noise.
- Computational Throughput:
- 10,000 cells: Sub-second graph construction and causal decomposition (< 0.8 seconds on standard GPU).
- 100,000 cells: Complete pipeline execution under 45 seconds using Ytterbium (Yb, Module 70) GPU acceleration.
- Memory Footprint: Strict peak VRAM ceiling of 4.2 GB during full counterfactual diffusion passes on 100,000-cell spatial graphs.
The rpugb.compliance subpackage programmatically audits and enforces 51 binding European Union regulations, Finnish national acts, and Nordic cross-border governance frameworks:
- European Union Acts: EU AI Act (Regulation (EU) 2024/1689), EuroHPC Joint Undertaking (Regulation (EU) 2021/1173), EuroHPC AI Factories Amendment (Regulation (EU) 2024/1732), Cyber Resilience Act (Regulation (EU) 2024/2847), GDPR (Regulation (EU) 2016/679), EHDS (Regulation (EU) 2025/327), EU Data Act (Regulation (EU) 2023/2854), Data Governance Act (Regulation (EU) 2022/868), SoHO Regulation (Regulation (EU) 2024/1938), Contained Use GMM Directive (Directive 2009/41/EC), Nagoya Protocol (Regulation (EU) No 511/2014), Biological Agents Directive (Directive 2000/54/EC), IVDR (Regulation (EU) 2017/746), MDR (Regulation (EU) 2017/745), CTR (Regulation (EU) No 536/2014), EMA Proposal (COM(2023) 193), Human Medicinal Products Proposal (COM(2023) 192), Animal Protection 3Rs Directive (Directive 2010/63/EU), DSM Copyright TDM Directive (Directive (EU) 2019/790), Biotech Patents Directive (Directive 98/44/EC), EU Dual-Use Export Controls (Regulation (EU) 2021/821), STEP Regulation (Regulation (EU) 2024/795), EU Biotech Communication (COM(2024) 137), Horizon Europe (Regulation (EU) 2021/695).
- Finnish National Legislation: Biopankkilaki (688/2012), Toisiolaki (552/2019), Geeniteknologialaki (377/1995), Tietosuojalaki (1050/2018), Kudoslaki (101/2001), Laki laakinnallisista laitteista (719/2021), Laki laaketieteellisesta tutkimuksesta (488/1999), Laki kliinisesta laaketutkimuksesta (983/2021), Laki tieteellisiin tarkoituksiin kaytettavien elainten suojelusta (497/2013), Asetus geenitekniikan suljetusta kaytosta (1053/2005), Tekijanoikeuslaki (404/1961 amended 1259/2022), Laki kaksikayttotuotteiden vientivalvonnasta (500/2024), Asiakastietolaki (703/2023), Tartuntatautilaki (1227/2016).
- Nordic Governance Frameworks: Helsinki Treaty (1962), Kalmar II Declaration (2023), Nordic Commons Vision 2030, Nordic Commons Policy Board Decision (AK-S 2021), Tryggve Sensitive Data Code of Conduct, Heilsa Tryggvedottir Collaboration Framework, Nordic Biotechnology Framework, NCBio Ethical Biobanking Guidelines, BBMRI-Nordic Infrastructure Framework, Nordic Ethical AI and Data Roadmap, NACG Clinical Genomics Consensus, LUMI Supercomputer Consortium Agreement, Norecopa Nordic 3Rs Platform.
All 51 instruments correspond one-to-one with physical statutory PDF documents stored in rpugb/compliance/statutes/. Verification is enforced at package import and during continuous integration:
from rpugb.compliance.statutes_registry import verify_statute_text_corpus
# Programmatic verification of the 51 statutory PDF instruments
is_compliant, audit_message = verify_statute_text_corpus()
print(audit_message)RPuGB provides native optimization for AMD Instinct MI250X GPUs on the LUMI supercomputer (CSC, Kajaani, Finland) via rpugb.yb.rocm_lumi_backend and automated Slurm batch synthesis:
from rpugb.yb.slurm_generator import generate_lumi_slurm_script
# Generate a validated Slurm submission script for LUMI-G AI Factory partition
script_path = generate_lumi_slurm_script(
job_name="rpugb_spatial_screen",
account="project_462000000",
partition="standard-g",
nodes=2,
gpus_per_node=8,
time_limit="04:00:00",
output_script="submit_lumi.sh",
)All demonstration datasets included in RPuGB for unit testing and tutorials are procedurally generated synthetic fixtures (tests/data/synthetic_xenium_sample.h5ad and tests/data/synthetic_merscope_sample.h5ad) created via rpugb.utils.datasets. No real, re-identifiable human donor data or patient health records are contained in version control. Tutorials referencing public benchmarks (10x Genomics Xenium breast cancer, Vizgen MERSCOPE mouse brain, NanoString CosMx lung) download raw data directly from vendor open-access portals at runtime.
The complete source code for RPuGB is permanently hosted at https://github.com/olaflaitinen/rpugb. Archived release snapshots receive persistent Digital Object Identifiers (DOI) through the Zenodo integration (10.5281/zenodo.rpugb). All software releases adhere to the Nature Biotechnology Software Submission Checklist located at docs/software_submission_checklist.rst.
The author declares no competing financial or non-financial interests.
Portions of the introductory tutorial narratives and documentation markup were drafted with the assistance of artificial intelligence tools, and were subsequently fact-checked, corrected, and approved for release by the Principal Investigator, consistent with Nature Portfolio policy on artificial intelligence.
- Principal Investigator and Lead Architect: Gustav Olaf Yunus Laitinen-Fredriksson Lundstrom-Imanov
- Researcher Identifier (ORCID iD): 0009-0006-5184-0810
- Academic Department: School of Information and Communication Technology
- Higher Education Institution: Metropolia University of Applied Sciences (Metropolia Ammattikorkeakoulu)
- Campus Facility: Karamalmi Campus, Karaportti 2, FI-02610 Espoo, Finland
- Direct Telephone: +358 (0)46 583 8095 | Switchboard: +358 9 7424 5000
- Official Institutional Email:
yunus.imanov@metropolia.fi - Software License: European Union Public Licence version 1.2 (EUPL-1.2)
- Chernozhukov, V. et al. Double/debiased machine learning for treatment and structural parameters. Econom. J. 21, C1-C68 (2018).
- Moffitt, J. R. et al. Molecular, spatial, and functional single-cell profiling of the hypothalamic preoptic region. Science 362, eaau5324 (2018).
- Janesick, A. et al. High-resolution mapping of the tumor microenvironment using spatial transcriptomics. Nat. Commun. 14, 2453 (2023).
- Dixit, A. et al. Perturb-Seq: Dissecting molecular circuits with scalable single-cell RNA profiling of pooled genetic screens. Cell 167, 1853-1866 (2016).
- Laitinen-Fredriksson Lundstrom-Imanov, G. O. Y. Spatial perturbation and tissue simulation library for functional genomics. Nat. Biotechnol. Under Review (2026).