Oh thank you, I didn't knew the "order" parameter worked on the colors too, this is perfect!
Hello,
I want to show on my UMAP, using the DimPlot() function, the same colors on the text labels as the cluster colors. If I set up the same colors in the same order as the levels of my idents, the colors do not correspond at all, I guess the order in which the labels are organised inside the DimPlot() are not the same as the levels of the identities which are given for coloring the cells.
This is my code:
DimPlot(S2, label = T, repel = T, cols = list, label.size = 5, pt.size = 1, label.box = F, label.color = list)
Is there a way to make the colors coincide?
I also opened an github issue on this subject here
I'm sure it's something really obvious to do but I can't find it ...
Thank you!

1 answer
Bit of an oversight. Try:
DimPlot(S2, label = T, repel = T, cols = list, label.size = 5, pt.size = 1,
label.box = F, label.color = list, order = unique(S2$orig.ident))
Should get the colors to match up, though the order of the legend will change. Ultimate issue is that it's plotting whatever data comes first in the matrix whereas the labels are being tossed on centroids of the respective group, not necessarily in the same order.
Log in to answer this question.
What happens if you don't pass the
label.colorargument?The labels stay black
I think the GitHub issue is the place to watch - the source code is too complicated for me to suggest a workaround, maybe the developers can add an option or suggest a quickfix.
What does
listcontain? Also, consider not naming variableslistgiven that thelist()function exists.I wrote "list" just for the example, my variable is called differently.
It contains a list of colors
I also tried formatting the list by specifying the cluster name with its color name, but it's ineffective, like this: