Entering edit mode
17 months ago
Andy
▴
120
Good afternoon,
I am trying to subset my data, but I meet following error:
subset(data1, idents=cell_values, invert=FALSE)
Error in .subscript.2ary(x, i, j, drop = drop) : subscript out of bounds
I am wondering how to solve the error.
Thanks
Andy
I tried all of the likely ways to get this error that I could think of (passing in logical or numeric vectors for the
idents
arguments with length that doesn't matchnrow(dataframe)
) and couldn't figure out how you got this error. Can we get a reproducible example? Or at least some info about whatdata1
andcell_values
look like? Otherwise best I can do is direct you towards this general and in-depth solution.Hi, thanks for help.
I tried several different ways to solve the problem. I set meta.data as active.ident, but still failed.
Hello,
I am having the same error when I try to subset my Seurat object, both when I try with "cells" or with "idents".
I hope this information can give more insight into solving the error. Thanks for the help!
Ahh I guess you are talking about Seurat's subset function...I'm not great with Seurat but what if you simply tried:
It would be nice to know how you got
cell_values
, but you can check if the cells are in that subset first:In the case not all of them are in there (but maybe a lot of them are?), you could do the following
Let me know if it helped :)
You should have really mentioned Seurat in your post - without it, the questions looks a lot like a generic R question with little to do with bioinformatics. I've added a
seurat
tag to the post now.Ok. Thanks. I will add it.
UPDATE: I have come to realize that my problem arose when I downloaded an RDS file online. In the "count" line, the data represented gene IDs instead of gene names. While attempting to translate the gene IDs to names, I must have made an error, and this is likely the reason for the subset issue.