An interactive web application for generating cell type-specific DNA regulatory sequences using the DNA-Diffusion model from Pinello Lab.
- π° Interactive Slot Machine Interface: Visualize DNA sequence generation in real-time with 200 spinning slots
- 𧬠Cell Type-Specific Generation: Generate sequences for K562, GM12878, and HepG2 cell lines
- β‘ Real-time Feedback: Continuous animation while the model generates sequences
- π¨ Beautiful UI: Retro-futuristic design with neon effects and smooth animations
- π€ Powered by DNA-Diffusion: State-of-the-art diffusion model for DNA sequence generation
- Python 3.8+
- CUDA-capable GPU (optional, but recommended for faster generation)
- Git
- uv package manager (for DNA-Diffusion installation)
- Clone this repository:
git clone https://github.com/pinellolab/gradio-dna-diffusion.git
cd gradio-dna-diffusion
- Install uv package manager:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Clone and install DNA-Diffusion:
git clone https://github.com/pinellolab/DNA-Diffusion.git
cd DNA-Diffusion
uv sync
cd ..
- Install Gradio app dependencies:
pip install -r requirements.txt
- Basic usage:
DNA-Diffusion/.venv/bin/python app.py
- With options:
# Run on a specific port
DNA-Diffusion/.venv/bin/python app.py --port 8080
# Create a public share link
DNA-Diffusion/.venv/bin/python app.py --share
# Run on all network interfaces
DNA-Diffusion/.venv/bin/python app.py --host 0.0.0.0
- Open your browser to
http://localhost:7860
- Select a cell type using the radio buttons (K562, GM12878, or HepG2)
- Click GENERATE or pull the lever to start sequence generation
- Watch the slots spin while the model generates a 200bp regulatory sequence
- The generated sequence will be displayed below once complete
gradio-dna-diffusion/
βββ app.py # Main Gradio application
βββ dna_diffusion_model.py # Model wrapper for DNA-Diffusion
βββ dna-slot-machine.html # Interactive HTML interface
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ DNA-Diffusion/ # DNA-Diffusion repository (gitignored)
- Create a new Space on Hugging Face Spaces
- Select Gradio as the SDK
- Clone your Space locally:
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME
- Copy the required files:
cp path/to/gradio-dna-diffusion/app.py .
cp path/to/gradio-dna-diffusion/dna_diffusion_model.py .
cp path/to/gradio-dna-diffusion/dna-slot-machine.html .
cp path/to/gradio-dna-diffusion/requirements.txt .
- Create app metadata (
README.md
):
---
title: DNA Diffusion Slot Machine
emoji: π§¬
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 4.44.1
app_file: app.py
pinned: false
---
- Push to Hugging Face:
git add .
git commit -m "Initial commit"
git push
- Push this repository to GitHub
- Create a new Space on Hugging Face
- Link it to your GitHub repository
- The Space will automatically build and deploy
For optimal performance, enable GPU in your Space:
- Go to Settings β Hardware
- Select T4 GPU or better
- The model will automatically use GPU if available
The app can run in mock mode for UI development:
python app.py
This will use random sequence generation instead of the actual model.
- Edit
dna-slot-machine.html
to modify the visual interface - The interface communicates with Gradio backend via
postMessage
API - Cell types and generation parameters can be extended in
app.py
- Model: DNA-Diffusion from Pinello Lab (HuggingFace: ssenan/DNA-Diffusion)
- Sequence Length: 200bp regulatory elements
- Cell Types: K562, GM12878, HepG2 (hESCT0 available in model but not in UI)
- Generation Time: 2-5 seconds on GPU, 20-30 seconds on CPU
- Framework: Gradio 4.44.1 with custom HTML/JS interface
- Ensure DNA-Diffusion is properly installed with
uv sync
- Check that you're using the DNA-Diffusion virtual environment
- Verify CUDA is available if using GPU:
python -c "import torch; print(torch.cuda.is_available())"
- Check that
dna-slot-machine.html
exists in the same directory asapp.py
- Clear browser cache and reload
- Check browser console for JavaScript errors
- Use a CUDA-capable GPU for 10x faster generation
- The first generation includes model warm-up time
- CPU generation typically takes 20-30 seconds
If you use this application in your research, please cite:
@article{dnadiffusion2024,
title={DNA-Diffusion: Leveraging Generative Models for Controlling Chromatin Accessibility and Gene Expression via Synthetic Regulatory Elements},
author={DaSilva, Lucas Ferreira and Senan, Simon and Patel, Zain Munir and Reddy, Aniketh Janardhan and Gabbita, Sameer and Nussbaum, Zach and CΓ³rdova, CΓ©sar Miguel Valdez and Wenteler, Aaron and Weber, Noah and Tunjic, Tin M. and Khan, Talha Ahmad and Li, Zelun and Smith, Cameron and Bejan, Matei and Louis, Lithin Karmel and Cornejo, Paola and Connell, Will and Wong, Emily S. and Meuleman, Wouter and Pinello, Luca},
journal={bioRxiv},
year={2024},
doi={10.1101/2024.02.01.578352},
url={https://www.biorxiv.org/content/10.1101/2024.02.01.578352v1}
}
DNA-Diffusion Gradio Interface is made available for free to academic and non-profit researchers under the Apache License, Version 2.0.
If you plan to use this code or the synthetic sequences generated by the model for profit, please contact [email protected] for more information.
See LICENSE file for full details.
- Pinello Lab for the DNA-Diffusion model
- Gradio for the web framework
- DNA-Diffusion team for the pretrained models