Skip to content

Add COZI to nhood_enrichment()#1023

Open
chiarasch wants to merge 47 commits into
scverse:mainfrom
chiarasch:cozi_nhood_enrichment
Open

Add COZI to nhood_enrichment()#1023
chiarasch wants to merge 47 commits into
scverse:mainfrom
chiarasch:cozi_nhood_enrichment

Conversation

@chiarasch

@chiarasch chiarasch commented Aug 12, 2025

Copy link
Copy Markdown

Description

  • Adds normalization parameter for conditional and total normalization of neighbor counts to nhood_enrichment() as described in Schiller et al bioRxiv.
  • Adds conditional cell ratio (CCR) output when normalization= conditional. CCR is the proportion of cells of an index type that neighbors cells of the neighbor type.
  • Adds nhood_enrichment_dotplot()to plot zscore and CCR at once.
  • Adds min_cell_count parameter to nhood_enrichment() to filter out clusters of cells with counts below the set threshold. Filtered out interaction z-scores are replaced with NA.

How has this been tested?

Added additional test functions for nhood_enrichment with conditional normalization and CCR. Test images for dotplot are missing, all other tests run successfully.

TODO

  • Add dotplot test images for test

@chiarasch

Copy link
Copy Markdown
Author

I get a resolution-too-deep error for dependencies for ubuntu related to tox and the error for macos also seems to be connected to tox. I only added an import warnings in the code, so I did not change any dependencies. Can someone help?

@codecov-commenter

codecov-commenter commented Aug 19, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.18797% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.48%. Comparing base (40307c8) to head (7824c66).

Files with missing lines Patch % Lines
src/squidpy/gr/_nhood.py 73.40% 21 Missing and 4 partials ⚠️
src/squidpy/pl/_graph.py 79.48% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1023      +/-   ##
==========================================
- Coverage   76.54%   76.48%   -0.06%     
==========================================
  Files          63       63              
  Lines        9072     9174     +102     
  Branches     1523     1541      +18     
==========================================
+ Hits         6944     7017      +73     
- Misses       1542     1567      +25     
- Partials      586      590       +4     
Files with missing lines Coverage Δ
src/squidpy/pl/_graph.py 79.51% <79.48%> (-0.01%) ⬇️
src/squidpy/gr/_nhood.py 77.33% <73.40%> (-4.15%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@selmanozleyen

Copy link
Copy Markdown
Member

Hi, sorry I just saw this. I'd like to understand what happens here before I give it an OK. Could we maybe set a meeting in the scverse zulip?

@selmanozleyen selmanozleyen self-assigned this Sep 18, 2025
@chiarasch

Copy link
Copy Markdown
Author

@selmanozleyen I adopted the result class changes, ready for review

@selmanozleyen selmanozleyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The unit tests here aren't enough. Only isnan checks. Isn't there a way to ensure we have sensible results?

Also the doc formatting needs to be fixed so the CI's don't fail.

Meanwhile I also want to do performance improvement in this function and this PR. We can keep that separate though

Comment thread src/squidpy/pl/_graph.py Outdated
Annotated data matrix.
cluster_key : str
Key in `adata.obs` where the cluster (cell type) annotation is stored.
zscore_key : str, optional

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

zscore_key isn't being used here I think

Comment thread src/squidpy/pl/_graph.py Outdated
annotate: bool = False,
title: str | None = None,
cmap: str = "coolwarm",
palette: Palette_t = None,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also palette

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.

4 participants