Answers.Body: <p>If your cell types and sample names are in separate metadata variables attached to the Seurat object, then you can use <code>table</code> to count up the pairings:</p>
  <pre><code>table(pbmc.seurat<span class="math-container">$singler_labels, pbmc.seurat$</span>sample_name)
  </code></pre>
  <p>This will output a matrix containing these counts</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-15T19:39:00.733Z
Answers.LastActivityDate: 2023-02-15T19:39:00.733Z
Answers.UserDisplayName: gringer
Answers.Body: <p>The following package performs this type of analysis and can be directly used on a Seurat object:</p>
  <p>paper: <a href="https://academic.oup.com/bioinformatics/article/38/20/4720/6675456" rel="nofollow noreferrer">propeller: testing for differences in cell type proportions in single cell data</a></p>
  <p>github: <a href="https://github.com/phipsonlab/speckle" rel="nofollow noreferrer">Speckle</a></p>
  <p>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:</p>
  <p><em><strong>celltype, sample, group_to_test</strong></em></p>
  <p>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):</p>
  <pre><code>propel &lt;- propeller(clusters = object@meta.data$celltype, 
                      sample = object@meta.data$sample, 
                      group = object@meta.data$technology)
  </code></pre>
  <p>This will return the statistics: t-test for two groups or ANOVA for multiple testing.</p>
  <p>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 <code>transform</code> you will offcourse have to decide which transformation is applicable to your data.</p>
  <pre><code>getTransformedProps(clusters = object@meta.data$celltype, 
                               sample = object@meta.data$sample, transform=&quot;asin&quot;)
  </code></pre>
  <p>There are a variety of other packages that allow for more complex analysis and a recent benchmark can be found <a href="https://www.biorxiv.org/content/10.1101/2023.02.24.529894v1" rel="nofollow noreferrer">here</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-06T13:22:16.460Z
Answers.LastActivityDate: 2023-03-06T13:22:16.460Z
Answers.UserDisplayName: Macintosh
Body: <p>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.</p>
  <p>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.</p>
  <p>How do I do this?</p>
  <p>Thank you!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-13T15:41:35.047Z
Comments.Text: 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?
Comments.UserDisplayName: Ram RS
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-02-13T15:52:11.520Z
Comments.Text: 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.
Comments.UserDisplayName: Community
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-03-06T14:53:16.027Z
Comments.Text: 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
Comments.UserDisplayName: Macintosh
Tags: <rna-seq><scrnaseq><seurat><single-cell><multi-omics>
Title: How to calculate cell type percentage in every sample
ThreadText: # How to calculate cell type percentage in every sample
  
  (Asked by: username_0 on 2023-02-13)
  
  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!
  
  **Tags:** rna-seq, scrnaseq, seurat, single-cell, multi-omics
  
  > **Comments:**
  > **username_1**: 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?  
  > **username_2**: 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.  
  > **username_3**: 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  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2023-02-15. Score: 1
  
  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
  
  
  ---
  
  ### Answer by username_3 on 2023-03-06. Score: 1
  
  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](https://academic.oup.com/bioinformatics/article/38/20/4720/6675456)
  
  github: [Speckle](https://github.com/phipsonlab/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 = object@meta.data$celltype, 
                      sample = object@meta.data$sample, 
                      group = object@meta.data$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 = object@meta.data$celltype, 
                               sample = object@meta.data$sample, transform="asin")
  
  ```
  
  There are a variety of other packages that allow for more complex analysis and a recent benchmark can be found [here](https://www.biorxiv.org/content/10.1101/2023.02.24.529894v1)
  
  
  ---
  
  