text: user6774: I am using Seurat to analyze my single cell data. I have 2 conditions, treated and untreated.  I am trying to create a stacked bar graph in order to show the differences in cell types for each condition but need to collect the percentages of each cluster for the specific cell types. How to I put together a sheet that contains the percentages of each cluster and the make a stacked bar graph of comparison of each condition. 
  
  user4766: pt <- table(Idents(myobj), myobj$orig.ident)
  pt <- as.data.frame(pt)
  pt$Var1 <- as.character(pt$Var1)
  
  ggplot(pt, aes(x = Var2, y = Freq, fill = Var1)) +
    theme_bw(base_size = 15) +
    geom_col(position = "fill", width = 0.5) +
    xlab("Sample") +
    ylab("Proportion") +
    scale_fill_manual(values = brewer.pal(12, "Paired")) +
    theme(legend.title = element_blank())
  
  This shall work. myobj is your seurat object. This is my old code so if I remember correct, orig.ident is your treated and untreated conditions. Idents should give you cell clusters.
  If this does not work, please let me know
  
  user1855: You can access these data from a Seurat object as columns of object@meta.data and tabulate them.
  There are functions such as “propellor” which will also implement this:
  https://github.com/Oshlack/speckle
  Note that a Seurat vignette also explores this topic:
  https://satijalab.org/seurat/archive/v3.0/interaction_vignette.html
  You need to be careful when doing this to ensure different proportions are biological as single cell data is prone to technical errors.
  
original_text: 6774: <p>I am using Seurat to analyze my single cell data. I have 2 conditions, treated and untreated.  I am trying to create a stacked bar graph in order to show the differences in cell types for each condition but need to collect the percentages of each cluster for the specific cell types. How to I put together a sheet that contains the percentages of each cluster and the make a stacked bar graph of comparison of each condition. </p>
   4766: <pre><code>pt &lt;- table(Idents(myobj), myobj<span class="math-container">$orig.ident)
  pt &lt;- as.data.frame(pt)
  pt$</span>Var1 &lt;- as.character(pt$Var1)
  
  ggplot(pt, aes(x = Var2, y = Freq, fill = Var1)) +
    theme_bw(base_size = 15) +
    geom_col(position = "fill", width = 0.5) +
    xlab("Sample") +
    ylab("Proportion") +
    scale_fill_manual(values = brewer.pal(12, "Paired")) +
    theme(legend.title = element_blank())
  </code></pre>
  
  <p>This shall work. <code>myobj</code> is your seurat object. This is my old code so if I remember correct, <code>orig.ident</code> is your treated and untreated conditions. <code>Idents</code> should give you cell clusters.
  If this does not work, please let me know</p>
   1855: <p>You can access these data from a Seurat object as columns of <code>object@meta.data</code> and tabulate them.</p>
  <p>There are functions such as “propellor” which will also implement this:</p>
  <p><a href="https://github.com/Oshlack/speckle" rel="nofollow noreferrer">https://github.com/Oshlack/speckle</a></p>
  <p>Note that a Seurat vignette also explores this topic:</p>
  <p><a href="https://satijalab.org/seurat/archive/v3.0/interaction_vignette.html" rel="nofollow noreferrer">https://satijalab.org/seurat/archive/v3.0/interaction_vignette.html</a></p>
  <p>You need to be careful when doing this to ensure different proportions are biological as single cell data is prone to technical errors.</p>
  