Answers.Body: <p>The "identities" can be accessed with the <code>Idents()</code> function in Seurat v3.</p>
  
  <p>You should change <code>cell.num &lt;- table(shox2crepos_mtmg@ident)</code> to </p>
  
  <p><code>cell.num &lt;- table(Idents(shox2crepos_mtmg))</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-29T08:27:32.547Z
Answers.LastActivityDate: 2019-10-29T15:03:11.893Z
Answers.LastEditDate: 2019-10-29T15:03:11.893Z
Answers.UserDisplayName: haci
Body: <p>I was supposed to use the code below to get the number of cells per cluster. The code works with Seurat version 2, but while using version 3 I got the error <code>no slot of name "ident" for this object of class "Seurat"</code>. Does anyone have any idea about how to deal with this?</p>
  
  <pre><code># Calculate number of cells per cluster from object@ident
  
  cell.num &lt;- table(shox2crepos_mtmg@ident)
  
  # Add cell number per cluster to cluster labels
  
  ClusterLabels = paste("Cluster", names(cell.num), paste0("(n = ", cell.num, ")"))
  
  # Order legend labels in plot in the same order as 'ClusterLabels'
  
  ClusterBreaks = names(cell.num)
  
  # Plot tSNE with new legend labels for clusters
  
  TSNEPlot(object = shox2crepos_mtmg, do.return = T) +
    scale_colour_discrete(breaks = ClusterBreaks,
                          labels = ClusterLabels) +
    labs(x = "t-SNE 1",
         y = "t-SNE 2")
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-05T15:08:53.327Z
Comments.Text: The official seurat website (https://satijalab.org/seurat/essential_commands.html) has a `cheat sheet` page with all the different commands between `v2` and `v3` (`Seurat v2.X vs v3.X`).
Comments.UserDisplayName: fra
Tags: <scrnaseq>
Title: How to calculate the number of cells in different cell clusters with Seurat v3?
ThreadText: # How to calculate the number of cells in different cell clusters with Seurat v3?
  
  (Asked by: username_0 on 2019-10-28)
  
  I was supposed to use the code below to get the number of cells per cluster. The code works with Seurat version 2, but while using version 3 I got the error `no slot of name "ident" for this object of class "Seurat"`. Does anyone have any idea about how to deal with this?
  
  ```
  # Calculate number of cells per cluster from object@ident
  
  cell.num <- table(shox2crepos_mtmg@ident)
  
  # Add cell number per cluster to cluster labels
  
  ClusterLabels = paste("Cluster", names(cell.num), paste0("(n = ", cell.num, ")"))
  
  # Order legend labels in plot in the same order as 'ClusterLabels'
  
  ClusterBreaks = names(cell.num)
  
  # Plot tSNE with new legend labels for clusters
  
  TSNEPlot(object = shox2crepos_mtmg, do.return = T) +
    scale_colour_discrete(breaks = ClusterBreaks,
                          labels = ClusterLabels) +
    labs(x = "t-SNE 1",
         y = "t-SNE 2")
  
  ```
  
  **Tags:** scrnaseq
  
  > **Comments:**
  > **username_1**: The official seurat website (https://satijalab.org/seurat/essential_commands.html) has a `cheat sheet` page with all the different commands between `v2` and `v3` (`Seurat v2.X vs v3.X`).  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-10-29. Score: 2 | Accepted answer
  
  The "identities" can be accessed with the `Idents()` function in Seurat v3.
  
  You should change `cell.num <- table(shox2crepos_mtmg@ident)` to
  
  `cell.num <- table(Idents(shox2crepos_mtmg))`
  
  
  ---
  
  