Computes Ripley's K function to assess spatial clustering or dispersion at multiple scales.
Usage
RipleysK(object, r_seq = NULL, target = NULL, correction = c("none", "border"))Arguments
- object
An
SpatialCellData-classobject.- r_seq
Numeric vector of radii, or
NULLfor automatic.- target
Character or
NULL. Restrict to a phenotype.- correction
Character.
"none"(default) or"border".
Examples
counts <- matrix(rnorm(100), nrow = 50,
dimnames = list(NULL, c("CD3", "CD8")))
coords <- data.frame(x = runif(50, 0, 200), y = runif(50, 0, 200))
obj <- CreateSpatialObject(counts, coords)
RipleysK(obj)
#> r K L expected
#> 1 0.0000000 0.0000 0.0000000 0.000000
#> 2 0.9987329 0.0000 -0.9987329 3.133636
#> 3 1.9974658 0.0000 -1.9974658 12.534545
#> 4 2.9961987 0.0000 -2.9961987 28.202726
#> 5 3.9949316 61.3791 0.4252013 50.138180
#> 6 4.9936645 122.7582 1.2573474 78.340906
#> 7 5.9923974 122.7582 0.2586145 112.810905
#> 8 6.9911303 184.1373 0.6647645 153.548177
#> 9 7.9898632 214.8269 0.2794483 200.552721
#> 10 8.9885961 245.5164 -0.1483303 253.824537
#> 11 9.9873290 276.2060 -0.6108111 313.363626
#> 12 10.9860619 337.5851 -0.6199314 379.169987
#> 13 11.9847948 368.2746 -1.1577246 451.243621
#> 14 12.9835277 368.2746 -2.1564575 529.584528
#> 15 13.9822606 552.4119 -0.7218619 614.192707
#> 16 14.9809935 675.1701 -0.3210711 705.068158
#> 17 15.9797264 767.2388 -0.3521966 802.210882
#> 18 16.9784593 828.6179 -0.7378540 905.620879
#> 19 17.9771922 951.3761 -0.5751115 1015.298148
#> 20 18.9759251 1012.7552 -1.0212603 1131.242689
#> 21 19.9746580 1104.8238 -1.2216223 1253.454503
#> 22 20.9733908 1196.8925 -1.4546125 1381.933590
#> 23 21.9721237 1258.2716 -1.9591209 1516.679949
#> 24 22.9708566 1473.0984 -1.3167162 1657.693581
#> 25 23.9695895 1565.1671 -1.6490125 1804.974485
#> 26 24.9683224 1657.2357 -2.0006382 1958.522662
#> 27 25.9670553 1779.9939 -2.1639112 2118.338111
#> 28 26.9657882 1902.7522 -2.3555298 2284.420832
#> 29 27.9645211 2117.5790 -2.0021188 2456.770827
#> 30 28.9632540 2271.0268 -2.0766352 2635.388093
#> 31 29.9619869 2424.4745 -2.1818824 2820.272633
#> 32 30.9607198 2547.2327 -2.4860055 3011.424444
#> 33 31.9594527 2639.3014 -2.9747029 3208.843529
#> 34 32.9581856 2731.3700 -3.4722215 3412.529885
#> 35 33.9569185 2946.1969 -3.3333395 3622.483515
#> 36 34.9556514 3191.7133 -3.0816198 3838.704417
#> 37 35.9543843 3314.4715 -3.4731737 4061.192591
#> 38 36.9531172 3590.6774 -3.1456013 4289.948038
#> 39 37.9518501 3682.7461 -3.7136479 4524.970757
#> 40 38.9505830 3805.5043 -4.1464217 4766.260749
#> 41 39.9493159 3897.5730 -4.7266527 5013.818013
#> 42 40.9480488 4296.5371 -3.9665637 5267.642550
#> 43 41.9467817 4542.0535 -3.9233608 5527.734360
#> 44 42.9455146 4634.1222 -4.5386545 5794.093442
#> 45 43.9442475 4695.5013 -5.2838740 6066.719796
#> 46 44.9429804 4787.5699 -5.9054236 6345.613423
#> 47 45.9417133 4941.0177 -6.2834887 6630.774323
#> 48 46.9404462 5125.1550 -6.5500079 6922.202495
#> 49 47.9391791 5247.9132 -7.0678853 7219.897939
#> 50 48.9379120 5462.7401 -7.2384616 7523.860656