Skip to main content

BioInformatics WalkThrough: import single-cell data and generate agent-based model initial conditions

Project description

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

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")

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

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

Project details


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.1.0.tar.gz (73.8 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.1.0-py3-none-any.whl (76.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for biwt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 46228640d7c607b33d0d8e339efc0490cfafffd7e8bf301c136100c79be63c9a
MD5 9afc19c31596325ee8d764269c3ed671
BLAKE2b-256 e79dc2a72d39f81f2913784eef29865e6de7d5d7bfabb5e92a92e8f280f4a5e9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: biwt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 76.2 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab236bf4e61694dd210b27186c9da87dc90d6022e569ae3a294c63b364f2d006
MD5 b874183c25e4944b7e83be7e8d8380e3
BLAKE2b-256 7bd485edbda67635c64786bd6c45313d7a88aeaeae79c01dc056e429b1154dd5

See more details on using hashes here.

Provenance

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page