Skip to main content

BIWT — BioInformatics WalkThrough

A guided wizard for importing single-cell bioinformatics data and generating initial conditions for agent-based models (ABMs). Designed as a standalone pip-installable package that can be embedded in any host application. Currently integrated with PhysiCell Studio.

Installation

pip install biwt                    # core (CSV support only)
pip install "biwt[anndata]"         # + .h5ad support
pip install "biwt[seurat]"          # + .rds/.rda support (also needs R — see below)
pip install "biwt[gui]"             # + PyQt5 walkthrough UI
pip install "biwt[all]"             # everything

Development install (from a clone):

pip install -e ".[dev]"             # editable + test dependencies

.rds / .rda import needs a working R with Seurat and SingleCellExperiment in addition to the pip extra. See the installation guide for the conda recipe and a troubleshooting guide for the R stack.

Documentation

Full docs: drbergman-lab.github.io/biwt — user guide for every wizard step, worked recipes for Visium / scRNA-seq / spot-deconvolution data, the host-integration contract, and a generated API reference.

Build them locally with:

pip install -e ".[docs]"
mkdocs serve

Quick Start

import sys
from PyQt5.QtWidgets import QApplication

from biwt.gui.theme import apply_light_palette
from biwt.gui.walkthrough import create_biwt_widget
from biwt.types import BiwtInput, DomainSpec

domain = DomainSpec(xmin=-500, xmax=500, ymin=-500, ymax=500, units="micron")
biwt_input = BiwtInput(preferred_domain=domain)

def on_complete(result):
    # result.coordinates is a DataFrame with columns: x, y, z, type
    result.to_csv("config/cells.csv")

app = QApplication(sys.argv)
apply_light_palette(app) 

widget = create_biwt_widget(biwt_input, on_complete=on_complete)
widget.show()

sys.exit(app.exec_())

Running Tests

PYTHONPATH=src python -m pytest tests/ -v

Package Structure

src/biwt/
  types.py              — Public API: DomainSpec, BiwtInput, BiwtResult
  core/
    data_loader.py      — Unified loader (.h5ad, .rds, .csv) → BiwtData
    domain.py           — Domain inference + coordinate column detection
    positioning.py      — Coordinate scaling + build_ic_dataframe
    cell_types.py       — Name-matching heuristics
    parameters/
      cell_templates.py — 29 PhysiCell cell-type XML templates
      xml_defaults.py   — Default PhysiCell XML scaffold
  gui/
    walkthrough.py      — Session state machine + Qt widget + step logic
    widgets.py          — Shared Qt widgets
    windows/            — One file per walkthrough step
tests/
  test_session.py       — 78 tests covering session logic end-to-end
  test_gui_smoke.py     — Headless Qt import-path and error-dialog tests
  test_positions_plot.py — Spatial placement / plot scaling tests
  fixtures/             — CSV test fixtures
scripts/
  make_screenshot_data.py — Synthetic Visium-like .h5ad for doc screenshots
docs/                   — MkDocs Material site (published to GitHub Pages)
  index.md
  getting-started/      — Install matrix, first walkthrough, R/Seurat troubleshooting
  guide/                — One page per wizard step, plus the domain editor
  recipes/              — Visium, non-spatial scRNA-seq, spot deconvolution
  integration/          — Host embedding: API contract + Studio bridge
  reference/            — mkdocstrings API reference
mkdocs.yml

Key Design Decisions

  • No file I/O in BIWT. The package returns BiwtResult in-memory; the host decides how to write.
  • Pure-Python session. WalkthroughSession has no Qt dependencies. All Qt logic is in window classes.
  • Single source of truth for steps. _step_predicates(session) defines step ordering. Tests import it directly.
  • CSV uses type header (not cell_type) to match PhysiCell convention.
  • Domain units. DomainSpec.units defaults to "micron" but supports other ABM frameworks.

Implementation Status

Completed

  • Data import: .h5ad, .rds/.rda/.rdata, .csv
  • Spatial coordinate detection (obsm, obs columns)
  • Pixel-coordinate fallback: recognize imagecol→x / imagerow→y (row-flipped) as a last-resort spatial source; domain reported in a generic data unit (no inferred unit name)
  • Spatial synthesis from obs columns (x/y/z or imagerow/imagecol → obsm["spatial"]) for CSV and AnnData/R, so the dim-reduction plot offers a Spatial view
  • Domain inference with priority chain (preferred > data_range > default)
  • Domain mismatch: two-tier detection (classify_domain_mismatch: "outside" / "small" / None)
  • DomainEditorDialog auto-triggered at positions window open (not import time)
  • Context-sensitive mismatch header; no header for manual "Domain Settings…" open
  • domain_accepted flag prevents re-trigger on back/forward navigation
  • Domain editor OK is gated on a usable domain: all six bounds must parse and min < max on every axis (a zero-width axis divides by zero in placement scaling); offending fields are highlighted and Cancel is never gated
  • Domain editor shows the live extents of the domain being edited
  • BiwtInput.domain_accepted + "Skip domain validation" checkbox bypass auto-check
  • Z-fields default to ±10 for 2D data in domain editor
  • Data-unit→host-unit scale factor in the domain editor: auto-detected Visium µm/pixel (_extract_visium_microns_per_pixel), editable, with each value shown in host units beside its parenthesized data-units mirror, synced by the factor, plus a reset-to-file button
  • Domain editor is an axis-major ruled grid — one row per axis (X (width), Y (height), Z (depth)) against min / max / size columns — so an axis' extent sits beside the bounds that span it instead of in a separate block six rows below. _DOMAIN_AXES is the single source of truth for the layout, the extent derivation, and the validation
  • Placement scales cells by the factor and centers them in the domain (compute_spatial_placement; session.effective_scale()) — uniform, aspect-preserving; the domain is an independent host-units container
  • "Domain Settings…" button in positions plot window for manual domain editing
  • Spot deconvolution query and cell expansion; per-spot apportionment lives in core.positioning.apportion_spot_cells (shifted-divisor equal proportions), with ties broken at random so the surplus cell no longer lands on the first-listed obs column in every spot
  • Cluster column selection
  • Spatial data query (use spatial coords or random placement)
  • Edit cell types (keep / merge / delete) with scatter plot and legend
  • Rename cell types with Studio name suggestions and duplicate blocking
  • Cell counts (data counts, confluence, total count modes); a count of zero defines the cell type without placing any of it
  • Coordinate placement (spatial scaling, random placement)
  • 29 cell parameter templates with XML assembly
  • BiwtResult assembly (coordinates, cell_type_map, domain, XML)
  • BiwtResult carries no output path — the host owns where results go; to_csv(path) writes and records nothing
  • 3-D spatial plot ⇧-drag writes the correct extent slots (the 3-D layout is (x0, y0, z0, width, height, depth), not the 2-D (x0, y0, width, height))
  • Studio bridge (BiwtInput/BiwtResult, _biwt_complete callback)
  • Overwrite/Append/Browse/Cancel dialog for CSV output
  • Append handles extra columns in existing CSV
  • Session reset on reimport
  • tomli in core dependencies (fixes import crash on Python 3.9/3.10)
  • Step predicate extraction for testability
  • [project.urls] metadata so the PyPI page links to the repo, docs, and issues
  • MkDocs Material documentation site published to GitHub Pages by .github/workflows/docs.yml
  • Docs: user guide (all wizard steps), recipes (Visium / non-spatial / spot deconvolution), host-integration guide, mkdocstrings API reference
  • LoadError.docs_url: environment-related import failures link to the setup docs from the "Import failed" dialog; file-related failures stay plain text. Missing dependencies point at the install page, broken R stacks at troubleshooting
  • pyproject.toml extras for anndata/seurat/dev dependencies
  • CI pipeline (GitHub Actions, Python 3.9–3.12)
  • CI: R-dependent .rds tests run in a dedicated seurat job that provisions R, Seurat, and SingleCellExperiment from conda across Python 3.9–3.12; tests/fixtures/make_fixtures.R regenerates the fixture each run so it cannot drift against the resolved R version
  • 155 passing tests (one .rds test skips locally without the R stack; the seurat CI job runs it)

In Progress

  • End-to-end manual testing with Studio

Remaining

  • User documentation / help text within wizard steps
  • Substrate/gene expression pass-through (reserved fields in BiwtResult)
  • Multi-library Visium support
  • 3D spatial data support beyond z=0 padding

Related Documents

  • Documentation site — user guide, recipes, integration guide, API reference (source in docs/)
  • PRD.md — Product requirements (behavioral specs, acceptance criteria)
  • progress.md — Session decisions and reasoning
  • CLAUDE.md — Claude agent guide for this repo

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

biwt-0.4.0.tar.gz (332.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

biwt-0.4.0-py3-none-any.whl (320.3 kB view details)

Uploaded Python 3

File details

Details for the file biwt-0.4.0.tar.gz.

File metadata

  • Download URL: biwt-0.4.0.tar.gz
  • Upload date:
  • Size: 332.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for biwt-0.4.0.tar.gz
Algorithm Hash digest
SHA256 37e2535646d28a9694abde5366c8a26e84588f15580ebaa3c3aa2f1a4a5c1c05
MD5 20efd1b6917d90b27ff30b7660051858
BLAKE2b-256 f4d73a592a80eceea0560a957df7c88b41e18725820a8a4a1bee9d5276f2b19c

See more details on using hashes here.

Provenance

The following attestation bundles were made for biwt-0.4.0.tar.gz:

Publisher: publish.yml on drbergman-lab/biwt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file biwt-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: biwt-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 320.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for biwt-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d1e9cfd6cd27d8463ea0e0c8203cd60f379915f38c365221a22c8716d417a957
MD5 fa0cc88cedd2d38eb45a174e464b1471
BLAKE2b-256 6ff217fe1ef63900c03d05397316ca160cde06893e970655792c5e1e1e8a8d71

See more details on using hashes here.

Provenance

The following attestation bundles were made for biwt-0.4.0-py3-none-any.whl:

Publisher: publish.yml on drbergman-lab/biwt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.0

2 files

This release

0.4.0 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

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