Cell tracking graph with R


I’m relatively new to R, so it might be trivial for some users but I’m a bit lost.
I did a cell tracking workflow using TrackMate (on ImageJ). I ended up with a table of x and y positions of cells for each time points. I wanted to draw a graph representing the displacement of cells in a centred coordinates grid. (as the Ibidi chemotaxis and cell migration tool).

I first centred the x and Y positions of my cells relative to 0. And ended with a table were “track ID means= the name of 1 path”, “frame=time points”, and X and Y positions. All classified by conditions (CTRL vs siRNA)

I now have some trouble in making the graph, the best that I could get is a scatter plot of all the positions colored by conditions.
here is what I did :

testgraph<-ggscatter(F_NEWPOS, x=“POSITION_XN”, y=“POSITION_YN”, color=“CONDITIONS”,
fill=“CONDITIONS”, palette = c(“black”, “red”), alpha=0.5)+
geom_hline(yintercept = 0, color = “black”) +
geom_vline(xintercept = 0, color = “black”)

What I want thought, is drawing “the path” ie connecting between the points of the same path (ie same Track ID).
I tried by adding lines or changing the plot to ggline but the best that I’m getting is weird point connection between same frames. And if I try changing and filtering by “TRACK_ID” I get the error message :
“Continuous value supplied to discrete scale”
Which I can understand but don’t know what to change.

Hope that some of you will have suggestions
Thank you in advance !

I think you can adapt some examples found, e.g., here to visualize movements (scroll down to the ggplot example in 5.2):


For more inspiration (or transpiration), see:

For ggplot see also the online book:


Oh YES ! thank you soo much it worked !!!
for anyone that might be interested in the future here is what worked for me :

Trackgraph<-ggplot(F_NEWPOS, aes(x=POSITION_XN, y=POSITION_YN, group=TRACK_ID_all, col=CONDITIONS)) +

Ah, all this time I was very close.
Thanks again !