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() with split.by does not seem to have the same scaling for all subplots #5243

Closed
abayegan opened this issue Oct 29, 2021 · 12 comments
Labels
bug Something isn't working

Comments

@abayegan
Copy link

# insert reproducible example here
@abayegan abayegan added the bug Something isn't working label Oct 29, 2021
@abayegan
Copy link
Author

I believe the scales in different feature subplots with split.by are not the same which might be misleading especially that the scales are hidden by default. For instance running
p <- FeaturePlot(obj,features,reduction = 'umap',split.by = "condition")
gives the following plot for my data:
image

but running:
for(i in 1:3){p[[i]] <- p[[i]]+theme_void()} p
yields:
image

As you can see the scale of the middle plot is from (0,125) while the other two are from (0-80) so the colors are not comparable. This is not an extreme case but still not accurate.

@samuel-marsh
Copy link
Collaborator

Hi,

Not member of dev team but hopefully can be helpful. What version of Seurat are you using? This issue was addressed in release 3.2.3 (https://github.com/satijalab/seurat/blob/master/NEWS.md#seurat-323---2020-12-14).

Best,
Sam

@abayegan
Copy link
Author

Hi,

Not member of dev team but hopefully can be helpful. What version of Seurat are you using? This issue was addressed in release 3.2.3 (https://github.com/satijalab/seurat/blob/master/NEWS.md#seurat-323---2020-12-14).

Best, Sam

Thank you @samuel-marsh! I was not aware of the keep.scale parameter.

@abayegan
Copy link
Author

abayegan commented Oct 29, 2021

Setting keep.scale="all" unifies the scales in my specific example with only one feature

@samuel-marsh
Copy link
Collaborator

Are you plotting more than one gene/feature? The default should keep scale the same within feature when split. Also be advised that setting to all may result in suboptimal scales when plotting multiple features

@abayegan abayegan reopened this Oct 29, 2021
@abayegan
Copy link
Author

Are you plotting more than one gene/feature? The default should keep scale the same within feature when split. Also be advised that setting to all may result in suboptimal scales when plotting multiple features

I am using Seurat 4.0.3 . That does not seem to be the case. By default the splits have different scales even for the same feature as you can see in my example. It should not be the case according to the documentation here.

As you mentioned setting keep.scale="all" does not seem reasonable to be applied to more than one feature.

@samuel-marsh
Copy link
Collaborator

samuel-marsh commented Oct 29, 2021

hmmm actually you're right... Something must have gotten lost in recent versions. Hopefully devs can chime in here.

Reproducible example below.

pbmc <- pbmc3k.SeuratData::pbmc3k.final
pbmc <- UpdateSeuratObject(pbmc)

[email protected]$test[[email protected]$seurat_annotations == "B"] <- "Group1"
[email protected]$test[[email protected]$seurat_annotations == "NK"] <- "Group2"

pbmc_subset <- subset(x = pbmc, idents = c("B", "NK"))

FeaturePlot(object = pbmc_subset, features = "MS4A1")
FeaturePlot(object = pbmc_subset, features = "MS4A1", split.by = "test") & theme(legend.position = "right")

image

*Edit: @andrewwbutler tagging you since you helped with original PR. Thanks!!

@abayegan
Copy link
Author

Thanks for generating this example!

@olneykimberly
Copy link

so what is the solution?

@samuel-marsh
Copy link
Collaborator

Hi @olneykimberly for now (or for future) you can use FeaturePlot_scCustom from scCustomize package. See this vignette: https://samuel-marsh.github.io/scCustomize/articles/Gene_Expression_Plotting.html for more info. When using split.by it will preserve scale across plots.

Best,
Sam

@samuel-marsh
Copy link
Collaborator

For future reference this issue was also fixed within Seurat with 4.1 release.

https://github.com/satijalab/seurat/blob/master/NEWS.md#seurat-410-2022-01-14

@ShanshuoZHU
Copy link

ShanshuoZHU commented Aug 25, 2023

Hi @olneykimberly for now (or for future) you can use FeaturePlot_scCustom from scCustomize package. See this vignette: https://samuel-marsh.github.io/scCustomize/articles/Gene_Expression_Plotting.html for more info. When using split.by it will preserve scale across plots.

Best, Sam

Hi @samuel-marsh , now I am trying to use FeaturePlot_scCustom and I am usingsplit.by and only have 1 feature. I find that when set 'na_cutoff = NA', the scale is not kept the same across plots for some features and all the scale legends will be displayed. but if donot set 'na_cutoff = NA', the scale will be preserved and only 1 scale legend displayed. why the na_cutoff setting affects the scale/legend and how can I avoid that? Thanks a lot.

Picture3

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

4 participants