Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do_DotPlot Sequential palette, diverging, white on extreme low end #49

Closed
ShashTrip1 opened this issue Jan 3, 2024 · 1 comment
Closed

Comments

@ShashTrip1
Copy link

I am running the following code:

do_DotPlot(alldata,features = c("P2RY12","CX3CR1","TMEM119","CSF1R","CD3E","TNF","TNFSF10","IFNG","GZMA","PRF1","FASLG","NKG7","CD163","TGFB1","IL10","HAVCR2","TIGIT","LAG3","PDCD1","CD274","LAIR1","STAT3","ITGAX","HLA-DRA","B2M","TAPBP","HSPA5","CALR","CIITA","CD14","MRC1","FCGR3A","FCGR1A","ITGAV"),sequential.palette = "RdGy",dot_border = TRUE,scale = TRUE,scale.by = "size")+ theme(axis.text.x = element_text(angle = 90,face = "plain",hjust=1,vjust = 0.5),axis.text.y = element_text(face = "plain"),panel.border = element_rect(colour = "black", fill=NA, size=1),legend.text = element_text(face = "plain"))

and the -2 value is showing as white instead of dark red, this is occur with all the diverging color palettes.

@enblacar
Copy link
Owner

enblacar commented Jan 5, 2024

Hi @ShashTrip1,

Thanks for using my package!

I see where the problems is:

  • You are feeding a diverging palette to sequential.palette parameter. Normally, this should throw an error, but somehow it is not happening. I will fix that for the next update.
  • Since the error is not being called, you actually get the side effect of the diverging palette being treated as sequential, for which I add a white and black end to the palette. That is why you are getting the error.

I did not intend this function to accept diverging palettes, as I thought there was no use case for it. I will implement its usage for the next update. For now, I would suggest you to use a sequential palette.

However, if you really want to use it with a diverging palette, given the side effect, you can just remove the behaviour of adding the white and black end to sequential color palettes with:

options("SCpubr.ColorPaletteEnds" = FALSE)

This should give you the output you want. But please, be mindful that when I update to fix this side effect, this will no longer work. Here is an example:

Current behaviour

options("SCpubr.ColorPaletteEnds" = TRUE)
SCpubr::do_DotPlot(sample, features = Seurat::VariableFeatures(sample)[1:10], sequential.palette = "RdBu")
Screenshot 2024-01-05 at 12 10 26

Hotfix

options("SCpubr.ColorPaletteEnds" = FALSE)
SCpubr::do_DotPlot(sample, features = Seurat::VariableFeatures(sample)[1:10], sequential.palette = "RdBu")
Screenshot 2024-01-05 at 12 10 37

Hope that works! Feel free to reopen the issue if not!

Best,
Enrique

@enblacar enblacar closed this as completed Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants