Is squidpy co_occurrence metric symmetric?

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, 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.

1 Like

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).