Error with Seurat subset function
0
0
Entering edit mode
3.5 years ago
Lucy ▴ 160

Hi,

I am using the subset function from Seurat to filter the genes present in the Seurat object as follows:

sample <- subset(sample, features = keep)

This works fine in RStudio, however when I run several samples in a loop using the rmarkdown::render() command, my code crashes on the second sample (the first sample runs completely fine) with the error:

Error in data[data_types == l, , drop = FALSE] : 
  object of type 'S4' is not subsettable
Calls: <Anonymous> ... withVisible -> eval -> eval -> Read10X -> lapply -> FUN

I presume it is trying to use the wrong subset function, but I am not sure why and I am also struggling to work out how to explicitly call the Seurat subset function.

I tried SeuratObject::subset() but it says the subset is not exported from the SeuratObject package. I have saved the sample object and it is definitely a Seurat object.

Any help would be greatly appreciated.

Best wishes,

Lucy

Seurat scRNA-seq RNA-seq • 3.5k views
ADD COMMENT
1
Entering edit mode

With the given information this is barely reproducible. Try to put together a minimal working example incl all relevant code especially the rendering command and how you load packages. It can be that you are loading from an environment in RStudio that is not accessable to the rendering command.

ADD REPLY
0
Entering edit mode

Don't use sample as a variable name in R, as there is a sample function in R. showing your keep and sample will be helpful.

ADD REPLY
0
Entering edit mode

Thank you - I think I might have fixed the issue by wrapping Rmarkdown::render inside Rscript_call()

ADD REPLY

Login before adding your answer.

Traffic: 1956 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