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.2.0.tar.gz (305.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.2.0-py3-none-any.whl (309.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: biwt-0.2.0.tar.gz
  • Upload date:
  • Size: 305.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.2.0.tar.gz
Algorithm Hash digest
SHA256 0fd887a81fb421c5b1c97fed459a4a0fd9b094507455a52db48432c759cbbb4a
MD5 9af7dbde653a8a36b5dd51afd1be69fa
BLAKE2b-256 0d7dce719ee0ad160e4717a1fda37a3546fe5d8c916cb21cb113097b38260e2d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: biwt-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 309.4 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9923ecbac5c6ef830e41faf5cbd99c87738b7f52062c4e6d19bfcf7c1dc2ec35
MD5 858c55e5768192d26e91c9152d1b1cb9
BLAKE2b-256 e0304da988cb22e7035fff32da4bc30d0de1ef5a6c3506eaee6cbb4b959cada1

See more details on using hashes here.

Provenance

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