A real-time interactive web-based simulation of cardiac fibroblast extracellular matrix (ECM) signaling pathways using WebAssembly and ODE-based modeling.
This simulation models complex signaling networks in cardiac fibroblasts, including:
- Real-time ODE solver: Interactive web-page solves more than 1 million equations simultaneously in real-time.
- Intracellular signaling cascades: More than 125 molecules including receptors, kinases, transcription factors).
- ECM production and regulation: 17 molecules including collagens, MMPs, TIMPs.
- Feedback mechanisms: Between cells (4 key signaling feedback molecules).
- Spatial diffusion: Diffusion of molecules across a 100×100 cellular grid.
- Brush-based cell selection: for localized input stimulation.
- Real-time visualization: with heatmaps and concentration tracking.
- Select specific regions of cells using an adjustable brush
- Apply different input concentrations to selected cells only
- Continuous feeding of input values throughout simulation
- Visual feedback with overlay highlighting
- Euler integration with adjustable time steps (0.01-0.5)
- Configurable rate constants for all pathway parameters
- Diffusion modeling for ECM and feedback molecules
- Per-cell concentration tracking and modification
- Main heatmap (500×500px) showing full 100×100 grid
- Select up to 8 cells directly on the main heatmap for detailed tracking
- Real-time line plots of concentration changes over time
- Color-coded gradients (red-yellow for ECM, blue for feedback)
- Figure export in PNG and SVG formats
ecm_simulation/
├── ecm.cpp # C++ simulation engine with ODE system
├── ecm_visualizer.js # JavaScript UI and visualization
├── index.html # Web interface
├── compile.sh # Emscripten compilation script
├── server.sh # Local development server
├── ecm.js # Generated WebAssembly wrapper (after compilation)
├── ecm.wasm # Compiled WebAssembly binary (after compilation)
└── README.md # This file
- Emscripten SDK (emsdk) - for compiling C++ to WebAssembly
- Python 3 - for local web server
- Modern web browser - with WebAssembly support (Chrome, Firefox, Safari, Edge)
- 4GB+ RAM (for handling 10,000 cell simulation)
- Multi-core CPU recommended for smooth real-time performance
# Clone and setup emsdk
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
cd ..# Clone this repository
git clone https://github.com/SysMechBioLab/ECMSim
cd ecm_simulation
# Make scripts executable
chmod +x compile.sh server.sh# Activate Emscripten environment
source ./emsdk/emsdk_env.sh
# Compile C++ to WebAssembly
./compile.shExpected output: ecm.js and ecm.wasm files will be generated.
# Start local web server
./server.shOpen browser and navigate to: http://localhost:8000
-
Molecule Selection: Choose from dropdown menu
- ECM molecules (collagen, fibronectin, MMPs, etc.)
- Feedback molecules (TGFβ, AngII, IL-6, ET-1)
-
Simulation Controls:
- Start: Begin continuous simulation
- Stop: Pause the simulation
- Step: Execute single simulation step
- Reset: Clear all data and restart
- Click "Enable Brush Mode"
- Adjust brush size (1-15 cells radius)
- Click and drag on main heatmap to select cells
- Set input concentrations using sliders
- Selected cells will continuously receive specified inputs
- Click directly on the main heatmap to select up to 8 cells for detailed tracking
- View real-time concentration plots for all selected cells
- Manually edit individual cell concentrations for any selected cell
- Monitor spatial and temporal dynamics
- Click the export button to save the current heatmap visualization
- Supported formats: PNG and SVG
- Useful for publications and presentations
- Click "Show ODE Parameters" to access:
- Time step control (0.01-0.5)
- Rate constants for all pathway components
- Input, feedback, degradation, and diffusion rates
The following three minimal worked examples demonstrate common use cases and help new users engage with the platform.
This workflow demonstrates how localized TGF-β stimulation drives collagen accumulation.
- Open ECMSim in your browser (
http://localhost:8000). - From the molecule dropdown, select proCI_ecm (procollagen type I) to visualize collagen in the main heatmap.
- Click "Enable Brush Mode" and adjust the brush size to ~5 cells.
- Click and drag on the main heatmap to select a rectangular region of cells. The selected region will be highlighted.
- In the input concentration panel, set TGF-β = 1.0 using the slider. Leave all other inputs at 0.
- Click "Start" to begin the simulation.
- Observe the main heatmap: over approximately 100-300 iterations, the selected (brushed) region will show increasing yellow color (higher procollagen I concentration), while the surrounding area remains dark.
- After ~500 iterations, notice how feedback molecule diffusion causes a concentration gradient extending beyond the initially stimulated region, demonstrating paracrine signaling.
- Click "Stop" to pause at any time and inspect the spatial pattern.
Expected outcome: Collagen I accumulates in and around the stimulated region, with a diffusion gradient spreading outward.
This workflow compares single vs. multi-factor stimulation and demonstrates cell tracking.
- Click "Reset" to start fresh.
- Select proCI_ecm from the molecule dropdown.
- Enable Brush Mode with brush size ~8.
- Draw an X-shaped pattern on the heatmap by clicking and dragging.
- Set TGF-β = 1.0, AngII = 1.0, IL6 = 1.0, and IL1 = 1.0. Leave other inputs at 0.
- Click directly on the main heatmap on a cell inside the X region to select it as Cell 1 (marked with a colored indicator).
- Click on a cell outside the X region to select it as Cell 2. You can select up to 8 cells for simultaneous tracking.
- Click "Start" and observe:
- The main heatmap shows enhanced collagen accumulation in the X region compared to Workflow 1 (single TGF-β), reflecting synergistic pathway crosstalk.
- The real-time line plots show Cell 1 (stimulated) rapidly increasing in proCI concentration, while Cell 2 (unstimulated) shows a delayed, smaller increase due to diffusing feedback molecules.
- Try switching the molecule dropdown to proMMP9_ecm (MMP-9) to observe the MMP response in the same spatial pattern.
Expected outcome: Multi-factor stimulation produces stronger and faster ECM accumulation than TGF-β alone. The line plots reveal distinct temporal dynamics between stimulated and unstimulated cells.
This workflow demonstrates how rate constant changes affect fibrotic outcomes in real time.
- Click "Reset" and set up a simple stimulation: enable Brush Mode, select a small square region, and set TGF-β = 1.0.
- Select proCI_ecm and click "Start". Let the simulation run for ~200 iterations to establish a baseline pattern, then click "Stop".
- Click "Show ODE Parameters" to open the parameter panel.
- Experiment A (degradation rate): Increase
k_degradationfrom 0.1 to 0.3 using the slider. Click "Start" again and observe: higher degradation reduces collagen accumulation and narrows the spatial spread. - Click "Stop", then reset
k_degradationback to 0.1. - Experiment B (production rate): Increase
k_productionfrom 0.01 to 0.03. Click "Start" and observe: higher production rate substantially increases collagen levels, consistent with the sensitivity analysis showingk_productionas the most influential parameter. - Experiment C (feedback sensitivity): Reset
k_productionto 0.01, then increasek_feedbackfrom 0.5 to 1.5. Observe how enhanced feedback amplifies the paracrine signaling, extending the spatial spread of the fibrotic response. - Try adjusting the time step (dt) slider to see how it affects simulation speed and stability.
Expected outcome: k_production has the largest effect on ECM accumulation magnitude, k_degradation controls the balance between deposition and turnover, and k_feedback primarily affects the spatial extent of the fibrotic response.
Input Signals: AngII, TGFβ, mechanical tension, cytokines (IL-6, IL-1, TNFα), catecholamines, growth factors (PDGF), endothelin-1, natriuretic peptides, estrogen
Key Signaling Cascades:
- MAPK pathways (ERK, p38, JNK)
- PI3K-Akt-mTOR signaling
- Rho/ROCK cytoskeletal regulation
- Calcium and cAMP second messenger systems
- NFκB, AP-1, STAT transcriptional programs
ECM Regulation:
- Collagen synthesis (Type I, III)
- Matrix metalloproteinases (MMPs 1,2,3,8,9,12,14)
- Tissue inhibitors (TIMP1, TIMP2)
- Matricellular proteins (fibronectin, periostin, tenascin-C)
- Feedback molecules: Diffusion coefficient = 0.2 (dimensionless units)
- ECM molecules: Diffusion coefficient = 0.04 (5× slower than feedback)
- Spatial discretization: 100×100 cellular grid
- Boundary conditions: Periodic (toroidal topology)
- C++ simulation core: Handles 10,000 cells × 132 molecules in real-time
- JavaScript visualization: 60 FPS rendering with Canvas API
- Memory management: Efficient pointer-based data access
- Function exports: 15+ C++ functions accessible from JavaScript
- ODE integration: Forward Euler method
- Diffusion solver: Explicit finite difference with periodic boundaries
- Rate constants: Biologically-informed parameter ranges
- Stability: Adaptive time stepping prevents numerical instabilities
"Module not found" error:
# Ensure Emscripten is properly activated
source ./emsdk/emsdk_env.sh
./compile.shSlow performance:
- Reduce time step in ODE parameters
- Use Chrome for best WebAssembly performance
- Close other browser tabs to free memory
Compilation errors:
# Check Emscripten version
emcc --version
# Clean and recompile
rm ecm.js ecm.wasm
./compile.shVisualization not updating:
- Check browser console (F12) for JavaScript errors
- Verify all files are served from same domain (use local server)
Adding new molecules:
- Add to appropriate struct in
ecm.cpp - Update initialization functions
- Add rate equations in
calculateRates() - Update JavaScript molecule mappings
Modifying UI:
- Edit
ecm_visualizer.jsfor interface changes - Update
index.htmlfor layout modifications - Recompile only needed for C++ changes
C++ optimizations:
- Compiler flags:
-O2(already enabled) - Memory layout: Structure of arrays for better cache locality
- SIMD instructions: Potential future enhancement
JavaScript optimizations:
- Canvas rendering: Off-screen buffer for complex visualizations
- Data structures: Typed arrays for numerical data
- Animation: RequestAnimationFrame for smooth updates
- Fork the repository
- Create feature branch (
git checkout -b feature/new-pathway) - Add tests for new functionality
- Commit changes (
git commit -am 'Add new signaling pathway') - Push to branch (
git push origin feature/new-pathway) - Create Pull Request
- C++: Google Style Guide with 2-space indentation
- JavaScript: ESLint standard configuration
- Comments: Biological rationale for all rate equations
If you use this simulation in research, please cite:
Preprint:
[arXiv:2510.12577](https://doi.org/10.48550/arXiv.2510.12577)
MIT License
- This work was supported by the National Institutes of Health (NIGMS R01GM157589) and the Department of Defense (DEPSCoR FA9550-22-1-0379)
- Emscripten team for WebAssembly toolchain
- Scientific literature on cardiac fibroblast signaling
- Open source contributors to mathematical and visualization libraries
Note: This simulation is for research and educational purposes. Results should be validated against experimental data before drawing biological conclusions.


