Seurat: Delete specific gene

Created on 12 Feb 2020  路  2Comments  路  Source: satijalab/seurat

I want to delete specific gene in Seurat.object. Could anyone tell me how to do so?

I sequenced brain tissue where I found the expression of red blood cell genes. I want to delete those genes. However, it cannot be done by '''Seurat.object <- ScaleData(Seurat.object, vars.to.regress = c('HBB','HBA1','HBA2','HBG2','HBG1','HBD'))'''

Analysis Question

Most helpful comment

@basilkhuder Thanks! Here I modified the code as:

  counts <- GetAssayData(seurat_obj, assay = "RNA")
  counts <- counts[-(which(rownames(counts) %in% c('HBB','HBA1','HBA2','HBG2','HBG1','HBD'))),]
  Patient.object <- subset(seurat_obj, features = rownames(counts))

All 2 comments

I would personally remove those genes from the matrix prior to importing it in Seurat. If that's not an option, you could retrieve the counts from your Seurat object with:

counts <- GetAssayData(seurat_obj, assay = "RNA)

Find out the index of the genes you want removed:

which(rownames(counts == "GENE1")) | rownames(counts == "GENE2")) | which(rownames(counts == "GENE3"))

[1] 19566 19572 14094

Remove them

counts <- counts[-c(19566,19572,14094),]

And then subset your data based upon the genes (row names)

seurat_obj <- subset(seurat_obj, features = rownames(counts)

@basilkhuder Thanks! Here I modified the code as:

  counts <- GetAssayData(seurat_obj, assay = "RNA")
  counts <- counts[-(which(rownames(counts) %in% c('HBB','HBA1','HBA2','HBG2','HBG1','HBD'))),]
  Patient.object <- subset(seurat_obj, features = rownames(counts))
Was this page helpful?
0 / 5 - 0 ratings