How to retrieve total gene numbers per cluster
1
1
Entering edit mode
5 days ago
sam ▴ 30

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 • 182 views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
2
Entering edit mode
4 days ago
sam ▴ 30

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!

ADD COMMENT

Login before adding your answer.

Traffic: 1657 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6