I have a 100um x 100um x100um volume which has 200 cells in it. I will measure the locations of those cells within the volume, and wish to estimate whether they are significantly non-randomly clustered together. So far I have thought of two methods, each with their own problems:

Method 1) Measure the distances between each pair of cells, giving approximately 40000 distances. Randomly simulate 200 points in an equal sized volume, and plot the distribution of their pairwise distances (this is the distribution under the null hypothesis). Depending on the characteristics of this distribution, use an appropriate statistical test to calculate the probability of observing a certain mean distance (or one more extreme) from a single 200 cell set, and use compare the mean distance from the real dataset to this distribution under the null hypothesis. This would allow the calculation of a p-value, which would indicate whether there is likely to be any significant clustering in the real sample, but not give any information about the number or identity or location of clusters. As far as I can tell it would only be necessary to run one simulation of a two hundred cell volume, because this would generate approx 40000 distances, which would be sufficient to determine the distribution of this statistic under the null hypothesis.

Method 2) Use an clustering algorithm (such as DBSCAN: en.wikipedia.org/wiki/DBSCAN), to measure the number of clusters of cells in the 200 cell single real dataset. Number of clusters would now be the test statistic, rather than distances between individual cells in the volume. So there will only be one measurement within the volume (i.e. a single measurement of number of clusters). Could one then run the DBSCAN algorithm on e.g. 10,000 simulated 200 cell volumes (where the cells' locations in each simulated volume was random), generating a cluster number from each simulation, and thereby a cluster number probability distribution under the null hypothesis (I would expect the most common cluster number from random simulation to be 0, and then drop sharply - i.e. not normally distributed). But if we can generate a probability distribution of the test statistic (cluster number) under the null hypothesis of random spatial distribution, entirely by simulation, then we should be able to calculate the p-value for our single real measurement of cluster number from our single real 200 cell dataset.

I haven't used simulated datasets to generate the distribution under the null hypothesis before though, so I'd appreciate any advice on whether my assumptions described above are defensible, in particular whether one can compare a single measurement of the test statistic to a distribution of the same test statistic under the null hypothesis.

  • $\begingroup$ See Ripley's K function: it gives far more information than the mean of mutual distances. Simulations (plural: one will not do in any case, due to edge effects) can be used to place confidence envelopes around the empirical K function. $\endgroup$ – whuber Oct 23 '17 at 21:59

I'd rather avoid the challenges of clustering here.

The first approach sounds much like Hopkins test for clustering tendency. Except that that one doesn't use pairwise distances, but just the nearest neighbor each (with an index, this is much faster). And of course, Ripley's K and L.

But in essence, you attempt to do a test for a uniform distribution.

A very fast and simple test could be by simply dividing the data into small enough squares, then comparing the distribution of counts. I'm pretty sure that someone's has studied this before, and provides thresholds. While this test may have less power, it will be fast, and likely be able to recognize the obvious cases.

There is an important difference here: the tests will usually allow you to reject the hypothesis that the data is uniform - that does not imply there are multiple meaningful clusters there. In fact, a single Gaussian (which is just as random as a uniform distribution) will usually be rejected as uniform (if the test is good). So beware: being "not uniform" is not the same as "having multiple clusters".

  • $\begingroup$ Hi, thanks for the reply Anony-Mouse and apologies for my delayed reply. Regarding the the approaches for testing for non-uniformity (I appreciate that this is not the same as 'having meaningful clusters'), I am happy to go ahead and apply the Hopkins test to my data. $\endgroup$ – Alex Oct 30 '17 at 16:52
  • $\begingroup$ I suppose my real interest is in finding a way of objectively measuring the number of clusters within a set of samples, and then treating 'number of clusters' as the test statistic, to be able to look for differences in 'number of clusters' between different conditions. $\endgroup$ – Alex Oct 30 '17 at 16:53
  • $\begingroup$ I am fairly confident that I could generate a probability distribution for 'number of clusters' by randomly varying the locations of individual points 10,000 times, and calculating the number of clusters produced by the algorithm each time. This would give a distribution of 'number of clusters' under the null hypothesis (which is that the points are randomly distributed), and that in turn could give the probability of observing a certain 'number of clusters' under the null hypothesis. $\endgroup$ – Alex Oct 30 '17 at 16:53
  • $\begingroup$ What feels quite dubious is to then take a single cluster number measurement from a single real sample, and state the probability of achieving this cluster number under the null hypothesis. But I can't work out why this feels dubious - would I actually have to have multiple independent real samples, each with their own 'number of clusters', and then compare the distribution, variance or some other feature of this real 'number of clusters' distribution to 'number of clusters' distribution under the null hypothesis (which is produced by simulation) ? Many thanks for any advice you can give! $\endgroup$ – Alex Oct 30 '17 at 16:53
  • $\begingroup$ Don't rely on synthetic data simulations. Your real data is not generated this way. You overfit to your data generation process, and it doesn't reflect reality. Cluster centers are not uniformly distributed, are not exactly Gaussian, etc. - your simulation process is full of assumptions. $\endgroup$ – Anony-Mousse Oct 30 '17 at 17:33

I've seen the following approach recommended in point process literature:

Estimate pairwise correlation function for your data and plot it alongside the pairwise correlation function for a point process with complete spatial randomness (I think it's constant at 1?). Deviations away from 1 will indicate non-random fluctuations away from complete spatial randomness.

You can do the same for Ripley's K function or the L function but these contain the same information as the pairwise correlation function and it's often easier to eyeball deviations away from a horizontal line than a curve or angled line as youd get in the K or L function case.

You can get 'confidence' bounds around the pairwise correlation function by simulating many times from a homogeneous point process, calculating the correlation fn and plotting the max-min bounds on the plot or the upper/lower 95% quantile or whatever flavour you like. This lets you know which wiggles are not likely to be random.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.