Hi there.
I'm doing a PhD in plant cell biology. Right now I am doing a co-localization study where I am examining if two different proteins appear in the same subcellular domains within a cell. From confocal microscopy images I can retrieve two-dimensional data for the localization of the two different proteins (with ImageJ I can obtain x and y values for each dot in my images, representing the proteins).
example.jpg

My issue is this:
I have, say 50 dots and thus 50 coordinates (x and y) from protein A, and 50 coordinates from protein B.
Protein A and B are said to co-localize if they appear within 2 units from each other, in both x and y directions.
For example, in the supplied image dataset.jpg, sample 1 from protein A and sample 2 from protein B are within 2 units of each other in both x and y.

So: How can I, find and count dataset matches between samples in protein A and protein B that meet the matching requirements in both x and y?

(To be overexplicit, how can I using a formula find that Protein A values (X: 626.18, Y: 861.94) matches Protein B values (X: 626.05, 861.25) since they are within +-2 units of each other?)

----

I have tried something like the following:

=COUNT(C$1:C$5)-COUNTIF(C$1:C$5;">A3+2")-COUNTIF(C$1:C$5;"<A3-2")

I know this function is not correct, but what I finally managed to do is to count the number of similar (+- 2) cells in one dimension (either x or y), but I don't know how to analyze both x and y simultaneously.

Thanks to anyone who firstly understands my situation, and secondly to the genius that can help me. It would make my work a whole lot easier. I've got hundreds of samples to analyze and I want do do all I can to automate this process.
Thanks again in advance!

Kristoffer