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

Allow feature names to be plotted in secondary Y axis instead of in the color legend #60

Closed
gabrielnegreira opened this issue Sep 20, 2022 · 3 comments
Assignees
Labels
enhancement Enhance existing function/feature

Comments

@gabrielnegreira
Copy link

Hi,

First, thanks a lot for the package, it is very useful!

I have a problem with the FeaturePlot_scCustom function. The gene names for the organism I am studying are quite big (for instance: "typeII-glutathioneperoxidase-like-tryparedoxinperoxidase.1"

In the FeaturePlot function from seurat, the feature names are ploted in the secondary Y axis if "split.by" is set:

features_to_plot <- c("hypotheticalprotein.50", "typeII-glutathioneperoxidase-like-tryparedoxinperoxidase.1") FeaturePlot(seuratObj, features_to_plot, split.by = "sample")

seurat

However, in FeaturePlot_scCustom, the feature names are plotted as a title for the color scale. In case gene names have different sizes, this leads to plots with different widths:

features_to_plot <- c("hypotheticalprotein.50", "typeII-glutathioneperoxidase-like-tryparedoxinperoxidase.1") FeaturePlot_scCustom(seuratObj, features_to_plot, split.by = "sample")

Rplot

I can fix this by removing the legend title by adding a theme() function:

features_to_plot <- c("hypotheticalprotein.50", "typeII-glutathioneperoxidase-like-tryparedoxinperoxidase.1") FeaturePlot_scCustom(seuratObj, features_to_plot, split.by = "sample")& theme(legend.title = element_blank())
Rplot01

But then there is no information on which feature is being plotted in each row. Would it be possible to add an option to plot the feature names in the secondary Y axis as FeaturePlot() from seurat does?

Thanks once again for the package!

Gabriel

@samuel-marsh
Copy link
Owner

Hi Gabriel,

Thanks for kind words. I think I can probably do that but it would have to come with tradeoffs. The reason I don't use secondary y-axis for gene names is because I've implemented code to allow for selection of column number when returning split plots (which Seurat doesn't, potentially for this reason?). Therefore it's possible to end up with multiple features in same row.

I think I can implement an optional parameter to switch it to the secondary y-axis with the sacrifice that column number will be automatically set based on the number of split.by conditions to avoid issues in confused labeling.

How does that sound?

Best,
Sam

@samuel-marsh samuel-marsh self-assigned this Sep 22, 2022
@samuel-marsh samuel-marsh added the enhancement Enhance existing function/feature label Sep 22, 2022
@gabrielnegreira
Copy link
Author

Hi Samuel,

Thanks a lot for the quick response! I think it sounds good!

Best,

Gabriel

@samuel-marsh samuel-marsh mentioned this issue Oct 2, 2022
11 tasks
@samuel-marsh
Copy link
Owner

Hey Gabriel,

Feature is now live in the dev branch v0.7.0.9946. The new parameter is called label_feature_yaxis and logical that is set to FALSE by default. It is only applicable when using split.by and again when used it will auto set the number of columns of the output. It will issue a warning if user tries to set provide column number and set parameter to TRUE and abort the function if user does not provide split.by.

Here is quick example:

library(tidyverse)
library(Seurat)
library(scCustomize)

pbmc <- pbmc3k.SeuratData::pbmc3k.final
pbmc <- UpdateSeuratObject(object = pbmc)
pbmc$sample_id <- sample(c("sample1", "sample2", "sample3"), size = ncol(pbmc),
                         replace = TRUE)

FeaturePlot_scCustom(seurat_object = pbmc, "CD3E", split.by = "sample_id", label_feature_yaxis = TRUE)

image

If you have any issues let me know and I can reopen the issue. I will be planning on full release on master branch for scCustomize this week or next but develop branch should be stable to download now for you to start using function.

Best,
Sam

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhance existing function/feature
Projects
None yet
Development

No branches or pull requests

2 participants