Answers.Body: <p>If you're using a GUI you could select the cells interactively:</p>
  
  <pre><code>plot &lt;- DimPlot(seurat_obj, reduction = "umap")
  </code></pre>
  
  <p>Then select the cells by clicking around them</p>
  
  <pre><code>select.cells &lt;- CellSelector(plot = plot)
  Idents(seurat_obj, cells = select.cells) &lt;- "SubCells"
  </code></pre>
  
  <p>and subset based on these cells</p>
  
  <pre><code>sub_cells &lt;- WhichCells(seurat_obj, idents = "SubCells")
  sub_obj &lt;- subset(seurat_obj, cells = sub_cells)
  </code></pre>
  
  <p>You could then use subobject in your downstream dimplot.</p>
  
  <p>See <a href="https://satijalab.org/seurat/v3.0/visualization_vignette.html" rel="nofollow noreferrer">here</a> for some of the interactive options. I guess you could outright subset on UMAP coordinates, but that may not always be easy if your boundary isn't linear.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-11-20T15:00:06.993Z
Answers.LastActivityDate: 2019-11-20T16:19:55.570Z
Answers.LastEditDate: 2019-11-20T16:19:55.570Z
Answers.UserDisplayName: TW93
Body: <p>I am going to adjust Seurat dimplot in a way avoiding some cells so both my dimplot and heatmap look nice</p>
  
  <p>If you please consider this picture, you would see some cells are far from the clusters so I want to avoid them in dimplot and of course for heatmap (coming from finding markers).</p>
  
  <p>[![enter image description here][1]][1]</p>
  
  <p>Can you suggest me a piece of code doing that?
  Thanks</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-22T17:26:51.463Z
Comments.Text: Answered on GitHub here: https://github.com/satijalab/seurat/issues/2338
Comments.UserDisplayName: TimStuart
Tags: <r><seurat>
Title: Putting cells in Seurat dimplot selectively
ThreadText: # Putting cells in Seurat dimplot selectively
  
  (Asked by: username_0 on 2019-11-19)
  
  I am going to adjust Seurat dimplot in a way avoiding some cells so both my dimplot and heatmap look nice
  
  If you please consider this picture, you would see some cells are far from the clusters so I want to avoid them in dimplot and of course for heatmap (coming from finding markers).
  
  [![enter image description here][1]][1]
  
  Can you suggest me a piece of code doing that?
  Thanks
  
  **Tags:** r, seurat
  
  > **Comments:**
  > **username_1**: Answered on GitHub here: https://github.com/satijalab/seurat/issues/2338  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-11-20. Score: 1
  
  If you're using a GUI you could select the cells interactively:
  
  ```
  plot <- DimPlot(seurat_obj, reduction = "umap")
  
  ```
  
  Then select the cells by clicking around them
  
  ```
  select.cells <- CellSelector(plot = plot)
  Idents(seurat_obj, cells = select.cells) <- "SubCells"
  
  ```
  
  and subset based on these cells
  
  ```
  sub_cells <- WhichCells(seurat_obj, idents = "SubCells")
  sub_obj <- subset(seurat_obj, cells = sub_cells)
  
  ```
  
  You could then use subobject in your downstream dimplot.
  
  See [here](https://satijalab.org/seurat/v3.0/visualization_vignette.html) for some of the interactive options. I guess you could outright subset on UMAP coordinates, but that may not always be easy if your boundary isn't linear.
  
  
  ---
  
  