Subset Seurat Object based on metadata
1
0
Entering edit mode
6 months ago
Bine ▴ 90

Good afternoon,

I am trying to filter my Seurat object based on metadata with

Pancreas_Object<- subset(x = Pancreas_Object, subset = sample_type=='solid tumor')

However, I get the following error:

> RNA assay doesn't leave any cells, so it is removed Error in
> subset.Seurat(x = Pancreas_Object, subset = sample_type == "solid
> tumor") :    No cells left in the default assay, please change the
> default assay

I dont understand why it says "RNA assay doesnt leave any cells". I clearly have cells for this sample_type.

There is only one assay ("RNA") no integrated data or similar.

Thank you for any input!

Seurat • 1.3k views
ADD COMMENT
1
Entering edit mode

Hi Bine,

Have you figured out how to solve your problem? I am facing the exact same issue.

Best regards,
Anton

ADD REPLY
0
Entering edit mode

P.S: Please do not add answers unless you're answering the top level question. Instead, use Add Comment or Add Reply as appropriate. I've moved your post to the right location this time, please be more careful in the future.

ADD REPLY
0
Entering edit mode

You can try this-

Idents(Pancreas_Object) <- "sample_type" 
cell_values <- c("solid tumor")
Pancreas_Object_subset <- subset(Pancreas_Object, idents = cell_values, invert = FALSE)
ADD REPLY
0
Entering edit mode

Thank you, but unfortunately I still get the same error:

> Idents(C1Q_Object) <- "sample_type" 
> cell_values <- c("solid tumor")
> Pancreas_Object_subset <- subset(C1Q_Object, idents = cell_values, invert = FALSE)
Error in subset.Seurat(C1Q_Object, idents = cell_values, invert = FALSE) : 
  No cells left in the default assay, please change the default assay
ADD REPLY
0
Entering edit mode
5 weeks ago

That's likely because the rownames in your seurat metadata do not match the colnames of your count matrix

you can compare them with

> colnames(GetAssayData(seurat_object, assay = "RNA", slot = "counts"))
> rownames(seurat_object@meta.data)

Best, Aurel

ADD COMMENT

Login before adding your answer.

Traffic: 2063 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6