1

I am working on spatial point pattern analysis using R.

I have two sets of coordinates, both defined inside a 32*20 region. I first convert two data sets to ppp objects:

Tumor_CD8 <- ppp(Tumor_CD8[,1],Tumor_CD8[,2], c(0,32), c(0,20))
Tumor_CD3 <- ppp(Tumor_CD3[,1],Tumor_CD3[,2], c(0,32), c(0,20))

And now I am confused about how to combine them to a multitype point pattern object, in order to perform functions like: Gcross, Kcross and Lcross, etc.

1

Construct a new ppp using the coordinates of the components. Create a marks parameter as a factor of the same length as the sum of both ppp sizes:

> p1 = ppp(runif(10),runif(10))
> p2 = ppp(runif(10),runif(10))
> pm = ppp(c(p1$x, p2$x),c(p1$y,p2$y), 
           marks=factor(c(rep("A",p1$n),rep("B",p2$n))))
> is.multitype(pm)
[1] TRUE
> plot(pm)

should plot different markers for each type. Note it has to be a factor - numeric or character will create something with marks but is.multitype is FALSE unless its a factor.

Specify a window as well if not using the default (0,1) square.

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.