satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.3k stars 917 forks source link

Overlay function can not be implemented after integration #9284

Closed MengYunWang closed 2 months ago

MengYunWang commented 2 months ago

Hi,

I was trying to use the Overlay function to crop some parts of the fov. The process is a success on the Seurat object before the integration, but can not be done after the integration (I used harmony):

This is a success:

mouse_905_orig[["AC_left"]] <- Overlay(mouse_905_orig_orig[["x95"]] , lAC_to_crop, invert = FALSE) #x95 is the fov's name; lAC_to_crop is a SpatialPolygons object

This is a failure:

mouse_905_harmony[["AC_left"]] <- Overlay(mouse_905_harmony[["x95"]] ,lAC_to_crop,invert = FALSE)

Error in scan(text = lst[[length(lst)]], quiet = TRUE) : scan() expected 'a real', got 'IllegalArgumentException:' Error in (function (msg) : IllegalArgumentException: point array must contain 0 or >1 elements

I am wondering why is the issue? One compromised way I did this is like below, but i am not sure if it is the same as do the overlay directly on the 'mouse_905_harmony' object?

mouse_905_harmony[["AC_left"]] <- mouse_905_orig[["AC_left"]]

I am using libraries: Seurat V5, R4.3.0, sf 1.0-16. Thank you!

Best, Henrik

MengYunWang commented 2 months ago

additional info:

but if I try to crop the object which was integrated with rpca method, then it is also a success. So I am wondering if there is something special with Harmony method:

mouse_905_integrated_rpca[["AC_left"]] <- Overlay(mouse_905_integrated_rpca[["x95"]] ,lAC_to_crop,invert = FALSE)

MengYunWang commented 2 months ago

I rerun the harmony with normalization.method = "SCT" instead of using assay = "SCT", problem then solved. Seems like it's better to use normalization.method = "SCT" when doing integration. I will close my question. Thanks.