<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>

CC BY-SA 4.0
2019-11-20T15:00:06.993Z
2019-11-20T16:19:55.570Z
2019-11-20T16:19:55.570Z
TW93
<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>

CC BY-SA 4.0
2019-11-22T17:26:51.463Z
Answered on GitHub here: https://github.com/satijalab/seurat/issues/2338
TimStuart
<r><seurat>
Putting cells in Seurat dimplot selectively
# 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 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.


---

