# contour map and density map Classic List Threaded 5 messages Open this post in threaded view
|

## contour map and density map

 Hi there community, I'm not a specialist with Bio7 and especially with R. I'm trying to do 2 things: 1) to get a densitymap (heatmap) with X,Y (trues coordinates from imageJ analyze particles function) 2) to plot the same above coordinates X,Y and correlate them with Z (area of the particles) in a graph such a contour map. Does someone has any strings in R for that? This would be of great help for me, if i get famous with my project i'll share this :) Thank you Sacha
Open this post in threaded view
|

## Re: contour map and density map

 Hello Sacha, to become famous I would recommend you the 'spatstat' package which is best suited to do this kind of plotting and analysis. You have to install the package and then you can create heatmaps, etc. To plot the x,y coordinates transfer the particle analysis with the selected centroid and area values. Select the values in the ImageJ menu: 'Analyze->Set Measurements...' See video: https://www.youtube.com/watch?v=gUQRqfh7ZNcAfter the transfer (variables ImageWidth and ImageHeight will be available after transfer!) you can plot the points with: library(spatstat) X<- ppp(Particles\$X, Particles\$Y, c(0,ImageWidth), c(0,ImageHeight)) plot.ppp(X,axes=TRUE) In the next example I plot the coordinates like in ImageJ (0,0 coordinates in the upper left) and with custom axes. library(spatstat) xrange <- c(0,ImageWidth) yrange <- c(ImageHeight,0) X<- ppp(Particles\$X, Particles\$Y, c(0,ImageWidth), c(0,ImageHeight)) plot(x = xrange, y = yrange,xlim=c(1,ImageWidth),ylim=c(ImageHeight,1), type = "n", main = "", asp = 1, axes = F, xlab = "x", ylab = "y") plot(X,axes=TRUE,xlim=c(1,ImageWidth),ylim=c(ImageHeight,1),add = T) axis(1) axis(2, las = 2) For a density map you can plot: plot(density(X)) plot(X,add=TRUE) And here you find an example of the mark correlation function: http://www.inside-r.org/packages/cran/spatstat/docs/markcorrFor a marked point pattern (in this example the area): X<- ppp(Particles\$X, Particles\$Y, c(0,ImageWidth), c(0,ImageHeight),marks=Particles\$Area) plot(density(X, weights=Particles\$Area)) Please consult the spatstat documentation for more details. (type 'spatstat' in the texfield of the R-Shell view and then press the ? action button)
Open this post in threaded view
|

## Re: contour map and density map

 In reply to this post by saccente And you can Plot a contour Plot with: contour(density(X, weights=Particles\$Area))