This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to label metadata of Seurat object based gene read count

I have a scRNA-seq dataset that was mapped to both the mouse and mCMV genomes. All the genes from mCMV begin with "392XXXX" and there are 161 of them

For each cell in the dataset, I want to add a metadata identifier if at least one read was detected from at least one of these genes.

Any tips greatly appreciated!

thanks

seurat scrna-seq

Untested but should work in theory. If you get an error you may need to convert the counts from a sparse to dense matrix with as.matrix.

library("stringr")
library("Seurat")

mCMV_data <- GetAssayData(seu, assay="RNA", slot="counts")
mCMV_data <- mCMV_data[str_starts(rownames(mCMV_data), "392"), ]

seu$mCMVExpr <- rowSums(mCMV_data > 0) > 1

0 answers

No answers yet.

Log in to answer this question.