0

I want to subset my object object based on names in by object, and plot each subset. The subsetting is defined in idents like for example idents ="T-cell" and need to be specified with quotes. How do I set the quotes from the for-loop=?

for (i in names(table(Idents(object))))
{
subset.out <- subset(x = object, idents = "i") #i there is the problem
DimPlot(subset.out)
}

My solution in the end:

ids <- names(table(Idents(object)))

for (i in 1:length(celltypes)) {
  subset.out <- subset(x = object, idents =ids[i])
  print(DimPlot(subset.out))
}
user2300940
  • 2,355
  • 1
  • 22
  • 35
  • 4
    as you are using foreach, why don't you try `subset(object, idents == i)` note that it is `==` and `i` is not quoted – akrun Apr 09 '22 at 18:52
  • 1
    Likely related: https://stackoverflow.com/q/28176650/3358272 (`=` versus `==`). – r2evans Apr 09 '22 at 18:53

0 Answers0