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 -e .                    # core (CSV support only)
pip install -e ".[anndata]"         # + .h5ad support
pip install -e ".[seurat]"          # + .rds/.rda support (requires R + rpy2)
pip install -e ".[dev]"             # + test dependencies

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       — 43 tests covering session logic end-to-end
  fixtures/             — CSV test fixtures

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, Visium scale factors)
  • CSV spatial synthesis (x/y/z obs columns → obsm["spatial"])
  • Domain inference with priority chain (preferred > platform > 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
  • BiwtInput.domain_accepted + "Skip domain validation" checkbox bypass auto-check
  • Z-fields default to ±10 for 2D data in domain editor
  • DomainSpec units field; auto-scale toggle wired into positions step
  • Auto-scale off: raw data bounding box centered at domain center (not identity transform)
  • "Domain Settings…" button in positions plot window for manual domain editing
  • Spot deconvolution query and cell expansion
  • 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)
  • Coordinate placement (spatial scaling, random placement)
  • 29 cell parameter templates with XML assembly
  • BiwtResult assembly (coordinates, cell_type_map, domain, XML)
  • 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
  • Step predicate extraction for testability
  • 57 passing tests

In Progress

  • End-to-end manual testing with Studio

Remaining

  • pyproject.toml extras for anndata/seurat/dev dependencies
  • CI pipeline (GitHub Actions, Python 3.9–3.12)
  • CI: R-dependent tests for .rds import (requires provisioning R on CI runners; seurat excluded from dev extra for now)
  • 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

  • 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.3.1.tar.gz (306.4 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.3.1-py3-none-any.whl (309.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: biwt-0.3.1.tar.gz
  • Upload date:
  • Size: 306.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for biwt-0.3.1.tar.gz
Algorithm Hash digest
SHA256 19af3166187008eb78ad76173f11f558fdc742c9dd9d6a63726dafcad59c589e
MD5 8972281e3d6d90c2314344c8d62ee19a
BLAKE2b-256 8228ff4bde855bad39255f931fe50cf656bbd6b6eaa1d21ee03659c7f122f66e

See more details on using hashes here.

Provenance

The following attestation bundles were made for biwt-0.3.1.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.3.1-py3-none-any.whl.

File metadata

  • Download URL: biwt-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 309.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for biwt-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8441bae53a8360f295c45fa06702a9f32aefb814c24626a57c73bf26caebd26f
MD5 2e119e3bf571ecf28717837f2d241f4d
BLAKE2b-256 fbb4189db4fbfafaf8053cffbe160a0d4a44a333213a3b2230eacbd1c06d9c6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for biwt-0.3.1-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

0.4.0

2 files

This release

0.3.1 This release

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