Entering edit mode
2.7 years ago
learner-MD
▴
30
After clustering of approx. 25,000 cells from 2 different conditions, I'm doing DEG analysis via edgeR. One of the things I'm trying to do after subsetting my cluster of interest is to only include genes with non-zero expression in at least 5% off cells in that cluster for the DEG analysis. I've done the below to include genes that are expressed in at least 1 cell before converting the cell x gene table into a sample x gene table for edgeR:
new_object <- subset(seurat_object, idents = "cluster_of_interest")
counts <- GetAssayData(object = new_object, slot = "counts", assay = "RNA")
nonzero <- counts >0
keep_genes <- Matrix::rowSums(nonzero) >= 1
filtered_counts <- counts[keep_genes,]
filtered_object <- CreateSeuratObject(filtered_counts, meta.data = new_object@meta.data)
Any suggestions on adjusting the script to include only genes with non-zero expression in 5% or more of cells? Thanks in advance!
Something like this (not tested)?