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!
• 1,536 views
•
link
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!
• 0 views
•
link
Log in to answer this question.
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), whereintegrated_snn_res.1.8is the clustering column yourIdents(seurat_integrated)points to.