STUtility icon indicating copy to clipboard operation
STUtility copied to clipboard

spot coord problem

Open joe-jhou2 opened this issue 2 years ago • 1 comments

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: image001

If I use ST.FeaturePlot, plot looks like this image003

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

joe-jhou2 avatar May 27 '22 13:05 joe-jhou2

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

ludvigla avatar Jun 01 '22 08:06 ludvigla