Originally posted by **An17aV0** February 12, 2024
Hello everyone!
I would like to subset my data based on the genes in the 10X gene panel and my custom gene panel and analyze them separately. I am using the subset function like this xenium.obj.subset <- subset(xenium.obj, features = keep.genes)
The number of features (genes) is reduced after subsetting but it appears the expression data and coordinates are still present in the new object.
Below is a reproducible example where I am removing 4 genes from the "mouse-brain-10x-genomics-xenium-in-situ " and then plot these 4 genes as molecules in ImageDimPlot before and after subsetting. The plots look basically the same although after subsetting these 4 features should not be present anymore. I also get a couple of warnings while subsetting
such as : 1: Not validating FOV objects 2: Not validating Centroids objects ... 9: Not validating Seurat objects
1.) How do I accurately subset the SeuratObject and resolve those warnings?
2.) On a side note, how do I deal with the signal detected outside the tissue (as visible in the Images below)?
Thank you, any help is very much appreciated.
Data and most code from here: https://satijalab.org/seurat/articles/seurat5_spatial_vignette_2#mouse-brain-10x-genomics-xenium-in-situ
wget https://cf.10xgenomics.com/samples/xenium/1.0.2/Xenium_V1_FF_Mouse_Brain_Coronal_Subset_CTX_HP/Xenium_V1_FF_Mouse_Brain_Coronal_Subset_CTX_HP_outs.zip
unzip Xenium_V1_FF_Mouse_Brain_Coronal_Subset_CTX_HP_outs.zip
### Load the Xenium data
xenium.obj <- LoadXenium("Xenium_V1_FF_Mouse_Brain_Coronal_Subset_CTX_HP_outs", fov = "fov")
Output: 10X data contains more than one type and is being returned as a list containing matrices of each type.
Output: Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')
### Remove cells with 0 counts
xenium.obj <- subset(xenium.obj, subset = nCount_Xenium > 0)
Output: Warning messages:
#1: Not validating FOV objects
#2: Not validating Centroids objects
[...]
#9: Not validating Seurat objects
dim(xenium.obj) # [1] 248 36553
### Remove 4 genes
molecules.to.remove = c("Gad1", "Sst", "Pvalb", "Gfap")
all.features <-Features(xenium.obj) # grab all genes from the Seurat object
length(all.features) # [1] 248
keep.genes <- all.features[!all.features %in% molecules.to.remove]
length(keep.genes) # [1] 244
### Subset Seurat object
xenium.obj.subset <- subset(xenium.obj, features = keep.genes)
Output: Warning messages:
#1: Not validating FOV objects
#2: Not validating Centroids objects
[...]
#9: Not validating Seurat objects
dim(xenium.obj.subset) # [1] 244 36553
### Plot data before and after subsetting
plot.xenium.obj <- ImageDimPlot(xenium.obj, fov = "fov", molecules = c("Gad1", "Sst", "Pvalb", "Gfap"), nmols = 20000)+ggtitle("Before")
plot.xenium.obj.subset <- ImageDimPlot(xenium.obj.subset, fov = "fov", molecules = c("Gad1", "Sst", "Pvalb", "Gfap"), nmols = 20000) +ggtitle("After subsetting")
ggarrange(plot.xenium.obj, plot.xenium.obj.subset)
Hi, this can help I hope, though it's a temporary solution. Also check this discussion #7462
this would be the run:
xenium.obj.subset <- subset_opt(xenium.obj, features = keep.genes)
Discussed in https://github.com/satijalab/seurat/discussions/8459