satijalab / seurat

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

SplitObject of 10x Visium spatial Seurat Object retains all spatial images #9413

Open strawberry098 opened 1 week ago

strawberry098 commented 1 week ago

I have a Seurat Object that contains multiple 10x Visium spatial transcriptomics datasets.

I used SplitObject to split the Seurat Object by sample, but when calling split_seuobj$sample1, the spatial.images still lists all samples, instead of only sample.1

How can I resolve this issue? This is causing some downstream analysis issues.

jdrnevich commented 1 day ago

I had the same issue. Here's how I hacked them to only have 1 image each:

ifnb.list <- SplitObject(temp, split.by = "orig.ident")

#Each one keeps all 4 images:
ifnb.list[[1]]
# An object of class Seurat 
# 12345 features across 2174 samples within 1 assay 
# Active assay: Spatial (12345 features, 0 variable features)
# 4 images present: Uninf_1, Infect_2, Uninf_3, Infect_4

# Keep only images for each one:

for(i in 1:length(ifnb.list)) {
  ifnb.list[[i]]@images <- ifnb.list[[i]]@images[names(ifnb.list)[i]]
}