4

I know that I can do subsetting on just one gene in Seurat:

seurat_subset <- SubsetData(seurat_object, subset.name = neuron_ids[1], accept.low = 0.1)

However, I want to subset on multiple genes. Is there a way to do that? I just do not want to do manual subsetting on 10 genes, then manually getting @data matrix from each subset, and recreating seurat object afterwards.

Kohl Kinning
  • 1,149
  • 6
  • 26
Nikita Vlasenko
  • 2,558
  • 3
  • 26
  • 38

1 Answers1

6

I was able to achieve this in the following way:

require(data.table)
cell_names <- vector(mode="character")
for (i in 1:length(neuron_ids)) {
  seurat_subset <- SubsetData(seurat_object, subset.name = neuron_ids[i], accept.low = 0.1)
  genes <- colnames(seurat_subset@data)
  cell_names <- c(cell_names, genes[! genes %chin% cell_names])
}
seurat_subset <- SubsetData(seurat_object, cells.use = cell_names)

Would be interesting to know if Seurat provides such functionality out of the box.

Devon Ryan
  • 19,602
  • 2
  • 29
  • 60
Nikita Vlasenko
  • 2,558
  • 3
  • 26
  • 38
  • In Seurat V3 you should use seurat_subset <- SubsetData(seurat_object, cells = cell_names) as cells.use is no longer supported. – zdebruine Nov 15 '19 at 19:36