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

Text does not appear in DarkTheme in FeaturePlot #1361

Closed
fly4all opened this issue Apr 11, 2019 · 7 comments
Closed

Text does not appear in DarkTheme in FeaturePlot #1361

fly4all opened this issue Apr 11, 2019 · 7 comments

Comments

@fly4all
Copy link

fly4all commented Apr 11, 2019

I tried applying dark theme onto my tSNE feature plot but it seems that font might still be black in color and so, I'm unable to see it with the dark background.
Is there any fix for this?

Code:
baseplot <- FeaturePlot(object=decoder, features= features, reduction='tsne', pt.size=0.1)
baseplot + DarkTheme()

Screen Shot 2019-04-11 at 1 02 07 PM

@mojaveazure
Copy link
Member

Hi Maria,

This is happening because CombinePlots using cowplot::plot_grid which disables modifying individual plot components. CombinePlots is automatically called when plotting multiple features to keep everything together nicely.

To get around this, pass combine = FALSE to FeaturePlot, modify your plots in a for-loop or with lapply, then call CombinePlots to stitch everything together for you.

baseplot <- FeaturePlot(object = decoder, features = features, reduction = 'tsne', pt.size = 0.1, combine = FALSE)
for (i in 1:length(x = baseplot) {
  baseplot[[i]] <- baseplot[[i]] + DarkTheme()
}
# Can also use lapply
baseplot <- lapply(
  X = baseplot,
  FUN = function(p) {
    return(p + DarkTheme())
  }
)
CombinePlots(plots = baseplot, ncol = 2)

@fly4all
Copy link
Author

fly4all commented Apr 11, 2019

Hi Paul,

Thank you for the quick response. I tried both the methods but it gives me an error.

Upon doing it with for loop:

Error in baseplot[[i]] + DarkTheme() : 
  non-numeric argument to binary operator
In addition: Warning message:
In baseplot[[i]] + DarkTheme() :
  Incompatible methods ("Ops.data.frame", "+.gg") for "+

Upon running the lapply method (I have always run into an error trying to run combinePlots, I'm not sure why):

> baseplot <- lapply(
+   X = baseplot,
+   FUN = function(p) {
+     return(p + DarkTheme())
+   }
+ )
Error in p + DarkTheme() : non-numeric argument to binary operator
In addition: Warning message:
In FUN(X[[i]], ...) :
  Incompatible methods ("Ops.data.frame", "+.gg") for "+"
> CombinePlots(plots = baseplot, ncol = 2)
Error in plot_to_gtable(x) : 
  Argument needs to be of class "ggplot", "gtable", "grob", "recordedplot", or a function that plots to an R graphicsdevice when called, but is a data.frame

@mojaveazure
Copy link
Member

Hi Maria,

You need to rerun FeaturePlot and pass combine = FALSE like I said above.

@fly4all
Copy link
Author

fly4all commented Apr 11, 2019

Oh, sorry I missed on that.
It works now, thank you!

@fly4all fly4all closed this as completed Apr 11, 2019
@ondina-draia
Copy link

The only problem remaining is that the cluster labels are still black

@samuel-marsh
Copy link
Collaborator

@ondina-draia just submitted PR #5314 to add this parameter to FeaturePlot (already possible in DimPlot).

Best,
Sam

@ondina-draia
Copy link

@samuel-marsh This is wonderful, thank you 😊

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

4 participants