Skip to main content

gelpy

DOI

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 Gel object 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

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:

Analyse 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.

Documentation

docs/ is the map. The short version:

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 analyse 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 area is 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.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gelpy 1.0.0
File Size Uploaded Provenance Actions
gelpy-1.0.0.tar.gz 1.9 MB Without provenance Details for gelpy-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gelpy 1.0.0
File Interpreter ABI Platform Actions
gelpy-1.0.0-py3-none-any.whl Python 3 none any Details for gelpy-1.0.0-py3-none-any.whl

Total release size: 2.0 MB

Release files / gelpy-1.0.0.tar.gz

Download URL gelpy-1.0.0.tar.gz
Size 1.9 MB
Tags Source
SHA-256 checksum
How to use checksums
ef77569f51c2a4e43788b8479005a86365d753e96b00a0712980ce346435f0ad
BLAKE2b-256 checksum
How to use checksums
f257dfc5b954972cc6792817cc0055a7242d228a68913c2320fe91f33bbfee54
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.0.0-py3-none-any.whl

Download URL gelpy-1.0.0-py3-none-any.whl
Size 137.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc9cda719a57916c6813f8afa9abe1d8ee6bf1fa3c8524ba861b2316ead4499f
BLAKE2b-256 checksum
How to use checksums
7add28f4bc42094102d0167a4cb5fbe94902d328e47ad8958f774c9fb056901c
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.0.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page