itasc.contact_analysis.contacts.neighborhood¶
Neighborhood & density derivations over the cell–cell contact graph.
Two headless, Qt-free, label-agnostic derivations on an already-read
PositionContactAnalysis,
each returning a tidy column-major table (dict[str, np.ndarray]):
cell_neighbor_counts()— adjacency degree per cell (how many neighbors).cell_density()— cells per unit field-of-view area. (Counts straight off aframe -> [cell_id, …]map, so it needs only the cell labels, not the contact graph.)
The cell_cell edges of the contacts edges table are the adjacency
graph; degree is the count of incident cell_cell edges, deduped per neighbor
(a boundary split across several edge rows still counts as one neighbor).
The classification-dependent derivations (neighbour enrichment; contact-type
z-score vs a label-shuffle null) are not here — they consume a per-cell
subpopulation class_label and so live with the dataset that defines it, not in
this label-agnostic library.
Like contacts.signed_contact_length and contacts.contact_labels, these
operate on the in-memory analysis object only: they never open HDF5, so they run
unchanged in scripts, notebooks, and the napari plugin.
Functions
|
Per |
|
Per |
- itasc.contact_analysis.contacts.neighborhood.cell_neighbor_counts(analysis)[source]¶
Per
(frame, cell_id)adjacency degree — the headline neighbor count.One row per cell present in the
cellstable for that frame, withn_neighborsits number of distinctcell_cellneighbors (0 for an isolated cell). This count is also the numerator for density.Columns (column-major, equal length):
frame,cell_id,n_neighbors(int).- Return type:
- Parameters:
analysis (PositionContactAnalysis)
- itasc.contact_analysis.contacts.neighborhood.cell_density(frame_cells, *, fov_area_mm2)[source]¶
Per
framecell count anddensity = n_cells / fov_area_mm2.Emits one
label="all"row per frame that counts every cell in the frame.densityis in cells/mm²; fov_area_mm2 is the user’s field-of-view area and is required (a positive number) — there is no silent image-area fallback.frame_cells maps
frame -> [cell_id, …](the cell labels present in that frame), so this counts straight off the cell labels with no contacts dependency.Columns:
frame,label(str, always"all"),n_cells(int),density(float, cells/mm²).