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

FeaturePlot scale changes when put 3 cols #9669

Open
vayac opened this issue Feb 5, 2025 · 1 comment
Open

FeaturePlot scale changes when put 3 cols #9669

vayac opened this issue Feb 5, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@vayac
Copy link

vayac commented Feb 5, 2025

I use FeaturePlot to display gene distribution. To make it clear, I put 3 colors as parameters. #cols = c("lightgrey", "#00ff00", "#ff0000")

It used to work well. But now when I use these parameters, the legend bar changes from (0,3) to (1,2). All the dots there were just red and there's no grey. How do I change the legend bar to be consistent with my previous data?

@vayac vayac added the bug Something isn't working label Feb 5, 2025
@samuel-marsh
Copy link
Collaborator

samuel-marsh commented Feb 6, 2025

Hi,

Not member of dev team but hopefully can be helpful. What version of Seurat was previously working for you to plot? If you know when it was working I can look back. However, providing more than 2 colors traditionally to FeaturePlot caused scale to artificially change to match number of colors and not expression data which makes comparing plots of different genes tricky.

As fyi using the default FeaturePlot in Seurat the gray you are providing as first value gets blended with the others in scale so it can be tricky if you intending gray to be the color for points with no expression.

One solution is from my package scCustomize using FeaturePlot_scCustom this function automatically plots cells with zero expression in light gray and allows for more complex color schemes (and a number of other advantages too; see here for more info: https://samuel-marsh.github.io/scCustomize/articles/Gene_Expression_Plotting.html#featureplot_sccustom-solves-these-issues).

So your code would be:

FeaturePlot_scCustom(obj, features = "GENE", colors_use = c("#00ff00", "#ff0000"))

As final note (and colorblind person) the red green combo you have picked is not very color blind friendly (also doesn't really have great gradient transition) which makes it very hard to tell the difference between the points on the plot.

Best,
Sam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants