satijalab / seurat

R toolkit for single cell genomics
http://www.satijalab.org/seurat
Other
2.29k stars 915 forks source link

DotPlot color of the dot always grey #2342

Closed JihedC closed 4 years ago

JihedC commented 4 years ago

Hello, I am using Seurat since few weeks now and I found it great! I would like to compare the gene expression of clusters I have identified after integration of data from a control and a treated samples. Dotplot would be great to have a normalized gene expression per cluster but I can't make It work as in the example here

This is the code :

DotPlot(sample, features = c("Tcf7", "Cd3e"), cols = c("blue", "red"), dot.scale = 8, split.by = "orig.ident") + RotatedAxis()

and this is the output

Capture d’écran 2019-11-20 à 14 53 32

I would like to have a different color for the control and the stimulated but I can't get it to work. Can someone help me?

Jihed

samuel-marsh commented 4 years ago

Hi Jihed,

Not a member of the Dev team but hopefully this helps. So your example code isn't attempting to do the same thing as the DotPlot in the Vignette you linked which is likely the issue.

In the Vignette: DotPlot(immune.combined, features = rev(markers.to.plot), cols = c("blue", "red"), dot.scale = 8, split.by = "stim") + RotatedAxis() Specifically, the key is the split.by argument. In the Vignette they splitting by the condition from metadata "stim".

You are splitting by "orig.ident" which isn't doing the same thing. If you change split.by to be whatever you have named that information in your metadata slot does that solve the issue?

Best, Sam

JihedC commented 4 years ago

Hi @samuel-marsh ,

Thanks for your quick reply! I have tried to change the split.by argument by sample which is a metadata column indicating whether the cell is coming from an heterozygous or an homozygous sample. And it still doesn't work. :(

DotPlot(test, features = c("Tcf7", "Cd3e"), cols = c("blue", "red"), dot.scale = 8, split.by = "sample") + RotatedAxis()
Capture d’écran 2019-11-21 à 11 15 32

I tried the to split for the violin plot and it works nicely also with split.by = "origine.ident". I don't know why it's not working. Best, Jihed

trueth1206 commented 4 years ago

Hi, you can try to use "-" instead of " " in your cluster name. A cluster name with any "" will result in grey dots (seems a bug...).

satijalab commented 4 years ago

Thanks for pointing this out , we will fix (@timoast)

giovanegt commented 4 years ago

I am facing the same problem described above. Did anybody come up with a way to fix it? @satijalab

mojaveazure commented 4 years ago

This should be fixed in the development version of Seurat. To install the development version of Seurat, please see the instructions here.

JihedC commented 4 years ago

Thanks!

InternetExplorerBoy commented 3 years ago

Dear @timoast, dear @mojaveazure,

I'm posting my issue to this one, since I feel it's closely related to this previous bug.

I am on Seurat Version 4.0.3 and when I plot gene expression using DotPlot() and split by two different experimental conditions, I get grey dots for some of the clusters. Upon closer inspection, I believe that a "+" symbol in cluster names might be the cause of this, similarly as the "_" symbol caused this issue for OP.

DotPlot_Test

Thank you and keep up the great work!

kaushalmb commented 3 years ago

I am still facing this issue. I tried replacing "_" with "-" in the labels on the y axis and it didn't work. What is the solution to this very annoying issue? :(

kasumaz commented 3 years ago

Dear all, I am too facing the same issues.

I am using Seurat ver ‘4.0.4’.

Here is the code I am using:

DotPlot(object = comb6, features = c("Tcf7l2", "Lef1", "Pygo2", "Tle1", "Ctnnb1", "Axin2", "Gsk3b"), group.by = "mycells", split.by = "ages", cols = c("red", "blue", "green", "orange", "purple"))

Has anyone worked out a solution to the problem? I would love to know. Been at it since a day now :P Thanks a lot.

kaushalmb commented 3 years ago

Dear all, I am too facing the same issues.

I am using Seurat ver ‘4.0.4’.

Here is the code I am using:

DotPlot(object = comb6, features = c("Tcf7l2", "Lef1", "Pygo2", "Tle1", "Ctnnb1", "Axin2", "Gsk3b"), group.by = "mycells", split.by = "ages", cols = c("red", "blue", "green", "orange", "purple"))

Has anyone worked out a solution to the problem? I would love to know. Been at it since a day now :P Thanks a lot.

I could not solve the bug but I just went ahead with an alternate visualization of plotting the data in facets instead of the split.by option. The grouped data was plotted in facets. Let me know if you need the code for it.

kasumaz commented 3 years ago

Dear all, I am too facing the same issues. I am using Seurat ver ‘4.0.4’. Here is the code I am using: DotPlot(object = comb6, features = c("Tcf7l2", "Lef1", "Pygo2", "Tle1", "Ctnnb1", "Axin2", "Gsk3b"), group.by = "mycells", split.by = "ages", cols = c("red", "blue", "green", "orange", "purple")) Has anyone worked out a solution to the problem? I would love to know. Been at it since a day now :P Thanks a lot.

I could not solve the bug but I just went ahead with an alternate visualization of plotting the data in facets instead of the split.by option. The grouped data was plotted in facets. Let me know if you need the code for it.

Yes please. This would be so very helpful for anyone else facing the same issues. :) I can inform on how I get a long so that others can see a solution. Thanks a lot.

kaushalmb commented 3 years ago

Dear all, I am too facing the same issues. I am using Seurat ver ‘4.0.4’. Here is the code I am using: DotPlot(object = comb6, features = c("Tcf7l2", "Lef1", "Pygo2", "Tle1", "Ctnnb1", "Axin2", "Gsk3b"), group.by = "mycells", split.by = "ages", cols = c("red", "blue", "green", "orange", "purple")) Has anyone worked out a solution to the problem? I would love to know. Been at it since a day now :P Thanks a lot.

I could not solve the bug but I just went ahead with an alternate visualization of plotting the data in facets instead of the split.by option. The grouped data was plotted in facets. Let me know if you need the code for it.

Yes please. This would be so very helpful for anyone else facing the same issues. :) I can inform on how I get along so that others can see a solution. Thanks a lot.

This is the code for the plot that provides an alternate visualization -

replace <- Vectorize(function(x) {
  gsub("_"," ",x)
  })
_DotPlot(Seuratobject, features = c(< gene names you want to include>), group.by=  "subclass", dot.scale = 30) + RotatedAxis() + labs(y="Class", x = "Genes") + theme(axis.text=element_text(size=13)) + scale_y_discrete(labels = replace) +theme(panel.grid.minor = element_blank(),panel.grid.major = element_line(colour = "gray",linetype = "dashed", size=0.35), panel.border = element_rect(colour = "black", fill=NA, size=2))+ facet_grid(~ unique(Seuratobject@meta.data$condition))

seurat_reply_github

kaushalmb commented 3 years ago

Hi, you can try to use "-" instead of " " in your cluster name. A cluster name with any "" will result in grey dots (seems a bug...).

Could you kindly help me understand how to do that? I tried changing the label names and it did not help.

Kadd-L commented 2 years ago

Hi, I had the same problem earlier, and my code below worked well. So if you split your dataset, you need a multidimensional vector of the color panel.

Set a color panel, row number should be equal to how many splits(conditions) you have.

x1 <- c("Pink", "Blue") x2 <- c("Pink", "Red") panel <- data.frame(x1, x2)

Make a feature index without duplicate

top10 = top10[!duplicated(top10$gene),] select_genes_all = split(top10$gene,top10$cluster) select_genes_all

Dotplot

dotcluster <- DotPlot(object = merge.sp, features=select_genes_all, split.by = 'stim', cols = panel) + theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=0.5, size = 10.5))

Here is my sample figure. I hope it helps.

Screen Shot 2022-10-18 at 14 01 25