Body: <p>I have number of cells in three cell types T, B, M in a Seurat object</p>
  <p>For two groups of patients, cancers and controls like</p>
  <pre><code>&gt; table(Idents(pbmc), pbmc$samples)
     
      PN0252_0001 PN0252_0002 PN0252_0003 PN0252_0004 PN0252_0005 PN0252_0006 PN0252_0008
    T        3550         568         136         268        1835           2        1678
    B         136         129          11          25         133           0         203
    M         120          22          18          26         159           0          59
  &gt; dput(table(Idents(pbmc), pbmc$samples))
  structure(c(3550L, 136L, 120L, 568L, 129L, 22L, 136L, 11L, 18L, 
  268L, 25L, 26L, 1835L, 133L, 159L, 2L, 0L, 0L, 1678L, 203L, 59L
  ), .Dim = c(3L, 7L), .Dimnames = structure(list(c(&quot;T&quot;, &quot;B&quot;, &quot;M&quot;
  ), c(&quot;PN0252_0001&quot;, &quot;PN0252_0002&quot;, &quot;PN0252_0003&quot;, &quot;PN0252_0004&quot;, 
  &quot;PN0252_0005&quot;, &quot;PN0252_0006&quot;, &quot;PN0252_0008&quot;)), .Names = c(&quot;&quot;, 
  &quot;&quot;)), class = &quot;table&quot;)
  &gt; 
  </code></pre>
  <p>Patients <code>PN0252_0001</code>, <code>PN0252_0002</code>, <code>PN0252_0003</code>, <code>PN0252_0004</code> are controls</p>
  <p>and <code>PN0252_0005</code>, <code>PN0252_0006</code>, <code>PN0252_0008</code> are cancers</p>
  <p>I want to look at the difference of the proportion of cells in each cell type between cancer and control</p>
  <p>But I am confused for getting proportion should I divide the number of cells on total cells in the object or total cells in each group</p>
  <p>Basically I need a box plot like although here numbers are not correct</p>
  <p><a href="https://i.sstatic.net/ht4k6.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ht4k6.jpg" alt="enter image description here" /></a></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-29T19:40:24.130Z
Comments.Text: This looks like a ggplot with a facet added to it. What have you tried?
Comments.UserDisplayName: Ram RS
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-30T08:34:32.750Z
Comments.Text: What I plotted here is what I have tried but I am not sure about the proportions
Comments.UserDisplayName: Mahta Mira
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-30T10:37:38.813Z
Comments.Text: Your boxplot seems correct. What do you think is wrong about it?
Comments.UserDisplayName: story
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-30T20:19:55.113Z
Comments.Text: I don't know proportion of T cells for example, I should divide the number of T cells in each patients on the total number of cells or total cells in controls and cancers separately
Comments.UserDisplayName: Mahta Mira
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-30T21:55:16.663Z
Comments.Text: The answer to that depends on the question you're asking and what you wish to showcase. In any case, only you can answer it, we can't do that for you.
Comments.UserDisplayName: Ram RS
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-07-31T10:06:29.253Z
Comments.Text: Ram RS as always your comments are extremely helpful . Thanks a million
Comments.UserDisplayName: Mahta Mira
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-05T09:02:29.463Z
Comments.Text: @mahta-mira, are you able to write up your solution as an answer, then mark it as a selected answer? This will help the StackExchange bots work out what's going on.
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-05T10:09:10.150Z
Comments.Text: At the moment I am not certain if my solution is correct :(
Comments.UserDisplayName: Mahta Mira
Tags: <scrnaseq><seurat><10x-genomics>
Title: Making a box plot of the proportion of cells in each cell types in two groups
ThreadText: # Making a box plot of the proportion of cells in each cell types in two groups
  
  (Asked by: username_0 on 2021-07-29)
  
  I have number of cells in three cell types T, B, M in a Seurat object
  
  For two groups of patients, cancers and controls like
  
  ```
  > table(Idents(pbmc), pbmc$samples)
     
      PN0252_0001 PN0252_0002 PN0252_0003 PN0252_0004 PN0252_0005 PN0252_0006 PN0252_0008
    T        3550         568         136         268        1835           2        1678
    B         136         129          11          25         133           0         203
    M         120          22          18          26         159           0          59
  > dput(table(Idents(pbmc), pbmc$samples))
  structure(c(3550L, 136L, 120L, 568L, 129L, 22L, 136L, 11L, 18L, 
  268L, 25L, 26L, 1835L, 133L, 159L, 2L, 0L, 0L, 1678L, 203L, 59L
  ), .Dim = c(3L, 7L), .Dimnames = structure(list(c("T", "B", "M"
  ), c("PN0252_0001", "PN0252_0002", "PN0252_0003", "PN0252_0004", 
  "PN0252_0005", "PN0252_0006", "PN0252_0008")), .Names = c("", 
  "")), class = "table")
  > 
  
  ```
  
  Patients `PN0252_0001`, `PN0252_0002`, `PN0252_0003`, `PN0252_0004` are controls
  
  and `PN0252_0005`, `PN0252_0006`, `PN0252_0008` are cancers
  
  I want to look at the difference of the proportion of cells in each cell type between cancer and control
  
  But I am confused for getting proportion should I divide the number of cells on total cells in the object or total cells in each group
  
  Basically I need a box plot like although here numbers are not correct
  
  [![enter image description here](https://i.sstatic.net/ht4k6.jpg)](https://i.sstatic.net/ht4k6.jpg)
  
  **Tags:** scrnaseq, seurat, 10x-genomics
  
  > **Comments:**
  > **username_1**: This looks like a ggplot with a facet added to it. What have you tried?  
  > **username_0**: What I plotted here is what I have tried but I am not sure about the proportions  
  > **username_2**: Your boxplot seems correct. What do you think is wrong about it?  
  > **username_0**: I don't know proportion of T cells for example, I should divide the number of T cells in each patients on the total number of cells or total cells in controls and cancers separately  
  > **username_1**: The answer to that depends on the question you're asking and what you wish to showcase. In any case, only you can answer it, we can't do that for you.  
  > **username_0**: username_1 as always your comments are extremely helpful . Thanks a million  
  > **username_3**: @username_0-username_0, are you able to write up your solution as an answer, then mark it as a selected answer? This will help the StackExchange bots work out what's going on.  
  > **username_0**: At the moment I am not certain if my solution is correct :(  
  
  ---
  
  ## 0 answers
  
  