STUtility
STUtility copied to clipboard
spot coord problem
Hi Joe,
I’ve trying to extract the spot coordinates from Staffli object in order to integrate single-cell RNA-seq with Spatial data.
I gotta the x and y by this data.frame(GetStaffli(A1_ST)[[]][,c(1,2)]),
I run my own code; the plot looks like this:
If I use ST.FeaturePlot, plot looks like this
The image generated by ST.FeaturePlot is correct since it’s the same as CellRanger. But image on my codes is upside down. I want to figure out what I did is wrong, if I pick up the wrong coordinate value? Would you please advise? Thanks
Hi @mimisikai,
The coordinates you are using are not the same ones used by ST.FeaturePlot
. It uses either the pixel_x
, pixel_y
coordinates or warped_x
, warped_x
coordinates if the images have been processed. If you want to use these coordinates, you can just do something like:
xy <- GetStaffli(A1_ST)@meta.data[, c("pixel_x", "pixel_y")]
Regardless of what coordinates you use, the y-axis goes from top to bottom. If you're using ggplot2
for example, the y-axis goes from bottom to top, so you need to invert the y axis to get the correct orientation. This can for example be done using scale_y_reverse()
. Alternatively, you can invert the y-axis values like this: y_inv <- maxy - y
/Ludvig