gelpy
A Python package for simplified, reproducible, and easily shareable gel electrophoresis analysis. Point it at a gel image and it gives you per-lane band intensities in a browsable folder of plain files — no hand-drawn ROIs, no CSV shuffling, and no analysis that only runs on the machine it was written on.
gelpy is maintained again, and version 1.0 is a rewrite. I archived this project in 2024 for lack of time. What brought it back is that the tedious half of the work — driving the tool, checking each lane, deciding what to refit — is work a coding agent can now do properly, provided the tool is built for one. So gelpy is now CLI-first and agent-native: it speaks JSON, every command is explicit and replayable, and the analysis lives in a run folder you can hand to someone else.
1.0 is not compatible with 0.x. The
Gelobject API is gone, not deprecated, and old pickled gel objects cannot be loaded. If you have 0.x notebooks, see docs/guide/migrating-from-0.x.md for the command that replaces each method, and CHANGELOG.md for the full list of breaks.
What it does
- Places lanes from the image, not from pixel coordinates you typed in, and renders an overlay so you can check before trusting anything downstream
- Removes the image background with a robust IRLS surface fit — no hand-placed stripes
- Extracts per-lane line profiles
- Fits bands with no per-lane peak-detection tuning: the peak count is chosen by AICc, the shape is chosen per component (gaussian, EMG, bi-gaussian, pseudo-Voigt), and every band is classified and counted
- Tells you how much to trust each lane: a per-lane confidence flag with machine-readable reasons, separate from whether the fit converged
- Writes the whole analysis to a run folder:
recipe.json,results.csv/.json,report.md, and every figure
The pipeline is content-hash cached: re-running an identical command recomputes nothing, and refitting one lane recomputes only that lane. The generated walkthrough times the first fit and a re-run on the example gel.
See it work
docs/walkthrough/ is the whole workflow on a real 20-lane DNA origami folding screen: the commands, their output, the figures and the numbers. The page is generated by running the analysis, so it cannot drift out of date. It also covers the awkward parts: which lanes came back low-confidence, and why the number you want is a sum over a migration window rather than a single row.
Install
conda create -n gelpy python=3.11
conda activate gelpy
pip install -e . # from a checkout
pip install -e ".[dev]" # plus the test and documentation suites
pip install -e ".[mcp]" # plus the MCP server (gelpy mcp)
This installs a gelpy command (also python -m gelpy). Check it:
gelpy --help
gelpy models list --kind fit
Use it
Two ways, and they do the same thing.
Ask an agent. With the skill installed (below), one prompt does the analysis, checks the lane overlay, inspects each fit, and tells you which lanes it would not trust:
Analyze gels/my_gel.tif. It is a 20-lane agarose gel; the sample
sheet is in gels/labels.txt. I want the per-lane band fractions and I want to
know which lanes you would not trust.
More prompts, and what each one makes the agent do, in examples/agent_prompts.md.
Or run it yourself. The commands the agent runs are the commands you would:
RUN=runs/gel; IMAGE=gels/my_gel.tif
gelpy init "$RUN" "$IMAGE" --n-lanes 20
gelpy lanes detect "$RUN" --n-lanes 20 --apply --labels-file gels/labels.txt
# now check $RUN/render/lane_detect.png: if the lanes are wrong, every
# number below is wrong
gelpy background remove "$RUN" --model robust_plane
gelpy fit run "$RUN" --plot
gelpy status "$RUN"
gelpy results show "$RUN" --format table
Every command takes the run directory explicitly, so there is no hidden "current run" and your
shell history is a complete record of the analysis. init stops with run_exists on a folder
that already holds a run: repeat it with --force to replace that run, or pick a new folder.
Each step above is also a tool that reads one JSON object and writes one (gelpy tool list --json
describes them, gelpy tool call NAME runs one). gelpy mcp serves the same tools to an MCP
client (pip install "gelpy[mcp]"), and gelpy report html "$RUN" writes the run as a static web
page. docs/guide/driving-from-an-agent.md has the tool
contract and docs/guide/html-report.md the report.
Documentation
docs/ is the map. The short version:
- docs/guide/analyze-a-gel.md — the workflow, in order
- docs/guide/fit-engine.md — what the fitter does and how far to trust it
- docs/guide/results.md — what every column means
- docs/guide/known-limitations.md — read this before you publish numbers
- docs/reference/ — every flag, contract and error code, generated from the code
- docs/guide/extending.md — adding a peak shape, fit strategy or background model
The documentation is checked rather than trusted: the reference is generated from the code and diffed by a test, every command block in the guide and the walkthrough is executed against the example gel, and key facts are asserted by named tests. This exists because, during the rewrite, the documentation was wrong in 38 verified places and nobody noticed for two months.
Getting the skill
The gelpy-analyze skill lives in plugin/ and carries the judgment part: verify
the overlay, don't trust status: "ok", escalate a low-confidence lane. The simplest install
needs no marketplace: copy plugin/skills/gelpy-analyze/ into ~/.claude/skills/ (every
project) or into .claude/skills/ of the project you analyze gels in. To update, delete the
old copy before copying the new one; copying over it keeps files the new version dropped. To
serve the skill from a Claude Code plugin marketplace instead,
plugin/README.md has both arrangements and the command that vendors it.
The verified setup is Claude Code (terminal or desktop app) in a directory with gelpy installed and your images on disk. I have not tested other agent environments.
What it deliberately does not do
- Molecular weights. No ladder calibration, so
areais in intensity units, not mass. - Sub-pixel lane placement. The grid phase is accurate to about 0.02 of the lane pitch on a real gel; that is invisible against a 180 px profile strip, but it is not sub-pixel.
- Rescue a gel that fills a fraction of the crop. The lane-grid prior assumes the lanes span roughly the whole image. That case is detected and flagged, not silently fudged — set the outer lane centers by hand instead.
- Decide what your bands mean. It gives you areas, classes and uncertainties. Which species is which is your call.
docs/guide/known-limitations.md has the full list, with measurements.
Contributing
Same invitation as before: try gelpy, break it, and tell me. A gel it handles badly is more useful to me than a bug report about tidy code, so an issue with the image attached is the most valuable thing you can send. If you want to write code, docs/guide/architecture.md explains the layout and docs/guide/extending.md explains how to add a model without touching anything else.
Before opening a pull request:
pytest tests/ -q # the suite must pass
python tools/docs.py check # documentation must agree with the code
Citing
If gelpy contributed to work you are publishing, please cite it via the Zenodo DOI.
License
GPLv3 or later. See LICENSE.
Metadata
Release files for gelpy 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gelpy-1.1.0.tar.gz | 2.1 MB | Without provenance | Details for gelpy-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gelpy-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for gelpy-1.1.0-py3-none-any.whl |
Total release size: 2.3 MB
Release files / gelpy-1.1.0.tar.gz
| Download URL | gelpy-1.1.0.tar.gz |
|---|---|
| Size | 2.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e47e3e025a3d1c5039906f071451073e46241dda68d43c27644e6409aea57473
|
|
BLAKE2b-256 checksum How to use checksums |
5faef4672e404fa8df7b99254b582419ee1c176c6dac33bdce22923d0343556b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Release files / gelpy-1.1.0-py3-none-any.whl
| Download URL | gelpy-1.1.0-py3-none-any.whl |
|---|---|
| Size | 198.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
407d27a0d8d19a4927b2cc503989bb623dfacf06ae2ae04c52c4e682a52c905a
|
|
BLAKE2b-256 checksum How to use checksums |
a0b6f3d5402315a2895291a6c113c73901c058fd9e2bed296ebd4c802684bd27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.13
|
Security for gelpy 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.