I have a Seurat object (metadata) with the single R samples consisting of cell types and sample types columns. I am trying to make a table that has a sample and percentage of cell types for each sample so that I can run a t-test across the samples that came out of 3 prime vs multi-omics.

I have a seuratobject meta data with singler_labels (cell labels like chondrocytes, astrocytes, macrophage...), sample names (S0030, S0031, S0032.....), cell id/barcodes, and everything a seurat object has. I want to make a table with samples and percent of cell types per sample just to see what sample has what percent types of cells.

How do I do this?

Thank you!

  • $\begingroup$ We can't really help you out without looking at your Seurat object. Can you show us what all the metadata in the object looks like? $\endgroup$
    – Ram RS
    Feb 13 at 15:41
  • $\begingroup$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. $\endgroup$
    – Community Bot
    Feb 13 at 15:52
  • $\begingroup$ Hi, do you have replicates for each condition you want to test? Based on your short description I assume you have but it would be useful to specifically mention this. Be careful when comparing such data because proportions are extremely variable from run to run $\endgroup$
    – Macintosh
    Mar 6 at 14:53

2 Answers 2


If your cell types and sample names are in separate metadata variables attached to the Seurat object, then you can use table to count up the pairings:

table(pbmc.seurat$singler_labels, pbmc.seurat$sample_name)

This will output a matrix containing these counts


The following package performs this type of analysis and can be directly used on a Seurat object:

paper: propeller: testing for differences in cell type proportions in single cell data

github: Speckle

You mention that you would like to do some statistics so keep in mind that this requires replicated measurements to handle the large variability in proportions between samples. Your metadata should contain:

celltype, sample, group_to_test

once the package is installed you can simply run the propeller function and set group to technology (in your post you mention you want to evaluate 3' vs multi-omics):

propel <- propeller(clusters = [email protected]$celltype, 
                    sample = [email protected]$sample, 
                    group = [email protected]$technology)

This will return the statistics: t-test for two groups or ANOVA for multiple testing.

The following function will return the transformed proportions that can then be used in limma for example to test for more complex designs or simple sample-wise plotting using ggplot. For transform you will offcourse have to decide which transformation is applicable to your data.

getTransformedProps(clusters = [email protected]$celltype, 
                             sample = [email protected]$sample, transform="asin")

There are a variety of other packages that allow for more complex analysis and a recent benchmark can be found here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.