Skip to content

Add perturb_fraction / random_state to make_neighbor_perturbation - #39

Merged
dbdimitrov merged 1 commit into
mainfrom
feat/perturb-fraction
Oct 1, 2026
Merged

dbdimitrov merged 1 commit into
mainfrom
feat/perturb-fraction

Conversation

@dbdimitrov

Copy link
Copy Markdown
Collaborator

Summary

  • make_neighbor_perturbation (and _make_perturbed_expression / _node_perturbation) gain perturb_fraction=1.0 and random_state=0.
  • Only a seeded random subset of round(perturb_fraction * n_cells) cells keeps the shift; the rest are reverted to their original expression after clipping and before renormalisation. Out-of-range values raise ValueError.
  • Defaults reproduce the previous behaviour exactly.
  • New test test_node_perturbation_fraction in tests/test_cellina.py (fraction 1.0 == old, 0.0 == unchanged, 0.5 changes half the rows deterministically, invalid range raises).

Distilled from 0f5b68a on the rebuttal branch (only the src/cellina/_spatial_utils.py hunks; the analysis/ scripts are not included). Required by the node-fraction dose-response sweep in cellina-reproducibility PR #59.

🤖 Generated with Claude Code

Perturb only a seeded random fraction of cells before re-aggregation;
the remaining rows are reverted to their original expression before
renormalisation. Defaults (1.0, 0) keep the previous behaviour.

Distilled from 0f5b68a on the rebuttal branch (library change only).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.17%. Comparing base (c77b614) to head (24fe743).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #39      +/-   ##
==========================================
+ Coverage   90.10%   90.17%   +0.07%     
==========================================
  Files          10       10              
  Lines        1394     1405      +11     
==========================================
+ Hits         1256     1267      +11     
  Misses        138      138              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

dbdimitrov added a commit to PMBio/cellina-reproducibility that referenced this pull request Sep 30, 2026
Rerun the slide-232 node-perturbation fraction sweep with cellina
feat/perturb-fraction (PR PMBio/cellina#39) over fractions 0.1, 0.25,
0.5, 0.75, 1.0 (0.0 and 0.05 dropped), 5 cell types x 5 seeds, and
regenerate the per-cell-type summary tables and figure.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@dbdimitrov
dbdimitrov merged commit 70bdf9a into main Oct 1, 2026
3 checks passed
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