NF03 · Local crowding & collective motion¶
An earlier exploratory draft (DV-motility_metrics_sanity_check.ipynb) tested "isolated vs.
crowded" neighbor-density groups against many columns, but only on the 2,130 cells that link to
Cell Painting. Here we compute local density for every detected cell in every live frame
(~300k cell-frame rows, no tracking/linking/final-frame restriction) via a per-frame KD-tree, and
ask: does local crowding predict instantaneous speed? Bonus: is there evidence of coordinated
("flocking") motion between nearby cells?
1 · Local density, all detected cells, all live frames¶
282,178 detected cells across 60 live frames
count 282178.000000 mean 4.303425 std 2.855956 min 0.000000 25% 2.000000 50% 4.000000 75% 6.000000 max 22.000000 Name: neighbor_count, dtype: float64
2 · Density vs. instantaneous speed, all tracked cells (continuous, not just linked-to-CP)¶
186,840 tracked cell-frame steps with a matching density value Spearman(neighbor_count, step_speed_um) = -0.091, p = 0, n = 186,840
3 · Isolated vs. crowded (generalized): Welch's t-test + BH-FDR¶
Reproduces the earlier draft's isolated (0 neighbors) vs. crowded (>=5 neighbors) comparison, but on the full live-trajectory population instead of just the 2,130 CP-linked cells, and against LCI-only features (motility metrics + the shape-over-time summary from NF02) since most cells here have no CP match.
isolated (mean nbrs <1): 222 | crowded (mean nbrs >=5): 1,425 13 / 26 features significant after BH-FDR
| feature | t | p | isolated_mean | crowded_mean | p_adj | significant | |
|---|---|---|---|---|---|---|---|
| 22 | equivalent_diameter_mean | 7.805724 | 1.017015e-13 | 16.934110 | 15.485750 | 1.322120e-12 | True |
| 14 | area_mean | 7.820011 | 9.645215e-14 | 233.585522 | 196.304885 | 1.322120e-12 | True |
| 16 | perimeter_mean | 6.905334 | 2.868788e-11 | 59.916580 | 55.212229 | 2.486283e-10 | True |
| 12 | path_length_um | 4.126386 | 4.801246e-05 | 223.731975 | 190.446957 | 1.929361e-04 | True |
| 13 | mean_step_um | 4.115748 | 5.194434e-05 | 6.393794 | 5.070380 | 1.929361e-04 | True |
| 9 | mean_step | 4.115748 | 5.194434e-05 | 1.967321 | 1.560117 | 1.929361e-04 | True |
| 7 | path_length | 4.126386 | 4.801246e-05 | 68.840608 | 58.599064 | 1.929361e-04 | True |
| 25 | form_factor_cv | 3.618377 | 3.542329e-04 | 0.089441 | 0.075009 | 1.151257e-03 | True |
| 1 | start_y | 3.423717 | 7.233240e-04 | 1616.658481 | 1380.241328 | 1.880642e-03 | True |
| 3 | end_y | 3.439238 | 6.848829e-04 | 1617.471433 | 1380.223256 | 1.880642e-03 | True |
| 20 | elongation_mean | -2.713283 | 6.997272e-03 | 1.300884 | 1.337798 | 1.653901e-02 | True |
| 23 | equivalent_diameter_cv | 2.557181 | 1.107642e-02 | 0.118313 | 0.107121 | 2.399891e-02 | True |
Bonus · Collective motion: velocity correlation vs. distance¶
If nearby cells move in correlated directions (beyond what crowding-vs-speed alone shows), that's evidence of coordinated/"flocking" migration rather than independent movement.
| bin_left_um | bin_right_um | mean_cos_similarity | n_pairs | |
|---|---|---|---|---|
| 0 | 0 | 50 | 0.090447 | 20740 |
| 1 | 50 | 100 | 0.020828 | 106979 |
| 2 | 100 | 150 | 0.009791 | 167841 |
| 3 | 150 | 200 | 0.007869 | 230767 |
| 4 | 200 | 300 | 0.006245 | 641812 |
| 5 | 300 | 400 | 0.003431 | 901101 |
| 6 | 400 | 600 | 0.005177 | 2499409 |
⭐ Key finding¶
(Corrected: an earlier pass accidentally included post-fixation frames -- now explicitly
filtered to frame_index <= MOTILITY_LAST_FRAME. This also exposed a second bug: once capped,
frame_last becomes ~constant, and a zero-variance t-test's NaN silently corrupted the whole
BH-FDR vector -- both are now excluded/guarded against.)
Crowded cells move measurably slower. Across 186,840 tracked cell-frame steps (all live
trajectories, not just CP-linked ones), local neighbor count (150 µm radius) correlates
negatively with instantaneous step speed: Spearman ρ = −0.091 (p ≈ 0) -- this number is
unaffected by the fix since the density join already implicitly excluded post-fixation steps.
The generalized isolated-vs-crowded comparison (222 isolated / 1,425 crowded trajectories, by
mean neighbor count) confirms this at the trajectory level: isolated cells average
6.39 µm/frame vs. 5.07 µm/frame for crowded cells (both mean_step_um and
path_length_um, BH-FDR significant). 13 of 26 LCI features tested survive BH-FDR --
isolated cells are also consistently larger (area_mean 234 vs. 196 px²,
equivalent_diameter_mean 16.9 vs. 15.5 px), suggesting crowding may restrict both spreading and
movement (contact inhibition-like behavior), not just an incidental correlation.
Bonus — collective motion: velocity direction correlation between cell pairs is consistently positive and decays with distance (mean cos-similarity 0.090 at 0-50 µm down to ~0.003-0.005 beyond 300 µm, n up to 2.5M pairs at the largest bin) — weak but real local coordination in migration direction, on top of (and distinct from) the crowding-slows-speed effect above.
Caveat: this notebook's step-level signal-to-noise ratio is low (see NF01's caveats section -- post-fixation "should be motionless" steps measure ~95% of the live median step size), and the tracker's distance-fallback/gap-bridging links are more likely to mislink in dense regions. If mislinking is more common in crowded areas and produces artificially smaller apparent displacement, that alone could partly explain "crowded cells look slower" without real biology behind it. Not yet ruled out -- see NF01 for the proposed overlap-only-vs-fallback comparison.