This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Help with subset seurat object by a column in metadata

Hi all,

I try to subset seurat object by sample:

subset(x = combined_seurat_large, subset = sample == "1") Error in .subscript.2ary(x, i, j, drop = drop) : subscript out of bounds

I found other people asked this error on the internet but don't have a clear answer yet. Would you please have a suggestion? The error persists with seurat version 4.3 and 5.1. Thank you so much!

seurat

If sample is one of the column in meta.data, you can subset sample "1" using following commands:

Idents(combined_seurat_large) <- "sample" 
sample <- "1"
subset(skin, idents = sample, invert = FALSE)

Thank you for your reply! Unfortunately, I got the same error message.

Seems that the bug still exists and they are working on it.

...and maybe you should try switch to Scanpy as @stefanonard85 said here: github issue

Thank you for the suggestion. Another way is to recreate the seurat object and use only the sample you want.

0 answers

No answers yet.

Log in to answer this question.