This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Removing features from RNA assay in seurat

I have a seurat object which looks like this:

An object of class Seurat 
31061 features across 6471 samples within 2 assays 
Active assay: RNA (31057 features, 0 variable features)
 1 layer present: counts.Gene Expression
 1 other assay present: HTO

I have 2 assays, RNA and HTO. I want to remove 4 genes from RNA assay. These 4 genes are also part of HTO assay. When I use subset like below:

obj <- subset(obj, features = setdiff(rownames(obj), antibody_capture_genes))

this is how my object looks like now:

An object of class Seurat 
31053 features across 6471 samples within 1 assay 
Active assay: RNA (31053 features, 0 variable features)
 1 layer present: counts.Gene Expression

So, I also loose the HTO assay. How can I just remove the genes from the RNA assay?

r seurat sc-rna-seq

I probably wouldn't recommend doing this, but anyway:

You can subset the assay rather than the whole object

test.seurat[["RNA2"]] <- test.seurat[["RNA"]]
features.sub <- sample(Features(test.seurat), 1000, replace = FALSE)
test.seurat[["RNA2"]] <- subset(test.seurat[["RNA2"]], features = features.sub)

DefaultAssay(test.seurat) <- "RNA"
nrow(test.seurat)
> [1] 27132
DefaultAssay(test.seurat) <- "RNA2"
nrow(test.seurat)
> [1] 1000

What happens to the HTO assay?

In your code:

obj[["RNA"]] <- subset(obj[["RNA"]], features = setdiff(rownames(obj[["RNA"]]), antibody_capture_genes))

This shouldn't affect the HTO assay

0 answers

No answers yet.

Log in to answer this question.