[R] tessellation from biological data in spatstat

Dr Richard Mort Richard.Mort at hgu.mrc.ac.uk
Fri Oct 15 16:10:21 CEST 2010


Hi,

I'm new to this mailing list so apologies if this is too basic. I have 
confocal images 512x512 from which I have extracted x,y positions of the 
coordiates of labelled cells exported from ImageJ as a.csv file. I also 
have images that define an underlying pattern in the tissue defined as 
areas of different pixel values 0 or 255 (also 512x512) I've exported 
these images as .txt files. I'd like to use spatstat to look at how the 
individual cells plot onto these patterns.

#I can import my x,y data and do basic stats with spatstat by doing the 
following:

library(spatstat)
data01 <- read.csv("250810.csv", skip=1)
x <- data01[[2]]
y <- data01[[3]]
data02 <- ppp(x, y, xrange=c(0,512), yrange=c(0,512))
unitname(data02) <- c("pixel", "pixels")
plot(data02)
#etc etc

#I can also import my text images and convert them to a tessellation 
using the following:

a <- read.table("FOLLICLES.txt")
win <- owin(c(0,512), c(0,512))
unitname(win) <- c("pixel", "pixels")
b <- as.matrix(a, xrange=c(0,512), yrange=c(0,512))
unitname(b) <- c("pixel", "pixels")
c <- im(b, xcol=seq(ncol(b)), yrow=seq(nrow(b)), unitname="pixels")
d <- tess(image = c)
plot(d)

#I can then plot my ppp pattern on top of my tessellation using:

plot(d)
plot(data02, add=TRUE)

#So far so good, but when I run for example:

qb <- quadratcount(data02, tess = d)

#I get the following error:

Warning message:
In quadratcount.ppp(data02, tess = d) :
  Tessellation does not contain all the points of X

#When I investigate further the following is returned for each object:

 > d
Tessellation
Tessellation is determined by a factor-valued image with 2 levels
window: binary image mask
512 x 512 pixel array (ny, nx)
enclosing rectangle: [0.5, 512.5] x [0.5, 512.5] pixels 
 > data02
 planar point pattern: 254 points
window: rectangle = [0, 512] x [0, 512] units 

#I don't understand why my tessellation is a different size but even 
taking this into account my ppp should plot inside the window and does 
when i do plot(data02, add=TRUE). I've spent ages playing around with 
redefining the windows but I must be missing something (probably obvious).

Any help would be appreciated, I can provide files.
Kind regards
Richard



More information about the R-help mailing list