Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 12, 2025

Creates an interactive Jupyter notebook demonstrating colocalization analysis for presentation slides, using toy regionprops data for Abeta plaques and Iba1 microglia.

Implementation

Notebook: examples/notebooks/colocalization_visualization.ipynb

  • Generates synthetic regionprops data (30 Abeta, 40 Iba1) with realistic spatial clustering
  • Implements full colocalization pipeline matching spimquant/workflow/scripts/compute_colocalization.py
  • 5 visualization types:
    • Spatial distribution (magenta Abeta, yellow Iba1 with black outline)
    • KDTree nearest neighbor search with radius visualization
    • Overlap ratio calculation across 4 scenarios
    • Colocalization map with color-coded spatial links
    • Statistical distributions (distance, overlap ratio, size relationships)

Documentation: examples/notebooks/README.md

  • Catalog of all example notebooks with usage instructions

Example Usage

# Generate toy data
df_abeta = pd.DataFrame({'stain': 'Abeta', 'pos_x': ..., 'nvoxels': ...})
df_iba1 = pd.DataFrame({'stain': 'Iba1', 'pos_x': ..., 'nvoxels': ...})

# KDTree-based colocalization
tree = KDTree(coords_iba1)
indices = tree.query_ball_point(pos_abeta, r=radius * 3.0)

# Calculate overlap ratio
overlap_ratio = max(0, 1 - distance / (radius_a + radius_b))

All visualizations are presentation-ready with configurable parameters (search_radius_multiplier, overlap_threshold).

Original prompt

can you make a jupyter notebook to make some toy regionprops data, and then run colocalization analysis on it, to create some figures? looking to make some explanatory figures for some presentation slides.. something showing 2d scatter plots of objects of two diff classes (Abeta, Iba1), plotting diff colors for each (magenta Abeta, yello(with black outline) Iba1), and then demonstrating the kd-tree, and nearest neighbour search, with distance and overlap_ratio.. any other plots or visuals you think may be helpful to describe the colocalization approach


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add Jupyter notebook for colocalization analysis with visuals Add colocalization visualization notebook with explanatory figures Dec 12, 2025
Copilot AI requested a review from akhanf December 12, 2025 19:44
@akhanf akhanf marked this pull request as ready for review December 14, 2025 01:27
@akhanf akhanf merged commit 409f302 into main Dec 14, 2025
2 checks passed
@akhanf akhanf deleted the copilot/create-colocalization-analysis-notebook branch December 14, 2025 01:28
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.

2 participants