Calculating clustering between segmented nuclei



I have different cell lines imaged 2D in the DAPI channel, and I want to measure if there is a difference in the way they cluster, ie the distance between nuclear edges and the number of nuclei per cluster. How should I go about this?



Hi @Karolina,
Could you upload a sample image as Bozkan did in his post please.


Hi Guillaume,

Here are two sample images- by eye it is clearly visible that one of the cell lines clusters more while another one seems to have a clustering defect.



I see you have only one channel per image, do you only need the level of clustering or will you also quantify intensities in other channels as well?
I am asking because we could use 2 distinct methods to find the cells: spot detection or nuclear segmentation and spot detection will not allow you to quantify the level of expression of other markers in the cells.


Hi @Ghiomm,

For this particular analysis I do not need to quantify anything in the other channels, but it might be useful for future analyses so i think nuclear segmentation may be a better approach.



Ok, I am trying to figure out which measure(s) would be the most meaningful in this case. ‘The way they cluster’ is not so simple to define.

At the moment I can think of 2 ways we can try:

  • We can run some clustering algorithm on your data in order to partition your cells into colonies. Then we can extract some features from the output (number of clusters, number of cells per cluster, inter-cluster distance, etc…). One problem with this though is that a ‘cluster’ is defined by the parameters we will provide to the algorithm. This can be fine since we will use the same parameters for all your data but these parameters are likely to influence your end result.

  • The other possibility is to use the Ripley’s K(t) functions. As I understand it, these functions allow to determine how far from a random distribution the cells are organised. It seems possible with this method to summarize the spatial patterns of the cells, compare the patterns in different conditions or even across distinct cell populations within one condition and test in each case for statistical significance.

I think the second option is what you really need. I need to do a bit of research to see if there exist an R package we can use maybe, we can use PickCells to segment and generate the point cloud to be used as input.

Let me know what you think.


I have found the R package: There it is and a very useful document which explains the basics and how to answer your questions with spatstat.

The feature you may be the most interested (image taken from here):

And there is more that can be quantified. I’ll give it it a try with the images you uploaded as soon as I find a bit of time.