Reputation: 25
Dear experts worldwide,
Hello, I am using Seurat to analyze integrated single-cell RNA-seq data. I confirmed the default color scheme of Dimplot like the described below.
show_col(hue_pal()(16))
But I wanted to change the current default colors of Dimplot. So, I tried it by the comment below. It successfully changed colors in Dimplot, but this changed color palette is not applied to downstream analysis (such as cluster labeling bar in DoHeatmap..).
DimPlot(object = Integrateddata, reduction = 'umap',
group.by = 'seurat_clusters', pt.size = 1, label=FALSE,
cols = c('0'='#F68282','4'='#31C53F','8'='#1FA195','6'='#B95FBB','3'='#D4D915',
'7'='#28CECA','1'='#ff9a36','2'='#2FF18B','10'='#aeadb3','11'='#faf4cf',
'5'='#CCB1F1','9'='#25aff5','12'='#A4DFF2','15'='#4B4BF7','13'='#AC8F14',
'14'='#E6C122'))
Is there any way to change the default color scheme of Dimplot and apply it to all the downstream analysis?
Thanks!
Upvotes: 1
Views: 24735
Reputation: 3134
The problem seems to be DimPlot(cols=)
relies on the names in the named character vector of colors, whereas DoHeatmap(group.colors=)
relies on their order. So you just need to order them by name, and the color scheme should be consistent:
my_seurat <- subset(initial_object, idents = 1:16)
levels(Idents(my_seurat))
my_cols <- c('3'='#F68282','15'='#31C53F','5'='#1FA195','1'='#B95FBB','13'='#D4D915',
'14'='#28CECA','9'='#ff9a36','8'='#2FF18B','11'='#aeadb3','6'='#faf4cf',
'2'='#CCB1F1','12'='#25aff5','7'='#A4DFF2','4'='#4B4BF7','16'='#AC8F14',
'10'='#E6C122')
my_cols2 <- my_cols[order(as.integer(names(my_cols)))]
scales::show_col(my_cols2)
DimPlot(my_seurat,
cols = my_cols2, label=TRUE , repel=TRUE)
DoHeatmap(my_seurat,
features = c("gene1", "gene2"),
group.colors = my_cols2)
Upvotes: 2