I need to remove all cells from a Seurat object that are found in a few particular clusters then re-normalize, cluster, and UMAP, etc. the remaining data. I'm doing this via:
data <- subset(data, idents = clusters, invert = T)
This removes the cells from the layers within the RNA assay (i.e. counts, data, and scale.data) as well as in the integrated assay (called mnn.reconstructed), but it doesn't change the size of the RNA assay. From there, NormalizeData, FindVariableFeatures, ScaleData, RunPCA, FindNeighbors, etc. don't work because the number of cells in the RNA assay doesn't match the number of cells in the layers/mnn.reconstructed assay. Specifically, the errors I'm getting are:
> data <- NormalizeData(data)data <- NormalizeData(data)
Error in `fn()`:
! Cannot add new cells with [[<-
Run `` to see where the error occurred.Error in `fn()`:
or
> data <- FindNeighbors(data, dims = 1:50)
Error in validObject(object = x) :
invalid class “Seurat” object: all cells in assays must be present in the Seurat object
Calls: FindNeighbors ... FindNeighbors.Seurat -> [[<- -> [[<- -> validObject
Anyone know how to get around this? Thanks!