Answers.Body: <p>It's possible that the original identities are encoded in the Seurat object under the name <code>orig.ident</code>.</p>
  <pre><code>old.cluster.ids &lt;- pbmc$orig.ident
  </code></pre>
  <p>I prefer explicitly creating a new named metadata value in the Seurat object for each new feature I want to add, including the initial clusters:</p>
  <pre><code>pbmc<span class="math-container">$seurat.clusterID &lt;- Idents(pbmc)
  pbmc$</span>cluster.names &lt;- new.cluster.ids
  </code></pre>
  <p>More details about identity modifications can be found here:</p>
  <p><a href="https://satijalab.org/seurat/articles/essential_commands.html" rel="nofollow noreferrer">https://satijalab.org/seurat/articles/essential_commands.html</a></p>
  <p>Most Seurat functions allow you to specify the identity using the <code>ident</code> parameter, which means you can often create workflows that don't need to ever explicitly change the default identity.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-04-26T21:50:09.270Z
Answers.LastActivityDate: 2024-04-26T21:50:09.270Z
Answers.UserDisplayName: gringer
Body: <p>I am analysing the scRNA-seq data using Seurat, in the annotation step, I change the idents of cell manually using the function <code>RenameIdents</code>:</p>
  <pre class="lang-r prettyprint-override"><code>new.cluster.ids &lt;- c(&quot;Naive CD4 T&quot;, &quot;CD14+ Mono&quot;, &quot;Memory CD4 T&quot;, &quot;B&quot;, &quot;CD8 T&quot;, &quot;FCGR3A+ Mono&quot;,
      &quot;NK&quot;, &quot;DC&quot;, &quot;Platelet&quot;)
  names(new.cluster.ids) &lt;- levels(pbmc)
  pbmc &lt;- RenameIdents(pbmc, new.cluster.ids)
  </code></pre>
  <p>Now I want to get back to the original indent which uses number such as 0 1 2 3...</p>
  
Tags: <scrnaseq><seurat>
Title: After changing the idents of cells in seurat, how can I get back to original ident?
ThreadText: # After changing the idents of cells in seurat, how can I get back to original ident?
  
  (Asked by: username_0 on 2024-04-25)
  
  I am analysing the scRNA-seq data using Seurat, in the annotation step, I change the idents of cell manually using the function `RenameIdents`:
  
  ```r
  new.cluster.ids <- c("Naive CD4 T", "CD14+ Mono", "Memory CD4 T", "B", "CD8 T", "FCGR3A+ Mono",
      "NK", "DC", "Platelet")
  names(new.cluster.ids) <- levels(pbmc)
  pbmc <- RenameIdents(pbmc, new.cluster.ids)
  
  ```
  
  Now I want to get back to the original indent which uses number such as 0 1 2 3...
  
  **Tags:** scrnaseq, seurat
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-04-26. Score: 3 | Accepted answer
  
  It's possible that the original identities are encoded in the Seurat object under the name `orig.ident`.
  
  ```
  old.cluster.ids <- pbmc$orig.ident
  
  ```
  
  I prefer explicitly creating a new named metadata value in the Seurat object for each new feature I want to add, including the initial clusters:
  
  ```
  pbmc$seurat.clusterID <- Idents(pbmc)
  pbmc$cluster.names <- new.cluster.ids
  
  ```
  
  More details about identity modifications can be found here:
  
  <https://satijalab.org/seurat/articles/essential_commands.html>
  
  Most Seurat functions allow you to specify the identity using the `ident` parameter, which means you can often create workflows that don't need to ever explicitly change the default identity.
  
  
  ---
  
  