Skip to content

feat: add partition_counts for conjugate node protein sums - #459

Open
elhb wants to merge 3 commits into
devfrom
PNA-3551
Open

feat: add partition_counts for conjugate node protein sums#459
elhb wants to merge 3 commits into
devfrom
PNA-3551

Conversation

@elhb

@elhb elhb commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Description

Add partition_counts so conjugate segmentation can sum a PNAGraph node protein matrix by partition group (cell1 / cell2 / interface / other).

This is the public-pixelator port of pixelatorR partition_counts. pass exactly one of a per-node partition vector or a partition_column node attribute; the result is partitions × proteins.

Fixes: PNA-3551

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

uv run pytest tests/pna/analysis/test_partition_counts.py -q --benchmark-disable

  • Mutual exclusion of partition vs partition_column
  • Aggregation smoke test on a tiny synthetic PNAGraph (label vector and node attribute)
  • Length mismatch, missing column, wrong graph type, and analysis re-export

PR checklist:

  • This comment contains a description of changes (with reason).
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and documentation and corrected any misspellings
  • I have documented any significant changes to the code in CHANGELOG.md

Note

Low Risk
Additive analysis API with validation and tests; no changes to pipeline stages or existing behavior.

Overview
Adds partition_counts so conjugate segmentation workflows can collapse a PNAGraph node protein matrix into one row per partition (e.g. cell1, cell2, interface) and one column per marker.

Callers pass exactly one of a per-node partition label vector (positional, index-aligned Series, or categorical with unused levels as zero rows) or a partition_column node attribute; missing/NA labels are aggregated into their own row. The function is implemented under pixelator.pna.analysis.segmentation, re-exported from pixelator.pna.analysis, and documented in the changelog and API overview. Tests cover aggregation, validation errors, categorical/NA handling, and the public export.

Reviewed by Cursor Bugbot for commit d24b4a6. Bugbot is set up for automated code reviews on this repo. Configure here.

… by node group.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e2b164b. Configure here.

Comment thread src/pixelator/pna/analysis/segmentation/partition.py Outdated
elhb and others added 2 commits September 4, 2026 16:36
…ropping the type alias.

Co-authored-by: Cursor <cursoragent@cursor.com>
…g their protein sums.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant