Answers.Body: <p>To add the column <code>status</code> can try the following:</p>
  <pre><code>B@meta.data$status &lt;- status[row.names(B@meta.data),]$status
  </code></pre>
  <p>To rename the clusters you can try the following:</p>
  <pre><code>B@meta.data$seurat_clusters &lt;- B@meta.data$status
  </code></pre>
  <p>However, I think the plotting functions in Seurat do not use the cluster information from <code>B@meta.data</code>, rather they use information from <code>B@active.idents</code>.
  So, I guess you have to do the following instead:</p>
  <pre><code>B@active.idents &lt;-  B@meta.data$status
  </code></pre>
  <p>This should work, but, I will verify and update this answer later.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-21T12:03:23.307Z
Answers.Text: Thank you! It worked!  `B@active.idents` worked for renaming the clusters!
Answers.UserDisplayName: Najeha Mohamed
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-20T17:37:27.580Z
Answers.LastActivityDate: 2020-07-20T17:45:46.117Z
Answers.LastEditDate: 2020-07-20T17:45:46.117Z
Answers.UserDisplayName: Ramasamy Kandasamy
Body: <p>I'm working on a Seurat object and want to name the clusters according to 2 values alone (yes/no). So I want to add a new column to metadata and annotate the clusters (UMAP) with it.</p>
  <pre><code>head(B@meta.data)
          orig.ident nCount_RNA nFeature_RNA percent.mito RNA_snn_res.0.6 seurat_clusters
  BC01_02       BC01   999789.2         9225 0.2385090196               6               6
  BC01_03       BC01   999776.9         9568 0.2925109851               6               6
  BC01_04       BC01   999595.1         7482 0.0009888404               6               6
  BC01_05       BC01   999992.0         8301 0.3801925053               6               6
  </code></pre>
  <p>I want to add a new column imported from a csv file that contains the row.names same as the meta.data with the status column as yes and no.</p>
  <pre><code>head(status)
                 status
  BC01_02           yes
  BC01_03           yes
  BC01_04           yes
  BC01_05           yes
  </code></pre>
  <p>After adding the column, I want to name the clusters with yes or no, how is it possible?</p>
  
Tags: <rna-seq><scrnaseq><seurat><sequence-annotation><clustering>
Title: How to add cluster name to metadata in Seurat?
ThreadText: # How to add cluster name to metadata in Seurat?
  
  (Asked by: username_0 on 2020-07-20)
  
  I'm working on a Seurat object and want to name the clusters according to 2 values alone (yes/no). So I want to add a new column to metadata and annotate the clusters (UMAP) with it.
  
  ```
  head(B@meta.data)
          orig.ident nCount_RNA nFeature_RNA percent.mito RNA_snn_res.0.6 seurat_clusters
  BC01_02       BC01   999789.2         9225 0.2385090196               6               6
  BC01_03       BC01   999776.9         9568 0.2925109851               6               6
  BC01_04       BC01   999595.1         7482 0.0009888404               6               6
  BC01_05       BC01   999992.0         8301 0.3801925053               6               6
  
  ```
  
  I want to add a new column imported from a csv file that contains the row.names same as the meta.data with the status column as yes and no.
  
  ```
  head(status)
                 status
  BC01_02           yes
  BC01_03           yes
  BC01_04           yes
  BC01_05           yes
  
  ```
  
  After adding the column, I want to name the clusters with yes or no, how is it possible?
  
  **Tags:** rna-seq, scrnaseq, seurat, sequence-annotation, clustering
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-07-20. Score: 1
  
  To add the column `status` can try the following:
  
  ```
  B@meta.data$status <- status[row.names(B@meta.data),]$status
  
  ```
  
  To rename the clusters you can try the following:
  
  ```
  B@meta.data$seurat_clusters <- B@meta.data$status
  
  ```
  
  However, I think the plotting functions in Seurat do not use the cluster information from `B@meta.data`, rather they use information from `B@active.idents`.
  So, I guess you have to do the following instead:
  
  ```
  B@active.idents <-  B@meta.data$status
  
  ```
  
  This should work, but, I will verify and update this answer later.
  
  > **Comments:**
  > **username_0**: Thank you! It worked!  `B@active.idents` worked for renaming the clusters!  
  
  ---
  
  