satijalab / seurat

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

Fov in Visium data/ BuildNicheAssay #9047

Closed odunola26 closed 1 week ago

odunola26 commented 1 week ago

Hello,

Please , i am trying to run "BuildNicheAssay" on my 10x visium data, but I am having error with the Fov, please can you guide me on how i can access this from my seurat object. here is my code :

Extract spatial coordinates from the centroids object coords <- sample39_obj@images$slice1@boundaries$centroids@coords coords

Ensure the coordinates matrix has proper row names rownames(coords) <- sample39_obj@images$slice1@boundaries$centroids@cells

Create the FOV list with the correct format fov <- list(FOV = coords)

Run BuildNicheAssay sample39_obj <- BuildNicheAssay( object = sample39_obj, fov = fov, group.by = "predicted.celltype", assay = "niche", cluster.name = "niches", neighbors.k = 30, niches.k = 5 )

HERE the error message i got: Error in object[[fov]]: ! 'i' must be a character vector Run rlang::last_trace() to see where the error occurred.

rlang::last_trace() <error/rlang_error> Error in object[[fov]]: ! 'i' must be a character vector

Thank you. Odunola

dcollins15 commented 1 week ago

The fov parameter just takes the name of the FOV instance stored in your object - in your case, you just need to do:

sample39_obj <- BuildNicheAssay(
    object = sample39_obj,
    fov = "fov",
    group.by = "predicted.celltype",
    assay = "niche",
    cluster.name = "niches",
    neighbors.k = 30,
    niches.k = 5
)
odunola26 commented 1 week ago

Thanks @dcollins15

fov didn´t work. I tried with 'slice1' and it worked.

thank you.