I am trying to assess the spatial homogeneity of cells I have cultured. I have successfully managed to obtain the x,y coordinates of the cells in a square image using Image J (an image of cell nucleuses stained with DAPI). After importing the coordinates into R, I have created a ppp object using the spatstat package, and am trying to perform a Kolmogorov-Smirnov test of Complete Spatial Randomness (CSR) using the cdf.test.ppp function in spatstat. However, I can't figure out the what exactly the "covariate" in the cdf.test function is. The points (cells) don't have marks (because they are all the same cells, no difference to be noted). Putting the values "x" or "y" into the covariate argument does seem to produce expected results (the p-value of the KS test is significant for images with clustered cells and not for homogenously distributed cells), but I need an exact understanding of what this covariate means.
### Read in Coordinates from ImageJ
DATA <- read.delim("clipboard", header = F)
### The columns V6,V7 are the X,Y Coordinates
pts <- ppp(DATA$V6,DATA$V7, window = square(1946))
plot(pts) ### Checked to see if the ppp object matches the image, no problem here
cdf.test.ppp(pts,
test = "ks",
covariate = "x")
The results go as: Spatial Kolmogorov-Smirnov test of CSR in two dimensions
data: covariate ‘function(x, y) {’ evaluated at points of ‘pts’ and transformed to uniform distribution under CSR D = xxx, p-value = xxx alternative hypothesis: two-sided
I can produce desired results using covariate = "x", but I have no idea what this means and whether it is appropriate. Tried asking ChatGPT about it, and also did quite a lot of searching, but couldn't find much about it, it is only stated that the covariate should be a function of x,y or an image, without an explanation about what it is and what should be used in what situation.