<p>The thing to tweak is the <code>group.by</code> argument of the <code>Dimplot</code> function.</p>
<p>It looks like you've already tried this in your attempts at solving <a href="https://bioinformatics.stackexchange.com/questions/16332/color-by-clusters-and-sampled-in-seurat">a different problem</a>.</p>
<p>The main thing you need to be aware of is that each new clustering needs to be saved as a separate metadata variable in order to do this. As I mentioned in one of my <a href="https://bioinformatics.stackexchange.com/a/16337/73">previous answers</a>, I like to use the <code>[[X]]</code> notation for this:</p>
<pre><code>control[[&quot;predicted.celltype.l1&quot;]] &lt;- a<span class="math-container">$predicted.celltype.l1
control[["predicted.celltype.l2"]] &lt;- a$</span>predicted.celltype.l2
</code></pre>
<p>Then you should be able to use both in the <code>group.by</code> argument:</p>
<pre><code>DimPlot(control, reduction = &quot;umap&quot;, group.by = &quot;predicted.celltype.l1&quot;)
DimPlot(control, reduction = &quot;umap&quot;, group.by = &quot;predicted.celltype.l2&quot;)
</code></pre>

CC BY-SA 4.0
2021-07-15T12:08:41.263Z
2021-07-15T23:05:39.110Z
2021-07-15T23:05:39.110Z
gringer
<p>In Seurat metadata I have assigned cells to some cell types with different resolutions</p>
<p>I have added the cluster identities to the object via <code>Idents</code>:</p>
<pre><code> Idents(control) &lt;- a$predicted.celltype.l1
</code></pre>
<p><a href="https://i.sstatic.net/xoWPp.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xoWPp.png" alt="enter image description here" /></a></p>
<p>I then added another clustering in the same way:</p>
<pre><code> Idents(control) &lt;- a$predicted.celltype.l2
</code></pre>
<p>Dimplot will now show the new identities:</p>
<p><a href="https://i.sstatic.net/XpReN.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/XpReN.png" alt="enter image description here" /></a></p>
<p>How I can ask Dimplot to plot the clustering I want for example if I want to show <code>predicted.celltype.l1</code> again (something like changing the default)?</p>

<scrnaseq><seurat><10x-genomics>
Seurat Dimplot with different clustering IDs
# Seurat Dimplot with different clustering IDs

(Asked by: username_0 on 2021-07-15)

In Seurat metadata I have assigned cells to some cell types with different resolutions
I have added the cluster identities to the object via Idents:
 Idents(control) <- a$predicted.celltype.l1


I then added another clustering in the same way:
 Idents(control) <- a$predicted.celltype.l2

Dimplot will now show the new identities:

How I can ask Dimplot to plot the clustering I want for example if I want to show predicted.celltype.l1 again (something like changing the default)?

**Tags:** scrnaseq, seurat, 10x-genomics

---

## 1 answers

### Answer by username_1 on 2021-07-15. Score: 1 | Accepted answer

The thing to tweak is the group.by argument of the Dimplot function.
It looks like you've already tried this in your attempts at solving a different problem.
The main thing you need to be aware of is that each new clustering needs to be saved as a separate metadata variable in order to do this. As I mentioned in one of my previous answers, I like to use the [[X]] notation for this:
control[["predicted.celltype.l1"]] <- a$predicted.celltype.l1
control[["predicted.celltype.l2"]] <- a$predicted.celltype.l2

Then you should be able to use both in the group.by argument:
DimPlot(control, reduction = "umap", group.by = "predicted.celltype.l1")
DimPlot(control, reduction = "umap", group.by = "predicted.celltype.l2")


---

