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

enter image description here

I then added another clustering in the same way:

 Idents(control) <- a$predicted.celltype.l2

Dimplot will now show the new identities:

enter image description here

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


1 Answer 1


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.