Hi all!
I am working with a single-cell RNA seq dataset from 10x, and I processed my data using Seurat. I want to show the cell type frequency between two different conditions (patients vs control). How can I calculate the frequency of each cell type and compare it between my patients and controls? I have the column in my data with sample_id and condition column.
I used the following code, and I think it gives me the number of cell types per group:
table(harmonized_seurat@meta.data$cell_type, harmonized_seurat@meta.data$condition)
#(just an example of how my data looks like):
patient Control
Astrocytes 157 111
Endothelial cells 12 16
Excitatory neurons 24 41
Inhibitory neurons 75 90
Microglia 40 15
Neurons 45 39
Is it the right way to get the number of cells per different conditions?
I feel like with this code, I am getting the number of cells per group. How do I calculate the fraction of cells between two groups? Then, which statistical test must I use to see if the difference in each fraction is significant between two groups (e.g. if the difference in the fraction of astrocytes is significant between patient and control)?
Many thanks in advance!
For me scProportionTest library does the trick.