# Is squidpy co\_occurrence metric symmetric?

**URL:** <https://discourse.scverse.org/t/is-squidpy-co-occurrence-metric-symmetric/3875>\
**Category:** squidpy\
**Created:** [November 24, 2025, 3:38pm UTC](https://discourse.scverse.org/t/is-squidpy-co-occurrence-metric-symmetric/3875 "2025-11-24T15:38:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashenflower](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/ashenflower/32/1467_2.png) [@ashenflower](https://discourse.scverse.org/u/ashenflower)\
**Post date:** [November 24, 2025, 3:38pm UTC](https://discourse.scverse.org/t/is-squidpy-co-occurrence-metric-symmetric/3875/1 "2025-11-24T15:38:01Z")

</div>

Hello everyone,

I’ve recently started using **squidpy** to analyze my spatial data, and I have a question about the **co-occurrence** metric. According to the [documentation](https://squidpy.readthedocs.io/en/stable/notebooks/examples/graph/compute_co_occurrence.html), the co-occurrence is computed as  
**P(A | B) / P(A)**, where _A_ and _B_ are the cell types of interest. Based on this definition, my understanding is that the metric should be symmetric; that is, **co\_occurrence(A, B)** should equal **co\_occurrence(B, A)**.

However, when I compute these values on my dataset, the two results differ slightly, typically starting around the fifth decimal place. My question is: **Is this small difference expected due to numerical approximations in the calculation, or is my assumption incorrect and the metric is not actually symmetric in practice?**

Thanks in advance for any clarification.

---

<div class="post-metadata">

**Author:** ![dimalvovs](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/dimalvovs/32/1632_2.png) [@dimalvovs](https://discourse.scverse.org/u/dimalvovs)\
**Post date:** [June 10, 2026, 8:03pm UTC](https://discourse.scverse.org/t/is-squidpy-co-occurrence-metric-symmetric/3875/2 "2026-06-10T20:03:09Z")

</div>

It does seem so, I’ve just ran a tiny example to visualize it using native plotting functions to see if I am making an error in array indexing or if it’s really reciprocal. The tiny example confirms the latter (e.g. tumor-other look the same as other-tumor).

 ![output](https://canada1.discourse-cdn.com/flex035/uploads/forum11/original/2X/3/3ec61783990e8ab5be9b0c9744e045ee32e4924b.png)
