This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to retrieve total gene numbers per cluster

Hi,

I am working 10x single cell data and I am using seurat package.

I am able to get the number of cells per cluster using the following code:

> n_cellsinsamples <- FetchData(seurat_integrated,  vars = "ident") %>%
> dplyr::count(ident) %>% tidyr::spread(ident, n)

But I would like to get the number of genes expressed per cell cluster. Can anyone suggest me how to do this?

Thanks!

seurat r

No need to use 2 different libraries to get the number of cells in each cluster. table(seurat_integrated@meta.data$integrated_snn_res.1.8), where integrated_snn_res.1.8 is the clustering column your Idents(seurat_integrated) points to.

1 answer

HI, I tried to solve myself and here is the code:

cells.use <- WhichCells(object = seurat_integrated, ident = 0) 
 expr <- GetAssayData(object = seurat_integrated, assay = "RNA", slot = "count")[, cells.use] 
 expr <- as(Class = 'matrix', object = expr) 
 expr <- data.frame(rowSums(expr)) %>% filter_all(all_vars(. >0))
 number_of_genes <- nrow(expr)

If any one has some suggestion or comments, please let me know.

Thanks!

Log in to answer this question.