STOmics / SAW

GNU General Public License v3.0
145 stars 34 forks source link

Filtering out small cells in cellcut #160

Closed renli1024 closed 1 month ago

renli1024 commented 1 month ago

Hi,

I’m using SAW 7.1 version, and is there a way in cellcut step to filter out cells based on their size/area? I notice there’s an “area” field in output gef file, but I think it’s better to do filtering during cellcut, so the remaining cells could still be adjusted by cell correct. Thank you so much!

renli1024 commented 1 month ago

Also, is there any unit for the "area" field values in the gef file? Thank you!

Clouate commented 1 month ago

Hi, We regret that no such parameter is currently available, as this threshold is difficult to determine based on different tissue types and staining types. You could use the python package cv2.connectedComponentsWithStats to process 03.register/mask.tif to detect the area of ​​each cell to filter out unwanted cells and output as a new mask file. Then import the new mask to cellcut/cellcorrect step through the -m parameter of singularity saw.sif cellCut cgef and cellCorrect. For the area field in the gef file, the unit is pixel, corresponding to the image pixel unit in register.tif or mask.tif in 03.register directory. When the image registration is accurate, 1 pixel = 1 DNB = 500 nm

renli1024 commented 1 month ago

Thank you so much for your quick response! Regarding the area field, I just checked an official BGI sample C04144D5_v8.0_mouse_brain_Stereo-seq_N_FFPE, and found that the mean area size for adjusted.cell.bin is ~700, and for cell.bin is ~200. If 1 value counts for 500 nm, the mean cell size will be 350 μm and 100 μm respectively. Will that be too large for normal cells?

Clouate commented 1 month ago

Please forgive me for not explaining it completely. Pixel represents the smallest square unit on the image, and its side length is equal to the spacing between two DNBs on the Stereo-seq chip, which is physically 500 nm, therefore the area of one pixel is 0.25 μm^2. So if a cell area contains 700 pixels, then it is physically 175 μm^2, and the diameter is about 15 μm (if it is a round cell)

renli1024 commented 1 month ago

Got it! It's very clear. Thank you!

renli1024 commented 1 month ago

By the way, I found there is an outspread distance parameter -d for cellcorrect, is the unit here also pixel? And how does SAW extend the cell area? Thank you!

Clouate commented 1 month ago

By the way, I found there is an outspread distance parameter -d for cellcorrect, is the unit here also pixel?

Yes, it means the pixels(length) of outspread distance based on cellular contour of cell. e.g. image

renli1024 commented 1 month ago

Understood. Thank you so much!