satijalab / seurat

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

How canI remove previously identified VariableFeatures after subsetting my SeuratObj? #9252

Closed yeroslaviz closed 2 months ago

yeroslaviz commented 2 months ago

After running the whole analysis on the complete data set, I need to concentrate the forward analysis on specific clusters. After subsetting the object, I'm trying to remove all unnecessary information from the bigger object, using DietSeurat and manually resetting some parameters.

seu_subset <- subset(x = seuobj, idents = c(1,2,11) )

seu_subset[["RNA"]]$data <- NULL 
seu_subset[["RNA"]]$scale.data <- NULL 

seu_subset <- DietSeurat(seu_subset, assays=c("RNA"), features = NULL, dimreducs = NULL, graphs = NULL, misc = FALSE, scale.data = NULL)

This gives me a new "clean" seurat obj:

An object of class Seurat 
26379 features across 13384 samples within 1 assay 
Active assay: RNA (26379 features, 2000 variable features)
 1 layer present: counts

But I can't get rid of the previously identified HVF. I re-run the workflow

seu_subset <- NormalizeData(seu_subset, normalization.method  ="LogNormalize", scale.factor = 10000) 
seu_subset <- FindVariableFeatures(seu_subset, selection.method = "mean.var.plot", mean.cutoff = c(0.0125, 3), dispersion.cutoff = c(0.5, Inf))

But even though I can see in the plot more than the default 2000 variable features, I don't see it in the object itself

length(VariableFeatures(Merged2_subset0.2))

give me 2000, but the plot gives me many more (s. below):

VariableFeaturePlot(Merged2_subset0.2)

What amI doing wrong?

thanks

Assa

subset_HVF

samuel-marsh commented 2 months ago

Hi,

Not member of dev team but hopefully can be helpful. If you want to remove variable features you can just run:

VariableFeatures(OBJ) <- NULL

If you calculated Variable features using more than one method it's possible that you are pulling data from the wrong slot. You can manually adjust this using the method parameter both when pulling features and plotting.

Best, Sam